Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2022-present Open Networking Foundation |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package format |
| 17 | |
| 18 | import ( |
| 19 | "os" |
| 20 | |
| 21 | app "voltha-go-controller/internal/pkg/application" |
| 22 | "voltha-go-controller/voltha-go-controller/cli/database" |
| 23 | "voltha-go-controller/voltha-go-controller/cli/models" |
| 24 | "voltha-go-controller/voltha-go-controller/nbi" |
| 25 | ) |
| 26 | |
| 27 | // Table interface for entry type in the table |
| 28 | type Table interface { |
| 29 | // For database based commands |
| 30 | SingleEntry(config *database.Data) |
| 31 | MultipleEntries(configs map[string]*database.Data) |
| 32 | // For API based Cache commands |
| 33 | SingleDataEntry(config map[string]map[string]bool) |
| 34 | MultipleDataEntries(configs map[string]map[string]bool) |
| 35 | // For API based ICMPv6 Cache commands |
| 36 | SingleIcmpDataEntry(config map[string]map[string]int) |
| 37 | MultipleIcmpDataEntries(configs map[string]map[string]int) |
| 38 | // For API based Cache Port commands |
| 39 | SinglePortDataEntry(config map[string][]*app.VoltPort) |
| 40 | MultiplePortDataEntries(configs map[string][]*app.VoltPort) |
| 41 | // For API based TaskList commands |
| 42 | SingleDeviceTaskList(config map[string]map[int]*app.TaskInfo) |
| 43 | MultipleDeviceTaskList(configs map[string]map[int]*app.TaskInfo) |
| 44 | // For API based Device Info commands |
| 45 | SingleDeviceInfo(config map[string]map[string]*nbi.DeviceInfo) |
| 46 | MultipleDeviceInfo(configs map[string]map[string]*nbi.DeviceInfo) |
| 47 | // For API based PON Ports commands |
| 48 | SinglePonPortDataEntry(config map[string][]*app.PonPortCfg) |
| 49 | MultiplePonPortDataEntries(configs map[string][]*app.PonPortCfg) |
| 50 | // For API based DHCP Session Info Commands |
| 51 | MultipleDhcpSessionInfo(config []*nbi.DhcpSessionInfo) |
| 52 | SingleDhcpSessionInfo(config []*nbi.DhcpSessionInfo) |
| 53 | } |
| 54 | |
| 55 | // NewTable function to create a new table |
| 56 | func NewTable(title models.TableTitle, orientation models.Orientation) Table { |
| 57 | switch orientation { |
| 58 | case models.Horizontal: |
| 59 | return newHorizontalTable(title, os.Stdout) |
| 60 | case models.Vertical: |
| 61 | return newVerticalTable(title, os.Stdout) |
| 62 | } |
| 63 | return newHorizontalTable(title, os.Stdout) |
| 64 | } |