-
Notifications
You must be signed in to change notification settings - Fork 29
/
aaa_domain_auth.go
102 lines (92 loc) · 3.65 KB
/
aaa_domain_auth.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
package models
import (
"fmt"
"strconv"
"github.com/ciscoecosystem/aci-go-client/container"
)
const (
DnaaaDomainAuth = "uni/userext/logindomain-%s/domainauth"
RnaaaDomainAuth = "domainauth"
ParentDnaaaDomainAuth = "uni/userext/logindomain-%s"
AaadomainauthClassName = "aaaDomainAuth"
)
type AuthenticationMethodfortheDomain struct {
BaseAttributes
NameAliasAttribute
AuthenticationMethodfortheDomainAttributes
}
type AuthenticationMethodfortheDomainAttributes struct {
Annotation string `json:",omitempty"`
ProviderGroup string `json:",omitempty"`
Realm string `json:",omitempty"`
RealmSubType string `json:",omitempty"`
Name string `json:",omitempty"`
}
func NewAuthenticationMethodfortheDomain(aaaDomainAuthRn, parentDn, description, nameAlias string, aaaDomainAuthAttr AuthenticationMethodfortheDomainAttributes) *AuthenticationMethodfortheDomain {
dn := fmt.Sprintf("%s/%s", parentDn, aaaDomainAuthRn)
return &AuthenticationMethodfortheDomain{
BaseAttributes: BaseAttributes{
DistinguishedName: dn,
Description: description,
Status: "created, modified",
ClassName: AaadomainauthClassName,
Rn: aaaDomainAuthRn,
},
NameAliasAttribute: NameAliasAttribute{
NameAlias: nameAlias,
},
AuthenticationMethodfortheDomainAttributes: aaaDomainAuthAttr,
}
}
func (aaaDomainAuth *AuthenticationMethodfortheDomain) ToMap() (map[string]string, error) {
aaaDomainAuthMap, err := aaaDomainAuth.BaseAttributes.ToMap()
if err != nil {
return nil, err
}
alias, err := aaaDomainAuth.NameAliasAttribute.ToMap()
if err != nil {
return nil, err
}
for key, value := range alias {
A(aaaDomainAuthMap, key, value)
}
A(aaaDomainAuthMap, "annotation", aaaDomainAuth.Annotation)
A(aaaDomainAuthMap, "providerGroup", aaaDomainAuth.ProviderGroup)
A(aaaDomainAuthMap, "realm", aaaDomainAuth.Realm)
A(aaaDomainAuthMap, "name", aaaDomainAuth.Name)
A(aaaDomainAuthMap, "realmSubType", aaaDomainAuth.RealmSubType)
return aaaDomainAuthMap, err
}
func AuthenticationMethodfortheDomainFromContainerList(cont *container.Container, index int) *AuthenticationMethodfortheDomain {
AuthenticationMethodfortheDomainCont := cont.S("imdata").Index(index).S(AaadomainauthClassName, "attributes")
return &AuthenticationMethodfortheDomain{
BaseAttributes{
DistinguishedName: G(AuthenticationMethodfortheDomainCont, "dn"),
Description: G(AuthenticationMethodfortheDomainCont, "descr"),
Status: G(AuthenticationMethodfortheDomainCont, "status"),
ClassName: AaadomainauthClassName,
Rn: G(AuthenticationMethodfortheDomainCont, "rn"),
},
NameAliasAttribute{
NameAlias: G(AuthenticationMethodfortheDomainCont, "nameAlias"),
},
AuthenticationMethodfortheDomainAttributes{
Annotation: G(AuthenticationMethodfortheDomainCont, "annotation"),
ProviderGroup: G(AuthenticationMethodfortheDomainCont, "providerGroup"),
Realm: G(AuthenticationMethodfortheDomainCont, "realm"),
RealmSubType: G(AuthenticationMethodfortheDomainCont, "realmSubType"),
Name: G(AuthenticationMethodfortheDomainCont, "name"),
},
}
}
func AuthenticationMethodfortheDomainFromContainer(cont *container.Container) *AuthenticationMethodfortheDomain {
return AuthenticationMethodfortheDomainFromContainerList(cont, 0)
}
func AuthenticationMethodfortheDomainListFromContainer(cont *container.Container) []*AuthenticationMethodfortheDomain {
length, _ := strconv.Atoi(G(cont, "totalCount"))
arr := make([]*AuthenticationMethodfortheDomain, length)
for i := 0; i < length; i++ {
arr[i] = AuthenticationMethodfortheDomainFromContainerList(cont, i)
}
return arr
}