forked from ciscoecosystem/aci-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infra_rs_func_to_epg.go
112 lines (76 loc) · 2.86 KB
/
infra_rs_func_to_epg.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/container"
)
const InfrarsfunctoepgClassName = "infraRsFuncToEpg"
type EPGsUsingFunction struct {
BaseAttributes
EPGsUsingFunctionAttributes
}
type EPGsUsingFunctionAttributes 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 NewEPGsUsingFunction(infraRsFuncToEpgRn, parentDn, description string, infraRsFuncToEpgattr EPGsUsingFunctionAttributes) *EPGsUsingFunction {
dn := fmt.Sprintf("%s/%s", parentDn, infraRsFuncToEpgRn)
return &EPGsUsingFunction{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: InfrarsfunctoepgClassName,
Rn: infraRsFuncToEpgRn,
},
EPGsUsingFunctionAttributes: infraRsFuncToEpgattr,
}
}
func (infraRsFuncToEpg *EPGsUsingFunction) ToMap() (map[string]string, error) {
infraRsFuncToEpgMap, err := infraRsFuncToEpg.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(infraRsFuncToEpgMap, "tDn", infraRsFuncToEpg.TDn)
A(infraRsFuncToEpgMap, "annotation", infraRsFuncToEpg.Annotation)
A(infraRsFuncToEpgMap, "encap", infraRsFuncToEpg.Encap)
A(infraRsFuncToEpgMap, "instrImedcy", infraRsFuncToEpg.InstrImedcy)
A(infraRsFuncToEpgMap, "mode", infraRsFuncToEpg.Mode)
A(infraRsFuncToEpgMap, "primaryEncap", infraRsFuncToEpg.PrimaryEncap)
return infraRsFuncToEpgMap, err
}
func EPGsUsingFunctionFromContainerList(cont *container.Container, index int) *EPGsUsingFunction {
EPGsUsingFunctionCont := cont.S("imdata").Index(index).S(InfrarsfunctoepgClassName, "attributes")
return &EPGsUsingFunction{
BaseAttributes{
DistinguishedName: G(EPGsUsingFunctionCont, "dn"),
Description: G(EPGsUsingFunctionCont, "descr"),
Status: G(EPGsUsingFunctionCont, "status"),
ClassName: InfrarsfunctoepgClassName,
Rn: G(EPGsUsingFunctionCont, "rn"),
},
EPGsUsingFunctionAttributes{
TDn: G(EPGsUsingFunctionCont, "tDn"),
Annotation: G(EPGsUsingFunctionCont, "annotation"),
Encap: G(EPGsUsingFunctionCont, "encap"),
InstrImedcy: G(EPGsUsingFunctionCont, "instrImedcy"),
Mode: G(EPGsUsingFunctionCont, "mode"),
PrimaryEncap: G(EPGsUsingFunctionCont, "primaryEncap"),
},
}
}
func EPGsUsingFunctionFromContainer(cont *container.Container) *EPGsUsingFunction {
return EPGsUsingFunctionFromContainerList(cont, 0)
}
func EPGsUsingFunctionListFromContainer(cont *container.Container) []*EPGsUsingFunction {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*EPGsUsingFunction, length)
for i := 0; i < length; i++ {
arr[i] = EPGsUsingFunctionFromContainerList(cont, i)
}
return arr
}