-
Notifications
You must be signed in to change notification settings - Fork 29
/
fvTagSelector_service.go
46 lines (39 loc) · 2.77 KB
/
fvTagSelector_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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateEndpointSecurityGroupTagSelector(matchValue string, matchKey string, endpoint_security_group string, application_profile string, tenant string, description string, nameAlias string, fvTagSelectorAttr models.EndpointSecurityGroupTagSelectorAttributes) (*models.EndpointSecurityGroupTagSelector, error) {
rn := fmt.Sprintf(models.RnfvTagSelector, matchKey, matchValue)
parentDn := fmt.Sprintf(models.ParentDnfvTagSelector, tenant, application_profile, endpoint_security_group)
fvTagSelector := models.NewEndpointSecurityGroupTagSelector(rn, parentDn, description, nameAlias, fvTagSelectorAttr)
err := sm.Save(fvTagSelector)
return fvTagSelector, err
}
func (sm *ServiceManager) ReadEndpointSecurityGroupTagSelector(matchValue string, matchKey string, endpoint_security_group string, application_profile string, tenant string) (*models.EndpointSecurityGroupTagSelector, error) {
dn := fmt.Sprintf(models.DnfvTagSelector, tenant, application_profile, endpoint_security_group, matchKey, matchValue)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
fvTagSelector := models.EndpointSecurityGroupTagSelectorFromContainer(cont)
return fvTagSelector, nil
}
func (sm *ServiceManager) DeleteEndpointSecurityGroupTagSelector(matchValue string, matchKey string, endpoint_security_group string, application_profile string, tenant string) error {
dn := fmt.Sprintf(models.DnfvTagSelector, tenant, application_profile, endpoint_security_group, matchKey, matchValue)
return sm.DeleteByDn(dn, models.FvtagselectorClassName)
}
func (sm *ServiceManager) UpdateEndpointSecurityGroupTagSelector(matchValue string, matchKey string, endpoint_security_group string, application_profile string, tenant string, description string, nameAlias string, fvTagSelectorAttr models.EndpointSecurityGroupTagSelectorAttributes) (*models.EndpointSecurityGroupTagSelector, error) {
rn := fmt.Sprintf(models.RnfvTagSelector, matchKey, matchValue)
parentDn := fmt.Sprintf(models.ParentDnfvTagSelector, tenant, application_profile, endpoint_security_group)
fvTagSelector := models.NewEndpointSecurityGroupTagSelector(rn, parentDn, description, nameAlias, fvTagSelectorAttr)
fvTagSelector.Status = "modified"
err := sm.Save(fvTagSelector)
return fvTagSelector, err
}
func (sm *ServiceManager) ListEndpointSecurityGroupTagSelector(endpoint_security_group string, application_profile string, tenant string) ([]*models.EndpointSecurityGroupTagSelector, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/ap-%s/esg-%s/fvTagSelector.json", models.BaseurlStr, tenant, application_profile, endpoint_security_group)
cont, err := sm.GetViaURL(dnUrl)
list := models.EndpointSecurityGroupTagSelectorListFromContainer(cont)
return list, err
}