-
Notifications
You must be signed in to change notification settings - Fork 30
/
ospf_rt_summ_pol.go
112 lines (76 loc) · 2.95 KB
/
ospf_rt_summ_pol.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const OspfrtsummpolClassName = "ospfRtSummPol"
type OspfRouteSummarization struct {
BaseAttributes
OspfRouteSummarizationAttributes
}
type OspfRouteSummarizationAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
Cost string `json:",omitempty"`
InterAreaEnabled string `json:",omitempty"`
NameAlias string `json:",omitempty"`
Tag string `json:",omitempty"`
}
func NewOspfRouteSummarization(ospfRtSummPolRn, parentDn, description string, ospfRtSummPolattr OspfRouteSummarizationAttributes) *OspfRouteSummarization {
dn := fmt.Sprintf("%s/%s", parentDn, ospfRtSummPolRn)
return &OspfRouteSummarization{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: OspfrtsummpolClassName,
Rn: ospfRtSummPolRn,
},
OspfRouteSummarizationAttributes: ospfRtSummPolattr,
}
}
func (ospfRtSummPol *OspfRouteSummarization) ToMap() (map[string]string, error) {
ospfRtSummPolMap, err := ospfRtSummPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(ospfRtSummPolMap, "name", ospfRtSummPol.Name)
A(ospfRtSummPolMap, "annotation", ospfRtSummPol.Annotation)
A(ospfRtSummPolMap, "cost", ospfRtSummPol.Cost)
A(ospfRtSummPolMap, "interAreaEnabled", ospfRtSummPol.InterAreaEnabled)
A(ospfRtSummPolMap, "nameAlias", ospfRtSummPol.NameAlias)
A(ospfRtSummPolMap, "tag", ospfRtSummPol.Tag)
return ospfRtSummPolMap, err
}
func OspfRouteSummarizationFromContainerList(cont *container.Container, index int) *OspfRouteSummarization {
OspfRouteSummarizationCont := cont.S("imdata").Index(index).S(OspfrtsummpolClassName, "attributes")
return &OspfRouteSummarization{
BaseAttributes{
DistinguishedName: G(OspfRouteSummarizationCont, "dn"),
Description: G(OspfRouteSummarizationCont, "descr"),
Status: G(OspfRouteSummarizationCont, "status"),
ClassName: OspfrtsummpolClassName,
Rn: G(OspfRouteSummarizationCont, "rn"),
},
OspfRouteSummarizationAttributes{
Name: G(OspfRouteSummarizationCont, "name"),
Annotation: G(OspfRouteSummarizationCont, "annotation"),
Cost: G(OspfRouteSummarizationCont, "cost"),
InterAreaEnabled: G(OspfRouteSummarizationCont, "interAreaEnabled"),
NameAlias: G(OspfRouteSummarizationCont, "nameAlias"),
Tag: G(OspfRouteSummarizationCont, "tag"),
},
}
}
func OspfRouteSummarizationFromContainer(cont *container.Container) *OspfRouteSummarization {
return OspfRouteSummarizationFromContainerList(cont, 0)
}
func OspfRouteSummarizationListFromContainer(cont *container.Container) []*OspfRouteSummarization {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*OspfRouteSummarization, length)
for i := 0; i < length; i++ {
arr[i] = OspfRouteSummarizationFromContainerList(cont, i)
}
return arr
}