-
Notifications
You must be signed in to change notification settings - Fork 29
/
cloudtemplate_ip_sec_tunnel_subnet_pool.go
83 lines (70 loc) · 3.14 KB
/
cloudtemplate_ip_sec_tunnel_subnet_pool.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/v2/container"
)
const (
DncloudtemplateIpSecTunnelSubnetPool = "uni/tn-%s/infranetwork-%s/ipsecsubnetpool-[%s]"
RncloudtemplateIpSecTunnelSubnetPool = "ipsecsubnetpool-[%s]"
ParentDncloudtemplateIpSecTunnelSubnetPool = "uni/tn-%s/infranetwork-%s"
CloudtemplateipsectunnelsubnetpoolClassName = "cloudtemplateIpSecTunnelSubnetPool"
)
type SubnetPoolforIpSecTunnels struct {
BaseAttributes
SubnetPoolforIpSecTunnelsAttributes
}
type SubnetPoolforIpSecTunnelsAttributes struct {
Annotation string `json:",omitempty"`
Poolname string `json:",omitempty"`
Subnetpool string `json:",omitempty"`
}
func NewSubnetPoolforIpSecTunnels(cloudtemplateIpSecTunnelSubnetPoolRn, parentDn string, cloudtemplateIpSecTunnelSubnetPoolAttr SubnetPoolforIpSecTunnelsAttributes) *SubnetPoolforIpSecTunnels {
dn := fmt.Sprintf("%s/%s", parentDn, cloudtemplateIpSecTunnelSubnetPoolRn)
return &SubnetPoolforIpSecTunnels{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Status: "created, modified",
ClassName: CloudtemplateipsectunnelsubnetpoolClassName,
Rn: cloudtemplateIpSecTunnelSubnetPoolRn,
},
SubnetPoolforIpSecTunnelsAttributes: cloudtemplateIpSecTunnelSubnetPoolAttr,
}
}
func (cloudtemplateIpSecTunnelSubnetPool *SubnetPoolforIpSecTunnels) ToMap() (map[string]string, error) {
cloudtemplateIpSecTunnelSubnetPoolMap, err := cloudtemplateIpSecTunnelSubnetPool.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(cloudtemplateIpSecTunnelSubnetPoolMap, "annotation", cloudtemplateIpSecTunnelSubnetPool.Annotation)
A(cloudtemplateIpSecTunnelSubnetPoolMap, "poolname", cloudtemplateIpSecTunnelSubnetPool.Poolname)
A(cloudtemplateIpSecTunnelSubnetPoolMap, "subnetpool", cloudtemplateIpSecTunnelSubnetPool.Subnetpool)
return cloudtemplateIpSecTunnelSubnetPoolMap, err
}
func SubnetPoolforIpSecTunnelsFromContainerList(cont *container.Container, index int) *SubnetPoolforIpSecTunnels {
SubnetPoolforIpSecTunnelsCont := cont.S("imdata").Index(index).S(CloudtemplateipsectunnelsubnetpoolClassName, "attributes")
return &SubnetPoolforIpSecTunnels{
BaseAttributes{
DistinguishedName: G(SubnetPoolforIpSecTunnelsCont, "dn"),
Status: G(SubnetPoolforIpSecTunnelsCont, "status"),
ClassName: CloudtemplateipsectunnelsubnetpoolClassName,
Rn: G(SubnetPoolforIpSecTunnelsCont, "rn"),
},
SubnetPoolforIpSecTunnelsAttributes{
Annotation: G(SubnetPoolforIpSecTunnelsCont, "annotation"),
Poolname: G(SubnetPoolforIpSecTunnelsCont, "poolname"),
Subnetpool: G(SubnetPoolforIpSecTunnelsCont, "subnetpool"),
},
}
}
func SubnetPoolforIpSecTunnelsFromContainer(cont *container.Container) *SubnetPoolforIpSecTunnels {
return SubnetPoolforIpSecTunnelsFromContainerList(cont, 0)
}
func SubnetPoolforIpSecTunnelsListFromContainer(cont *container.Container) []*SubnetPoolforIpSecTunnels {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*SubnetPoolforIpSecTunnels, length)
for i := 0; i < length; i++ {
arr[i] = SubnetPoolforIpSecTunnelsFromContainerList(cont, i)
}
return arr
}