-
Notifications
You must be signed in to change notification settings - Fork 29
/
fvEPSelector_service.go
46 lines (39 loc) · 2.64 KB
/
fvEPSelector_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) CreateEndpointSecurityGroupSelector(matchExpression string, endpoint_security_group string, application_profile string, tenant string, description string, nameAlias string, fvEPSelectorAttr models.EndpointSecurityGroupSelectorAttributes) (*models.EndpointSecurityGroupSelector, error) {
rn := fmt.Sprintf(models.RnfvEPSelector, matchExpression)
parentDn := fmt.Sprintf(models.ParentDnfvEPSelector, tenant, application_profile, endpoint_security_group)
fvEPSelector := models.NewEndpointSecurityGroupSelector(rn, parentDn, description, nameAlias, fvEPSelectorAttr)
err := sm.Save(fvEPSelector)
return fvEPSelector, err
}
func (sm *ServiceManager) ReadEndpointSecurityGroupSelector(matchExpression string, endpoint_security_group string, application_profile string, tenant string) (*models.EndpointSecurityGroupSelector, error) {
dn := fmt.Sprintf(models.DnfvEPSelector, tenant, application_profile, endpoint_security_group, matchExpression)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
fvEPSelector := models.EndpointSecurityGroupSelectorFromContainer(cont)
return fvEPSelector, nil
}
func (sm *ServiceManager) DeleteEndpointSecurityGroupSelector(matchExpression string, endpoint_security_group string, application_profile string, tenant string) error {
dn := fmt.Sprintf(models.DnfvEPSelector, tenant, application_profile, endpoint_security_group, matchExpression)
return sm.DeleteByDn(dn, models.FvepselectorClassName)
}
func (sm *ServiceManager) UpdateEndpointSecurityGroupSelector(matchExpression string, endpoint_security_group string, application_profile string, tenant string, description string, nameAlias string, fvEPSelectorAttr models.EndpointSecurityGroupSelectorAttributes) (*models.EndpointSecurityGroupSelector, error) {
rn := fmt.Sprintf(models.RnfvEPSelector, matchExpression)
parentDn := fmt.Sprintf(models.ParentDnfvEPSelector, tenant, application_profile, endpoint_security_group)
fvEPSelector := models.NewEndpointSecurityGroupSelector(rn, parentDn, description, nameAlias, fvEPSelectorAttr)
fvEPSelector.Status = "modified"
err := sm.Save(fvEPSelector)
return fvEPSelector, err
}
func (sm *ServiceManager) ListEndpointSecurityGroupSelector(endpoint_security_group string, application_profile string, tenant string) ([]*models.EndpointSecurityGroupSelector, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/ap-%s/esg-%s/fvEPSelector.json", models.BaseurlStr, tenant, application_profile, endpoint_security_group)
cont, err := sm.GetViaURL(dnUrl)
list := models.EndpointSecurityGroupSelectorListFromContainer(cont)
return list, err
}