forked from ciscoecosystem/aci-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
l3ext_l_node_p.go
146 lines (76 loc) · 3.05 KB
/
l3ext_l_node_p.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const L3extlnodepClassName = "l3extLNodeP"
type LogicalNodeProfile struct {
BaseAttributes
LogicalNodeProfileAttributes
}
type LogicalNodeProfileAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
ConfigIssues string `json:",omitempty"`
NameAlias string `json:",omitempty"`
Tag string `json:",omitempty"`
TargetDscp string `json:",omitempty"`
}
func NewLogicalNodeProfile(l3extLNodePRn, parentDn, description string, l3extLNodePattr LogicalNodeProfileAttributes) *LogicalNodeProfile {
dn := fmt.Sprintf("%s/%s", parentDn, l3extLNodePRn)
return &LogicalNodeProfile{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: L3extlnodepClassName,
Rn: l3extLNodePRn,
},
LogicalNodeProfileAttributes: l3extLNodePattr,
}
}
func (l3extLNodeP *LogicalNodeProfile) ToMap() (map[string]string, error) {
l3extLNodePMap, err := l3extLNodeP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(l3extLNodePMap, "name",l3extLNodeP.Name)
A(l3extLNodePMap, "annotation",l3extLNodeP.Annotation)
A(l3extLNodePMap, "configIssues",l3extLNodeP.ConfigIssues)
A(l3extLNodePMap, "nameAlias",l3extLNodeP.NameAlias)
A(l3extLNodePMap, "tag",l3extLNodeP.Tag)
A(l3extLNodePMap, "targetDscp",l3extLNodeP.TargetDscp)
return l3extLNodePMap, err
}
func LogicalNodeProfileFromContainerList(cont *container.Container, index int) *LogicalNodeProfile {
LogicalNodeProfileCont := cont.S("imdata").Index(index).S(L3extlnodepClassName, "attributes")
return &LogicalNodeProfile{
BaseAttributes{
DistinguishedName: G(LogicalNodeProfileCont, "dn"),
Description: G(LogicalNodeProfileCont, "descr"),
Status: G(LogicalNodeProfileCont, "status"),
ClassName: L3extlnodepClassName,
Rn: G(LogicalNodeProfileCont, "rn"),
},
LogicalNodeProfileAttributes{
Name : G(LogicalNodeProfileCont, "name"),
Annotation : G(LogicalNodeProfileCont, "annotation"),
ConfigIssues : G(LogicalNodeProfileCont, "configIssues"),
NameAlias : G(LogicalNodeProfileCont, "nameAlias"),
Tag : G(LogicalNodeProfileCont, "tag"),
TargetDscp : G(LogicalNodeProfileCont, "targetDscp"),
},
}
}
func LogicalNodeProfileFromContainer(cont *container.Container) *LogicalNodeProfile {
return LogicalNodeProfileFromContainerList(cont, 0)
}
func LogicalNodeProfileListFromContainer(cont *container.Container) []*LogicalNodeProfile {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*LogicalNodeProfile, length)
for i := 0; i < length; i++ {
arr[i] = LogicalNodeProfileFromContainerList(cont, i)
}
return arr
}