-
Notifications
You must be signed in to change notification settings - Fork 29
/
epIpAgingP_service.go
46 lines (39 loc) · 1.64 KB
/
epIpAgingP_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) CreateIPAgingPolicy(name string, description string, nameAlias string, epIpAgingPAttr models.IPAgingPolicyAttributes) (*models.IPAgingPolicy, error) {
rn := fmt.Sprintf(models.RnepIpAgingP, name)
parentDn := fmt.Sprintf(models.ParentDnepIpAgingP)
epIpAgingP := models.NewIPAgingPolicy(rn, parentDn, description, nameAlias, epIpAgingPAttr)
err := sm.Save(epIpAgingP)
return epIpAgingP, err
}
func (sm *ServiceManager) ReadIPAgingPolicy(name string) (*models.IPAgingPolicy, error) {
dn := fmt.Sprintf(models.DnepIpAgingP, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
epIpAgingP := models.IPAgingPolicyFromContainer(cont)
return epIpAgingP, nil
}
func (sm *ServiceManager) DeleteIPAgingPolicy(name string) error {
dn := fmt.Sprintf(models.DnepIpAgingP, name)
return sm.DeleteByDn(dn, models.EpipagingpClassName)
}
func (sm *ServiceManager) UpdateIPAgingPolicy(name string, description string, nameAlias string, epIpAgingPAttr models.IPAgingPolicyAttributes) (*models.IPAgingPolicy, error) {
rn := fmt.Sprintf(models.RnepIpAgingP, name)
parentDn := fmt.Sprintf(models.ParentDnepIpAgingP)
epIpAgingP := models.NewIPAgingPolicy(rn, parentDn, description, nameAlias, epIpAgingPAttr)
epIpAgingP.Status = "modified"
err := sm.Save(epIpAgingP)
return epIpAgingP, err
}
func (sm *ServiceManager) ListIPAgingPolicy() ([]*models.IPAgingPolicy, error) {
dnUrl := fmt.Sprintf("%s/uni/infra/epIpAgingP.json", models.BaseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.IPAgingPolicyListFromContainer(cont)
return list, err
}