-
Notifications
You must be signed in to change notification settings - Fork 30
/
fv_rs_path_att.go
151 lines (76 loc) · 2.82 KB
/
fv_rs_path_att.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
147
148
149
150
151
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FvrspathattClassName = "fvRsPathAtt"
type StaticPath struct {
BaseAttributes
StaticPathAttributes
}
type StaticPathAttributes struct {
TDn string `json:",omitempty"`
Annotation string `json:",omitempty"`
Encap string `json:",omitempty"`
InstrImedcy string `json:",omitempty"`
Mode string `json:",omitempty"`
PrimaryEncap string `json:",omitempty"`
}
func NewStaticPath(fvRsPathAttRn, parentDn, description string, fvRsPathAttattr StaticPathAttributes) *StaticPath {
dn := fmt.Sprintf("%s/%s", parentDn, fvRsPathAttRn)
return &StaticPath{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FvrspathattClassName,
Rn: fvRsPathAttRn,
},
StaticPathAttributes: fvRsPathAttattr,
}
}
func (fvRsPathAtt *StaticPath) ToMap() (map[string]string, error) {
fvRsPathAttMap, err := fvRsPathAtt.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fvRsPathAttMap, "tDn",fvRsPathAtt.TDn)
A(fvRsPathAttMap, "annotation",fvRsPathAtt.Annotation)
A(fvRsPathAttMap, "encap",fvRsPathAtt.Encap)
A(fvRsPathAttMap, "instrImedcy",fvRsPathAtt.InstrImedcy)
A(fvRsPathAttMap, "mode",fvRsPathAtt.Mode)
A(fvRsPathAttMap, "primaryEncap",fvRsPathAtt.PrimaryEncap)
return fvRsPathAttMap, err
}
func StaticPathFromContainerList(cont *container.Container, index int) *StaticPath {
StaticPathCont := cont.S("imdata").Index(index).S(FvrspathattClassName, "attributes")
return &StaticPath{
BaseAttributes{
DistinguishedName: G(StaticPathCont, "dn"),
Description: G(StaticPathCont, "descr"),
Status: G(StaticPathCont, "status"),
ClassName: FvrspathattClassName,
Rn: G(StaticPathCont, "rn"),
},
StaticPathAttributes{
TDn : G(StaticPathCont, "tDn"),
Annotation : G(StaticPathCont, "annotation"),
Encap : G(StaticPathCont, "encap"),
InstrImedcy : G(StaticPathCont, "instrImedcy"),
Mode : G(StaticPathCont, "mode"),
PrimaryEncap : G(StaticPathCont, "primaryEncap"),
},
}
}
func StaticPathFromContainer(cont *container.Container) *StaticPath {
return StaticPathFromContainerList(cont, 0)
}
func StaticPathListFromContainer(cont *container.Container) []*StaticPath {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*StaticPath, length)
for i := 0; i < length; i++ {
arr[i] = StaticPathFromContainerList(cont, i)
}
return arr
}