-
Notifications
You must be signed in to change notification settings - Fork 29
/
infra_acc_port_p.go
94 lines (67 loc) · 2.45 KB
/
infra_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
89
90
91
92
93
94
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const InfraaccportpClassName = "infraAccPortP"
type LeafInterfaceProfile struct {
BaseAttributes
LeafInterfaceProfileAttributes
}
type LeafInterfaceProfileAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
NameAlias string `json:",omitempty"`
}
func NewLeafInterfaceProfile(infraAccPortPRn, parentDn, description string, infraAccPortPattr LeafInterfaceProfileAttributes) *LeafInterfaceProfile {
dn := fmt.Sprintf("%s/%s", parentDn, infraAccPortPRn)
return &LeafInterfaceProfile{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: InfraaccportpClassName,
Rn: infraAccPortPRn,
},
LeafInterfaceProfileAttributes: infraAccPortPattr,
}
}
func (infraAccPortP *LeafInterfaceProfile) ToMap() (map[string]string, error) {
infraAccPortPMap, err := infraAccPortP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(infraAccPortPMap, "name", infraAccPortP.Name)
A(infraAccPortPMap, "annotation", infraAccPortP.Annotation)
A(infraAccPortPMap, "nameAlias", infraAccPortP.NameAlias)
return infraAccPortPMap, err
}
func LeafInterfaceProfileFromContainerList(cont *container.Container, index int) *LeafInterfaceProfile {
LeafInterfaceProfileCont := cont.S("imdata").Index(index).S(InfraaccportpClassName, "attributes")
return &LeafInterfaceProfile{
BaseAttributes{
DistinguishedName: G(LeafInterfaceProfileCont, "dn"),
Description: G(LeafInterfaceProfileCont, "descr"),
Status: G(LeafInterfaceProfileCont, "status"),
ClassName: InfraaccportpClassName,
Rn: G(LeafInterfaceProfileCont, "rn"),
},
LeafInterfaceProfileAttributes{
Name: G(LeafInterfaceProfileCont, "name"),
Annotation: G(LeafInterfaceProfileCont, "annotation"),
NameAlias: G(LeafInterfaceProfileCont, "nameAlias"),
},
}
}
func LeafInterfaceProfileFromContainer(cont *container.Container) *LeafInterfaceProfile {
return LeafInterfaceProfileFromContainerList(cont, 0)
}
func LeafInterfaceProfileListFromContainer(cont *container.Container) []*LeafInterfaceProfile {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*LeafInterfaceProfile, length)
for i := 0; i < length; i++ {
arr[i] = LeafInterfaceProfileFromContainerList(cont, i)
}
return arr
}