-
Notifications
You must be signed in to change notification settings - Fork 29
/
fv_rs_ctx_to_bgp_ctx_af_pol.go
86 lines (73 loc) · 3.47 KB
/
fv_rs_ctx_to_bgp_ctx_af_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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
DnfvRsCtxToBgpCtxAfPol = "uni/tn-%s/ctx-%s/rsctxToBgpCtxAfPol-[%s]-%s"
RnfvRsCtxToBgpCtxAfPol = "rsctxToBgpCtxAfPol-[%s]-%s"
ParentDnfvRsCtxToBgpCtxAfPol = "uni/tn-%s/ctx-%s"
FvrsctxtobgpctxafpolClassName = "fvRsCtxToBgpCtxAfPol"
)
type BGPAddressFamilyContextPolicyRelationship struct {
BaseAttributes
BGPAddressFamilyContextPolicyRelationshipAttributes
}
type BGPAddressFamilyContextPolicyRelationshipAttributes struct {
Annotation string `json:",omitempty"`
Af string `json:",omitempty"`
TnBgpCtxAfPolName string `json:",omitempty"`
TDn string `json:",omitempty"`
}
func NewBGPAddressFamilyContextPolicyRelationship(fvRsCtxToBgpCtxAfPolRn, parentDn string, fvRsCtxToBgpCtxAfPolAttr BGPAddressFamilyContextPolicyRelationshipAttributes) *BGPAddressFamilyContextPolicyRelationship {
dn := fmt.Sprintf("%s/%s", parentDn, fvRsCtxToBgpCtxAfPolRn)
return &BGPAddressFamilyContextPolicyRelationship{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Status: "created, modified",
ClassName: FvrsctxtobgpctxafpolClassName,
Rn: fvRsCtxToBgpCtxAfPolRn,
},
BGPAddressFamilyContextPolicyRelationshipAttributes: fvRsCtxToBgpCtxAfPolAttr,
}
}
func (fvRsCtxToBgpCtxAfPol *BGPAddressFamilyContextPolicyRelationship) ToMap() (map[string]string, error) {
fvRsCtxToBgpCtxAfPolMap, err := fvRsCtxToBgpCtxAfPol.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fvRsCtxToBgpCtxAfPolMap, "af", fvRsCtxToBgpCtxAfPol.Af)
A(fvRsCtxToBgpCtxAfPolMap, "annotation", fvRsCtxToBgpCtxAfPol.Annotation)
A(fvRsCtxToBgpCtxAfPolMap, "tnBgpCtxAfPolName", fvRsCtxToBgpCtxAfPol.TnBgpCtxAfPolName)
A(fvRsCtxToBgpCtxAfPolMap, "tDn", fvRsCtxToBgpCtxAfPol.TDn)
return fvRsCtxToBgpCtxAfPolMap, err
}
func BGPAddressFamilyContextPolicyRelationshipFromContainerList(cont *container.Container, index int) *BGPAddressFamilyContextPolicyRelationship {
BGPAddressFamilyContextPolicyRelationshipCont := cont.S("imdata").Index(index).S(FvrsctxtobgpctxafpolClassName, "attributes")
return &BGPAddressFamilyContextPolicyRelationship{
BaseAttributes{
DistinguishedName: G(BGPAddressFamilyContextPolicyRelationshipCont, "dn"),
Status: G(BGPAddressFamilyContextPolicyRelationshipCont, "status"),
ClassName: FvrsctxtobgpctxafpolClassName,
Rn: G(BGPAddressFamilyContextPolicyRelationshipCont, "rn"),
},
BGPAddressFamilyContextPolicyRelationshipAttributes{
Af: G(BGPAddressFamilyContextPolicyRelationshipCont, "af"),
Annotation: G(BGPAddressFamilyContextPolicyRelationshipCont, "annotation"),
TnBgpCtxAfPolName: G(BGPAddressFamilyContextPolicyRelationshipCont, "tnBgpCtxAfPolName"),
TDn: G(BGPAddressFamilyContextPolicyRelationshipCont, "tDn"),
},
}
}
func BGPAddressFamilyContextPolicyRelationshipFromContainer(cont *container.Container) *BGPAddressFamilyContextPolicyRelationship {
return BGPAddressFamilyContextPolicyRelationshipFromContainerList(cont, 0)
}
func BGPAddressFamilyContextPolicyRelationshipListFromContainer(cont *container.Container) []*BGPAddressFamilyContextPolicyRelationship {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*BGPAddressFamilyContextPolicyRelationship, length)
for i := 0; i < length; i++ {
arr[i] = BGPAddressFamilyContextPolicyRelationshipFromContainerList(cont, i)
}
return arr
}