-
Notifications
You must be signed in to change notification settings - Fork 29
/
epControlP_service.go
46 lines (39 loc) · 1.75 KB
/
epControlP_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) CreateEndpointControlPolicy(name string, description string, nameAlias string, epControlPAttr models.EndpointControlPolicyAttributes) (*models.EndpointControlPolicy, error) {
rn := fmt.Sprintf(models.RnepControlP, name)
parentDn := fmt.Sprintf(models.ParentDnepControlP)
epControlP := models.NewEndpointControlPolicy(rn, parentDn, description, nameAlias, epControlPAttr)
err := sm.Save(epControlP)
return epControlP, err
}
func (sm *ServiceManager) ReadEndpointControlPolicy(name string) (*models.EndpointControlPolicy, error) {
dn := fmt.Sprintf(models.DnepControlP, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
epControlP := models.EndpointControlPolicyFromContainer(cont)
return epControlP, nil
}
func (sm *ServiceManager) DeleteEndpointControlPolicy(name string) error {
dn := fmt.Sprintf(models.DnepControlP, name)
return sm.DeleteByDn(dn, models.EpcontrolpClassName)
}
func (sm *ServiceManager) UpdateEndpointControlPolicy(name string, description string, nameAlias string, epControlPAttr models.EndpointControlPolicyAttributes) (*models.EndpointControlPolicy, error) {
rn := fmt.Sprintf(models.RnepControlP, name)
parentDn := fmt.Sprintf(models.ParentDnepControlP)
epControlP := models.NewEndpointControlPolicy(rn, parentDn, description, nameAlias, epControlPAttr)
epControlP.Status = "modified"
err := sm.Save(epControlP)
return epControlP, err
}
func (sm *ServiceManager) ListEndpointControlPolicy() ([]*models.EndpointControlPolicy, error) {
dnUrl := fmt.Sprintf("%s/uni/infra/epControlP.json", models.BaseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.EndpointControlPolicyListFromContainer(cont)
return list, err
}