forked from ciscoecosystem/aci-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vns_svc_redirect_pol.go
148 lines (94 loc) · 4.33 KB
/
vns_svc_redirect_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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const VnssvcredirectpolClassName = "vnsSvcRedirectPol"
type ServiceRedirectPolicy struct {
BaseAttributes
ServiceRedirectPolicyAttributes
}
type ServiceRedirectPolicyAttributes struct {
Name string `json:",omitempty"`
AnycastEnabled string `json:",omitempty"`
Annotation string `json:",omitempty"`
DestType string `json:",omitempty"`
HashingAlgorithm string `json:",omitempty"`
MaxThresholdPercent string `json:",omitempty"`
MinThresholdPercent string `json:",omitempty"`
NameAlias string `json:",omitempty"`
ProgramLocalPodOnly string `json:",omitempty"`
ResilientHashEnabled string `json:",omitempty"`
ThresholdDownAction string `json:",omitempty"`
ThresholdEnable string `json:",omitempty"`
}
func NewServiceRedirectPolicy(vnsSvcRedirectPolRn, parentDn, description string, vnsSvcRedirectPolattr ServiceRedirectPolicyAttributes) *ServiceRedirectPolicy {
dn := fmt.Sprintf("%s/%s", parentDn, vnsSvcRedirectPolRn)
return &ServiceRedirectPolicy{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: VnssvcredirectpolClassName,
Rn: vnsSvcRedirectPolRn,
},
ServiceRedirectPolicyAttributes: vnsSvcRedirectPolattr,
}
}
func (vnsSvcRedirectPol *ServiceRedirectPolicy) ToMap() (map[string]string, error) {
vnsSvcRedirectPolMap, err := vnsSvcRedirectPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(vnsSvcRedirectPolMap, "name", vnsSvcRedirectPol.Name)
A(vnsSvcRedirectPolMap, "AnycastEnabled", vnsSvcRedirectPol.AnycastEnabled)
A(vnsSvcRedirectPolMap, "annotation", vnsSvcRedirectPol.Annotation)
A(vnsSvcRedirectPolMap, "destType", vnsSvcRedirectPol.DestType)
A(vnsSvcRedirectPolMap, "hashingAlgorithm", vnsSvcRedirectPol.HashingAlgorithm)
A(vnsSvcRedirectPolMap, "maxThresholdPercent", vnsSvcRedirectPol.MaxThresholdPercent)
A(vnsSvcRedirectPolMap, "minThresholdPercent", vnsSvcRedirectPol.MinThresholdPercent)
A(vnsSvcRedirectPolMap, "nameAlias", vnsSvcRedirectPol.NameAlias)
A(vnsSvcRedirectPolMap, "programLocalPodOnly", vnsSvcRedirectPol.ProgramLocalPodOnly)
A(vnsSvcRedirectPolMap, "resilientHashEnabled", vnsSvcRedirectPol.ResilientHashEnabled)
A(vnsSvcRedirectPolMap, "thresholdDownAction", vnsSvcRedirectPol.ThresholdDownAction)
A(vnsSvcRedirectPolMap, "thresholdEnable", vnsSvcRedirectPol.ThresholdEnable)
return vnsSvcRedirectPolMap, err
}
func ServiceRedirectPolicyFromContainerList(cont *container.Container, index int) *ServiceRedirectPolicy {
ServiceRedirectPolicyCont := cont.S("imdata").Index(index).S(VnssvcredirectpolClassName, "attributes")
return &ServiceRedirectPolicy{
BaseAttributes{
DistinguishedName: G(ServiceRedirectPolicyCont, "dn"),
Description: G(ServiceRedirectPolicyCont, "descr"),
Status: G(ServiceRedirectPolicyCont, "status"),
ClassName: VnssvcredirectpolClassName,
Rn: G(ServiceRedirectPolicyCont, "rn"),
},
ServiceRedirectPolicyAttributes{
Name: G(ServiceRedirectPolicyCont, "name"),
AnycastEnabled: G(ServiceRedirectPolicyCont, "AnycastEnabled"),
Annotation: G(ServiceRedirectPolicyCont, "annotation"),
DestType: G(ServiceRedirectPolicyCont, "destType"),
HashingAlgorithm: G(ServiceRedirectPolicyCont, "hashingAlgorithm"),
MaxThresholdPercent: G(ServiceRedirectPolicyCont, "maxThresholdPercent"),
MinThresholdPercent: G(ServiceRedirectPolicyCont, "minThresholdPercent"),
NameAlias: G(ServiceRedirectPolicyCont, "nameAlias"),
ProgramLocalPodOnly: G(ServiceRedirectPolicyCont, "programLocalPodOnly"),
ResilientHashEnabled: G(ServiceRedirectPolicyCont, "resilientHashEnabled"),
ThresholdDownAction: G(ServiceRedirectPolicyCont, "thresholdDownAction"),
ThresholdEnable: G(ServiceRedirectPolicyCont, "thresholdEnable"),
},
}
}
func ServiceRedirectPolicyFromContainer(cont *container.Container) *ServiceRedirectPolicy {
return ServiceRedirectPolicyFromContainerList(cont, 0)
}
func ServiceRedirectPolicyListFromContainer(cont *container.Container) []*ServiceRedirectPolicy {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*ServiceRedirectPolicy, length)
for i := 0; i < length; i++ {
arr[i] = ServiceRedirectPolicyFromContainerList(cont, i)
}
return arr
}