-
Notifications
You must be signed in to change notification settings - Fork 29
/
pim_nbr_filter_pol.go
85 lines (72 loc) · 2.68 KB
/
pim_nbr_filter_pol.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
RnPimNbrFilterPol = "nbrfilter"
DnPimNbrFilterPol = "uni/tn-%s/pimifpol-%s/nbrfilter"
ParentDnPimNbrFilterPol = "uni/tn-%s/pimifpol-%s"
PimNbrFilterPolClassName = "pimNbrFilterPol"
)
type PIMNeighborFiterPolicy struct {
BaseAttributes
PIMNeighborFiterPolicyAttributes
}
type PIMNeighborFiterPolicyAttributes struct {
Annotation string `json:",omitempty"`
Name string `json:",omitempty"`
NameAlias string `json:",omitempty"`
}
func NewPIMNeighborFiterPolicy(parentDn, description string, pimNbrFilterPolAttr PIMNeighborFiterPolicyAttributes) *PIMNeighborFiterPolicy {
dn := fmt.Sprintf("%s/%s", parentDn, RnPimNbrFilterPol)
return &PIMNeighborFiterPolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: PimNbrFilterPolClassName,
Rn: RnPimNbrFilterPol,
},
PIMNeighborFiterPolicyAttributes: pimNbrFilterPolAttr,
}
}
func (pimNbrFilterPol *PIMNeighborFiterPolicy) ToMap() (map[string]string, error) {
pimNbrFilterPolMap, err := pimNbrFilterPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(pimNbrFilterPolMap, "annotation", pimNbrFilterPol.Annotation)
A(pimNbrFilterPolMap, "name", pimNbrFilterPol.Name)
A(pimNbrFilterPolMap, "nameAlias", pimNbrFilterPol.NameAlias)
return pimNbrFilterPolMap, err
}
func PIMNeighborFiterPolicyFromContainerList(cont *container.Container, index int) *PIMNeighborFiterPolicy {
PIMNeighborFiterPolicyCont := cont.S("imdata").Index(index).S(PimNbrFilterPolClassName, "attributes")
return &PIMNeighborFiterPolicy{
BaseAttributes{
DistinguishedName: G(PIMNeighborFiterPolicyCont, "dn"),
Description: G(PIMNeighborFiterPolicyCont, "descr"),
Status: G(PIMNeighborFiterPolicyCont, "status"),
ClassName: PimNbrFilterPolClassName,
Rn: G(PIMNeighborFiterPolicyCont, "rn"),
},
PIMNeighborFiterPolicyAttributes{
Annotation: G(PIMNeighborFiterPolicyCont, "annotation"),
Name: G(PIMNeighborFiterPolicyCont, "name"),
NameAlias: G(PIMNeighborFiterPolicyCont, "nameAlias"),
},
}
}
func PIMNeighborFiterPolicyFromContainer(cont *container.Container) *PIMNeighborFiterPolicy {
return PIMNeighborFiterPolicyFromContainerList(cont, 0)
}
func PIMNeighborFiterPolicyListFromContainer(cont *container.Container) []*PIMNeighborFiterPolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*PIMNeighborFiterPolicy, length)
for i := 0; i < length; i++ {
arr[i] = PIMNeighborFiterPolicyFromContainerList(cont, i)
}
return arr
}