-
Notifications
You must be signed in to change notification settings - Fork 30
/
fabric_path_ep.go
81 lines (61 loc) · 2.07 KB
/
fabric_path_ep.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const FabricpathepClassName = "fabricPathEp"
type FabricPathEndpoint struct {
BaseAttributes
FabricPathEndpointAttributes
}
type FabricPathEndpointAttributes struct {
Name string `json:",omitempty"`
}
func NewFabricPathEndpoint(fabricPathEpRn, parentDn, description string, fabricPathEpattr FabricPathEndpointAttributes) *FabricPathEndpoint {
dn := fmt.Sprintf("%s/%s", parentDn, fabricPathEpRn)
return &FabricPathEndpoint{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: FabricpathepClassName,
Rn: fabricPathEpRn,
},
FabricPathEndpointAttributes: fabricPathEpattr,
}
}
func (fabricPathEp *FabricPathEndpoint) ToMap() (map[string]string, error) {
fabricPathEpMap, err := fabricPathEp.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
A(fabricPathEpMap, "name", fabricPathEp.Name)
return fabricPathEpMap, err
}
func FabricPathEndpointFromContainerList(cont *container.Container, index int) *FabricPathEndpoint {
FabricPathEndpointCont := cont.S("imdata").Index(index).S(FabricpathepClassName, "attributes")
return &FabricPathEndpoint{
BaseAttributes{
DistinguishedName: G(FabricPathEndpointCont, "dn"),
Description: G(FabricPathEndpointCont, "descr"),
Status: G(FabricPathEndpointCont, "status"),
ClassName: FabricpathepClassName,
Rn: G(FabricPathEndpointCont, "rn"),
},
FabricPathEndpointAttributes{
Name: G(FabricPathEndpointCont, "name"),
},
}
}
func FabricPathEndpointFromContainer(cont *container.Container) *FabricPathEndpoint {
return FabricPathEndpointFromContainerList(cont, 0)
}
func FabricPathEndpointListFromContainer(cont *container.Container) []*FabricPathEndpoint {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*FabricPathEndpoint, length)
for i := 0; i < length; i++ {
arr[i] = FabricPathEndpointFromContainerList(cont, i)
}
return arr
}