-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new class object rtctrlMatchCommRegexTerm
- Loading branch information
1 parent
be66af5
commit 3362cf4
Showing
2 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ciscoecosystem/aci-go-client/models" | ||
) | ||
|
||
func (sm *ServiceManager) CreateMatchRuleBasedonCommunityRegularExpression(commType string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommRegexTermAttr models.MatchRuleBasedonCommunityRegularExpressionAttributes) (*models.MatchRuleBasedonCommunityRegularExpression, error) { | ||
rn := fmt.Sprintf(models.RnrtctrlMatchCommRegexTerm, commType) | ||
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommRegexTerm, tenant, match_rule) | ||
rtctrlMatchCommRegexTerm := models.NewMatchRuleBasedonCommunityRegularExpression(rn, parentDn, description, nameAlias, rtctrlMatchCommRegexTermAttr) | ||
err := sm.Save(rtctrlMatchCommRegexTerm) | ||
return rtctrlMatchCommRegexTerm, err | ||
} | ||
|
||
func (sm *ServiceManager) ReadMatchRuleBasedonCommunityRegularExpression(commType string, match_rule string, tenant string) (*models.MatchRuleBasedonCommunityRegularExpression, error) { | ||
dn := fmt.Sprintf(models.DnrtctrlMatchCommRegexTerm, tenant, match_rule, commType) | ||
|
||
cont, err := sm.Get(dn) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
rtctrlMatchCommRegexTerm := models.MatchRuleBasedonCommunityRegularExpressionFromContainer(cont) | ||
return rtctrlMatchCommRegexTerm, nil | ||
} | ||
|
||
func (sm *ServiceManager) DeleteMatchRuleBasedonCommunityRegularExpression(commType string, match_rule string, tenant string) error { | ||
dn := fmt.Sprintf(models.DnrtctrlMatchCommRegexTerm, tenant, match_rule, commType) | ||
return sm.DeleteByDn(dn, models.RtctrlmatchcommregextermClassName) | ||
} | ||
|
||
func (sm *ServiceManager) UpdateMatchRuleBasedonCommunityRegularExpression(commType string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommRegexTermAttr models.MatchRuleBasedonCommunityRegularExpressionAttributes) (*models.MatchRuleBasedonCommunityRegularExpression, error) { | ||
rn := fmt.Sprintf(models.RnrtctrlMatchCommRegexTerm, commType) | ||
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommRegexTerm, tenant, match_rule) | ||
rtctrlMatchCommRegexTerm := models.NewMatchRuleBasedonCommunityRegularExpression(rn, parentDn, description, nameAlias, rtctrlMatchCommRegexTermAttr) | ||
rtctrlMatchCommRegexTerm.Status = "modified" | ||
err := sm.Save(rtctrlMatchCommRegexTerm) | ||
return rtctrlMatchCommRegexTerm, err | ||
} | ||
|
||
func (sm *ServiceManager) ListMatchRuleBasedonCommunityRegularExpression(match_rule string, tenant string) ([]*models.MatchRuleBasedonCommunityRegularExpression, error) { | ||
dnUrl := fmt.Sprintf("%s/uni/tn-%s/subj-%s/rtctrlMatchCommRegexTerm.json", models.BaseurlStr, tenant, match_rule) | ||
cont, err := sm.GetViaURL(dnUrl) | ||
list := models.MatchRuleBasedonCommunityRegularExpressionListFromContainer(cont) | ||
return list, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/ciscoecosystem/aci-go-client/container" | ||
) | ||
|
||
const ( | ||
DnrtctrlMatchCommRegexTerm = "uni/tn-%s/subj-%s/commrxtrm-%s" | ||
RnrtctrlMatchCommRegexTerm = "commrxtrm-%s" | ||
ParentDnrtctrlMatchCommRegexTerm = "uni/tn-%s/subj-%s" | ||
RtctrlmatchcommregextermClassName = "rtctrlMatchCommRegexTerm" | ||
) | ||
|
||
type MatchRuleBasedonCommunityRegularExpression struct { | ||
BaseAttributes | ||
NameAliasAttribute | ||
MatchRuleBasedonCommunityRegularExpressionAttributes | ||
} | ||
|
||
type MatchRuleBasedonCommunityRegularExpressionAttributes struct { | ||
Annotation string `json:",omitempty"` | ||
CommType string `json:",omitempty"` | ||
Name string `json:",omitempty"` | ||
Regex string `json:",omitempty"` | ||
} | ||
|
||
func NewMatchRuleBasedonCommunityRegularExpression(rtctrlMatchCommRegexTermRn, parentDn, description, nameAlias string, rtctrlMatchCommRegexTermAttr MatchRuleBasedonCommunityRegularExpressionAttributes) *MatchRuleBasedonCommunityRegularExpression { | ||
dn := fmt.Sprintf("%s/%s", parentDn, rtctrlMatchCommRegexTermRn) | ||
return &MatchRuleBasedonCommunityRegularExpression{ | ||
BaseAttributes: BaseAttributes{ | ||
DistinguishedName: dn, | ||
Description: description, | ||
Status: "created, modified", | ||
ClassName: RtctrlmatchcommregextermClassName, | ||
Rn: rtctrlMatchCommRegexTermRn, | ||
}, | ||
NameAliasAttribute: NameAliasAttribute{ | ||
NameAlias: nameAlias, | ||
}, | ||
MatchRuleBasedonCommunityRegularExpressionAttributes: rtctrlMatchCommRegexTermAttr, | ||
} | ||
} | ||
|
||
func (rtctrlMatchCommRegexTerm *MatchRuleBasedonCommunityRegularExpression) ToMap() (map[string]string, error) { | ||
rtctrlMatchCommRegexTermMap, err := rtctrlMatchCommRegexTerm.BaseAttributes.ToMap() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
alias, err := rtctrlMatchCommRegexTerm.NameAliasAttribute.ToMap() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for key, value := range alias { | ||
A(rtctrlMatchCommRegexTermMap, key, value) | ||
} | ||
|
||
A(rtctrlMatchCommRegexTermMap, "annotation", rtctrlMatchCommRegexTerm.Annotation) | ||
A(rtctrlMatchCommRegexTermMap, "commType", rtctrlMatchCommRegexTerm.CommType) | ||
A(rtctrlMatchCommRegexTermMap, "name", rtctrlMatchCommRegexTerm.Name) | ||
A(rtctrlMatchCommRegexTermMap, "regex", rtctrlMatchCommRegexTerm.Regex) | ||
return rtctrlMatchCommRegexTermMap, err | ||
} | ||
|
||
func MatchRuleBasedonCommunityRegularExpressionFromContainerList(cont *container.Container, index int) *MatchRuleBasedonCommunityRegularExpression { | ||
MatchRuleBasedonCommunityRegularExpressionCont := cont.S("imdata").Index(index).S(RtctrlmatchcommregextermClassName, "attributes") | ||
return &MatchRuleBasedonCommunityRegularExpression{ | ||
BaseAttributes{ | ||
DistinguishedName: G(MatchRuleBasedonCommunityRegularExpressionCont, "dn"), | ||
Description: G(MatchRuleBasedonCommunityRegularExpressionCont, "descr"), | ||
Status: G(MatchRuleBasedonCommunityRegularExpressionCont, "status"), | ||
ClassName: RtctrlmatchcommregextermClassName, | ||
Rn: G(MatchRuleBasedonCommunityRegularExpressionCont, "rn"), | ||
}, | ||
NameAliasAttribute{ | ||
NameAlias: G(MatchRuleBasedonCommunityRegularExpressionCont, "nameAlias"), | ||
}, | ||
MatchRuleBasedonCommunityRegularExpressionAttributes{ | ||
Annotation: G(MatchRuleBasedonCommunityRegularExpressionCont, "annotation"), | ||
CommType: G(MatchRuleBasedonCommunityRegularExpressionCont, "commType"), | ||
Name: G(MatchRuleBasedonCommunityRegularExpressionCont, "name"), | ||
Regex: G(MatchRuleBasedonCommunityRegularExpressionCont, "regex"), | ||
}, | ||
} | ||
} | ||
|
||
func MatchRuleBasedonCommunityRegularExpressionFromContainer(cont *container.Container) *MatchRuleBasedonCommunityRegularExpression { | ||
return MatchRuleBasedonCommunityRegularExpressionFromContainerList(cont, 0) | ||
} | ||
|
||
func MatchRuleBasedonCommunityRegularExpressionListFromContainer(cont *container.Container) []*MatchRuleBasedonCommunityRegularExpression { | ||
length, _ := strconv.Atoi(G(cont, "totalCount")) | ||
arr := make([]*MatchRuleBasedonCommunityRegularExpression, length) | ||
|
||
for i := 0; i < length; i++ { | ||
arr[i] = MatchRuleBasedonCommunityRegularExpressionFromContainerList(cont, i) | ||
} | ||
|
||
return arr | ||
} |