-
Notifications
You must be signed in to change notification settings - Fork 30
/
fv_ep_ret_pol.go
130 lines (85 loc) · 3.45 KB
/
fv_ep_ret_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
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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FvepretpolClassName = "fvEpRetPol"
type EndPointRetentionPolicy struct {
BaseAttributes
EndPointRetentionPolicyAttributes
}
type EndPointRetentionPolicyAttributes struct {
Name string `json:",omitempty"`
Annotation string `json:",omitempty"`
BounceAgeIntvl string `json:",omitempty"`
BounceTrig string `json:",omitempty"`
HoldIntvl string `json:",omitempty"`
LocalEpAgeIntvl string `json:",omitempty"`
MoveFreq string `json:",omitempty"`
NameAlias string `json:",omitempty"`
RemoteEpAgeIntvl string `json:",omitempty"`
}
func NewEndPointRetentionPolicy(fvEpRetPolRn, parentDn, description string, fvEpRetPolattr EndPointRetentionPolicyAttributes) *EndPointRetentionPolicy {
dn := fmt.Sprintf("%s/%s", parentDn, fvEpRetPolRn)
return &EndPointRetentionPolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FvepretpolClassName,
Rn: fvEpRetPolRn,
},
EndPointRetentionPolicyAttributes: fvEpRetPolattr,
}
}
func (fvEpRetPol *EndPointRetentionPolicy) ToMap() (map[string]string, error) {
fvEpRetPolMap, err := fvEpRetPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fvEpRetPolMap, "name", fvEpRetPol.Name)
A(fvEpRetPolMap, "annotation", fvEpRetPol.Annotation)
A(fvEpRetPolMap, "bounceAgeIntvl", fvEpRetPol.BounceAgeIntvl)
A(fvEpRetPolMap, "bounceTrig", fvEpRetPol.BounceTrig)
A(fvEpRetPolMap, "holdIntvl", fvEpRetPol.HoldIntvl)
A(fvEpRetPolMap, "localEpAgeIntvl", fvEpRetPol.LocalEpAgeIntvl)
A(fvEpRetPolMap, "moveFreq", fvEpRetPol.MoveFreq)
A(fvEpRetPolMap, "nameAlias", fvEpRetPol.NameAlias)
A(fvEpRetPolMap, "remoteEpAgeIntvl", fvEpRetPol.RemoteEpAgeIntvl)
return fvEpRetPolMap, err
}
func EndPointRetentionPolicyFromContainerList(cont *container.Container, index int) *EndPointRetentionPolicy {
EndPointRetentionPolicyCont := cont.S("imdata").Index(index).S(FvepretpolClassName, "attributes")
return &EndPointRetentionPolicy{
BaseAttributes{
DistinguishedName: G(EndPointRetentionPolicyCont, "dn"),
Description: G(EndPointRetentionPolicyCont, "descr"),
Status: G(EndPointRetentionPolicyCont, "status"),
ClassName: FvepretpolClassName,
Rn: G(EndPointRetentionPolicyCont, "rn"),
},
EndPointRetentionPolicyAttributes{
Name: G(EndPointRetentionPolicyCont, "name"),
Annotation: G(EndPointRetentionPolicyCont, "annotation"),
BounceAgeIntvl: G(EndPointRetentionPolicyCont, "bounceAgeIntvl"),
BounceTrig: G(EndPointRetentionPolicyCont, "bounceTrig"),
HoldIntvl: G(EndPointRetentionPolicyCont, "holdIntvl"),
LocalEpAgeIntvl: G(EndPointRetentionPolicyCont, "localEpAgeIntvl"),
MoveFreq: G(EndPointRetentionPolicyCont, "moveFreq"),
NameAlias: G(EndPointRetentionPolicyCont, "nameAlias"),
RemoteEpAgeIntvl: G(EndPointRetentionPolicyCont, "remoteEpAgeIntvl"),
},
}
}
func EndPointRetentionPolicyFromContainer(cont *container.Container) *EndPointRetentionPolicy {
return EndPointRetentionPolicyFromContainerList(cont, 0)
}
func EndPointRetentionPolicyListFromContainer(cont *container.Container) []*EndPointRetentionPolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*EndPointRetentionPolicy, length)
for i := 0; i < length; i++ {
arr[i] = EndPointRetentionPolicyFromContainerList(cont, i)
}
return arr
}