-
Notifications
You must be signed in to change notification settings - Fork 30
/
infra_rs_sp_acc_port_p.go
88 lines (64 loc) · 2.26 KB
/
infra_rs_sp_acc_port_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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const InfrarsspaccportpClassName = "infraRsSpAccPortP"
type InterfaceProfile struct {
BaseAttributes
InterfaceProfileAttributes
}
type InterfaceProfileAttributes struct {
TDn string `json:",omitempty"`
Annotation string `json:",omitempty"`
}
func NewInterfaceProfile(infraRsSpAccPortPRn, parentDn, description string, infraRsSpAccPortPattr InterfaceProfileAttributes) *InterfaceProfile {
dn := fmt.Sprintf("%s/%s", parentDn, infraRsSpAccPortPRn)
return &InterfaceProfile{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: InfrarsspaccportpClassName,
Rn: infraRsSpAccPortPRn,
},
InterfaceProfileAttributes: infraRsSpAccPortPattr,
}
}
func (infraRsSpAccPortP *InterfaceProfile) ToMap() (map[string]string, error) {
infraRsSpAccPortPMap, err := infraRsSpAccPortP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(infraRsSpAccPortPMap, "tDn", infraRsSpAccPortP.TDn)
A(infraRsSpAccPortPMap, "annotation", infraRsSpAccPortP.Annotation)
return infraRsSpAccPortPMap, err
}
func InterfaceProfileFromContainerList(cont *container.Container, index int) *InterfaceProfile {
InterfaceProfileCont := cont.S("imdata").Index(index).S(InfrarsspaccportpClassName, "attributes")
return &InterfaceProfile{
BaseAttributes{
DistinguishedName: G(InterfaceProfileCont, "dn"),
Description: G(InterfaceProfileCont, "descr"),
Status: G(InterfaceProfileCont, "status"),
ClassName: InfrarsspaccportpClassName,
Rn: G(InterfaceProfileCont, "rn"),
},
InterfaceProfileAttributes{
TDn: G(InterfaceProfileCont, "tDn"),
Annotation: G(InterfaceProfileCont, "annotation"),
},
}
}
func InterfaceProfileFromContainer(cont *container.Container) *InterfaceProfile {
return InterfaceProfileFromContainerList(cont, 0)
}
func InterfaceProfileListFromContainer(cont *container.Container) []*InterfaceProfile {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*InterfaceProfile, length)
for i := 0; i < length; i++ {
arr[i] = InterfaceProfileFromContainerList(cont, i)
}
return arr
}