-
Notifications
You must be signed in to change notification settings - Fork 29
/
rtctrlMatchCommFactor_service.go
59 lines (46 loc) · 2.93 KB
/
rtctrlMatchCommFactor_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
49
50
51
52
53
54
55
56
57
58
59
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateMatchCommunityFactor(community string, match_community_term string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommFactorAttr models.MatchCommunityFactorAttributes) (*models.MatchCommunityFactor, error) {
rn := fmt.Sprintf(models.RnrtctrlMatchCommFactor, community)
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommFactor, tenant, match_rule, match_community_term)
rtctrlMatchCommFactor := models.NewMatchCommunityFactor(rn, parentDn, description, nameAlias, rtctrlMatchCommFactorAttr)
err := sm.Save(rtctrlMatchCommFactor)
return rtctrlMatchCommFactor, err
}
func (sm *ServiceManager) ReadMatchCommunityFactor(community string, match_community_term string, match_rule string, tenant string) (*models.MatchCommunityFactor, error) {
dn := fmt.Sprintf(models.DnrtctrlMatchCommFactor, tenant, match_rule, match_community_term, community)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
rtctrlMatchCommFactor := models.MatchCommunityFactorFromContainer(cont)
return rtctrlMatchCommFactor, nil
}
func (sm *ServiceManager) DeleteMatchCommunityFactor(community string, match_community_term string, match_rule string, tenant string) error {
dn := fmt.Sprintf(models.DnrtctrlMatchCommFactor, tenant, match_rule, match_community_term, community)
return sm.DeleteByDn(dn, models.RtctrlmatchcommfactorClassName)
}
func (sm *ServiceManager) UpdateMatchCommunityFactor(community string, match_community_term string, match_rule string, tenant string, description string, nameAlias string, rtctrlMatchCommFactorAttr models.MatchCommunityFactorAttributes) (*models.MatchCommunityFactor, error) {
rn := fmt.Sprintf(models.RnrtctrlMatchCommFactor, community)
parentDn := fmt.Sprintf(models.ParentDnrtctrlMatchCommFactor, tenant, match_rule, match_community_term)
rtctrlMatchCommFactor := models.NewMatchCommunityFactor(rn, parentDn, description, nameAlias, rtctrlMatchCommFactorAttr)
rtctrlMatchCommFactor.Status = "modified"
err := sm.Save(rtctrlMatchCommFactor)
return rtctrlMatchCommFactor, err
}
func (sm *ServiceManager) ListMatchCommunityFactor(match_community_term string, match_rule string, tenant string) ([]*models.MatchCommunityFactor, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/subj-%s/commtrm-%s/rtctrlMatchCommFactor.json", models.BaseurlStr, tenant, match_rule, match_community_term)
cont, err := sm.GetViaURL(dnUrl)
list := models.MatchCommunityFactorListFromContainer(cont)
return list, err
}
func (sm *ServiceManager) ListMatchCommFactorsFromCommunityTerm(parentDn string) ([]*models.MatchCommunityFactor, error) {
baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/%s/%s.json", baseurlStr, parentDn, "rtctrlMatchCommFactor")
cont, err := sm.GetViaURL(dnUrl)
rtctrlMatchCommFactorsData := models.MatchCommunityFactorListFromContainer(cont)
return rtctrlMatchCommFactorsData, err
}