-
Notifications
You must be signed in to change notification settings - Fork 29
/
leak_routes.go
98 lines (83 loc) · 2.96 KB
/
leak_routes.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
DnleakRoutes = "uni/tn-%s/ctx-%s/leakroutes"
RnleakRoutes = "leakroutes"
ParentDnleakRoutes = "uni/tn-%s/ctx-%s"
LeakroutesClassName = "leakRoutes"
)
type InterVRFLeakedRoutesContainer struct {
BaseAttributes
NameAliasAttribute
InterVRFLeakedRoutesContainerAttributes
}
type InterVRFLeakedRoutesContainerAttributes struct {
Annotation string `json:",omitempty"`
Name string `json:",omitempty"`
}
func NewInterVRFLeakedRoutesContainer(leakRoutesRn, parentDn, description, nameAlias string, leakRoutesAttr InterVRFLeakedRoutesContainerAttributes) *InterVRFLeakedRoutesContainer {
dn := fmt.Sprintf("%s/%s", parentDn, leakRoutesRn)
return &InterVRFLeakedRoutesContainer{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: LeakroutesClassName,
Rn: leakRoutesRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
InterVRFLeakedRoutesContainerAttributes: leakRoutesAttr,
}
}
func (leakRoutes *InterVRFLeakedRoutesContainer) ToMap() (map[string]string, error) {
leakRoutesMap, err := leakRoutes.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := leakRoutes.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(leakRoutesMap, key, value)
}
A(leakRoutesMap, "annotation", leakRoutes.Annotation)
A(leakRoutesMap, "name", leakRoutes.Name)
return leakRoutesMap, err
}
func InterVRFLeakedRoutesContainerFromContainerList(cont *container.Container, index int) *InterVRFLeakedRoutesContainer {
InterVRFLeakedRoutesContainerCont := cont.S("imdata").Index(index).S(LeakroutesClassName, "attributes")
return &InterVRFLeakedRoutesContainer{
BaseAttributes{
DistinguishedName: G(InterVRFLeakedRoutesContainerCont, "dn"),
Description: G(InterVRFLeakedRoutesContainerCont, "descr"),
Status: G(InterVRFLeakedRoutesContainerCont, "status"),
ClassName: LeakroutesClassName,
Rn: G(InterVRFLeakedRoutesContainerCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(InterVRFLeakedRoutesContainerCont, "nameAlias"),
},
InterVRFLeakedRoutesContainerAttributes{
Annotation: G(InterVRFLeakedRoutesContainerCont, "annotation"),
Name: G(InterVRFLeakedRoutesContainerCont, "name"),
},
}
}
func InterVRFLeakedRoutesContainerFromContainer(cont *container.Container) *InterVRFLeakedRoutesContainer {
return InterVRFLeakedRoutesContainerFromContainerList(cont, 0)
}
func InterVRFLeakedRoutesContainerListFromContainer(cont *container.Container) []*InterVRFLeakedRoutesContainer {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*InterVRFLeakedRoutesContainer, length)
for i := 0; i < length; i++ {
arr[i] = InterVRFLeakedRoutesContainerFromContainerList(cont, i)
}
return arr
}