-
Notifications
You must be signed in to change notification settings - Fork 30
/
rtctrlMatchCommTerm_service.go
48 lines (39 loc) · 2.17 KB
/
rtctrlMatchCommTerm_service.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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateMatchCommunityTerm(name string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommTermAttr models.MatchCommunityTermAttributes) (*models.MatchCommunityTerm, error) {
rn := fmt.Sprintf(models.RnrtctrlMatchCommTerm, name)
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommTerm, tenant, match_rule)
rtctrlMatchCommTerm := models.NewMatchCommunityTerm(rn, parentDn, description, nameAlias, rtctrlMatchCommTermAttr)
err := sm.Save(rtctrlMatchCommTerm)
return rtctrlMatchCommTerm, err
}
func (sm *ServiceManager) ReadMatchCommunityTerm(name string, match_rule string, tenant string) (*models.MatchCommunityTerm, error) {
dn := fmt.Sprintf(models.DnrtctrlMatchCommTerm, tenant, match_rule, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
rtctrlMatchCommTerm := models.MatchCommunityTermFromContainer(cont)
return rtctrlMatchCommTerm, nil
}
func (sm *ServiceManager) DeleteMatchCommunityTerm(name string, match_rule string, tenant string) error {
dn := fmt.Sprintf(models.DnrtctrlMatchCommTerm, tenant, match_rule, name)
return sm.DeleteByDn(dn, models.RtctrlmatchcommtermClassName)
}
func (sm *ServiceManager) UpdateMatchCommunityTerm(name string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommTermAttr models.MatchCommunityTermAttributes) (*models.MatchCommunityTerm, error) {
rn := fmt.Sprintf(models.RnrtctrlMatchCommTerm, name)
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommTerm, tenant, match_rule)
rtctrlMatchCommTerm := models.NewMatchCommunityTerm(rn, parentDn, description, nameAlias, rtctrlMatchCommTermAttr)
rtctrlMatchCommTerm.Status = "modified"
err := sm.Save(rtctrlMatchCommTerm)
return rtctrlMatchCommTerm, err
}
func (sm *ServiceManager) ListMatchCommunityTerm(match_rule string, tenant string) ([]*models.MatchCommunityTerm, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/subj-%s/rtctrlMatchCommTerm.json", models.BaseurlStr, tenant, match_rule)
cont, err := sm.GetViaURL(dnUrl)
list := models.MatchCommunityTermListFromContainer(cont)
return list, err
}