-
Notifications
You must be signed in to change notification settings - Fork 30
/
edr_event_p.go
99 lines (89 loc) · 3.17 KB
/
edr_event_p.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const (
DnedrEventP = "uni/infra/edrErrDisRecoverPol-%s/edrEventP-%s"
RnedrEventP = "edrEventP-%s"
ParentDnedrEventP = "uni/infra/edrErrDisRecoverPol-%s"
EdreventpClassName = "edrEventP"
)
type ErrorDisabledRecoveryEvent struct {
BaseAttributes
NameAliasAttribute
ErrorDisabledRecoveryEventAttributes
}
type ErrorDisabledRecoveryEventAttributes struct {
Annotation string `json:",omitempty"`
Event string `json:",omitempty"`
Name string `json:",omitempty"`
Recover string `json:",omitempty"`
}
func NewErrorDisabledRecoveryEvent(edrEventPRn, parentDn, description, nameAlias string, edrEventPAttr ErrorDisabledRecoveryEventAttributes) *ErrorDisabledRecoveryEvent {
dn := fmt.Sprintf("%s/%s", parentDn, edrEventPRn)
return &ErrorDisabledRecoveryEvent{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: EdreventpClassName,
Rn: edrEventPRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
ErrorDisabledRecoveryEventAttributes: edrEventPAttr,
}
}
func (edrEventP *ErrorDisabledRecoveryEvent) ToMap() (map[string]string, error) {
edrEventPMap, err := edrEventP.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := edrEventP.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(edrEventPMap, key, value)
}
A(edrEventPMap, "annotation", edrEventP.Annotation)
A(edrEventPMap, "event", edrEventP.Event)
A(edrEventPMap, "name", edrEventP.Name)
A(edrEventPMap, "recover", edrEventP.Recover)
return edrEventPMap, err
}
func ErrorDisabledRecoveryEventFromContainerList(cont *container.Container, index int) *ErrorDisabledRecoveryEvent {
ErrorDisabledRecoveryEventCont := cont.S("imdata").Index(index).S(EdreventpClassName, "attributes")
return &ErrorDisabledRecoveryEvent{
BaseAttributes{
DistinguishedName: G(ErrorDisabledRecoveryEventCont, "dn"),
Description: G(ErrorDisabledRecoveryEventCont, "descr"),
Status: G(ErrorDisabledRecoveryEventCont, "status"),
ClassName: EdreventpClassName,
Rn: G(ErrorDisabledRecoveryEventCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(ErrorDisabledRecoveryEventCont, "nameAlias"),
},
ErrorDisabledRecoveryEventAttributes{
Annotation: G(ErrorDisabledRecoveryEventCont, "annotation"),
Event: G(ErrorDisabledRecoveryEventCont, "event"),
Name: G(ErrorDisabledRecoveryEventCont, "name"),
Recover: G(ErrorDisabledRecoveryEventCont, "recover"),
},
}
}
func ErrorDisabledRecoveryEventFromContainer(cont *container.Container) *ErrorDisabledRecoveryEvent {
return ErrorDisabledRecoveryEventFromContainerList(cont, 0)
}
func ErrorDisabledRecoveryEventListFromContainer(cont *container.Container) []*ErrorDisabledRecoveryEvent {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*ErrorDisabledRecoveryEvent, length)
for i := 0; i < length; i++ {
arr[i] = ErrorDisabledRecoveryEventFromContainerList(cont, i)
}
return arr
}