-
Notifications
You must be signed in to change notification settings - Fork 29
/
qosInstPol_service.go
46 lines (39 loc) · 1.7 KB
/
qosInstPol_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) CreateQOSInstancePolicy(name string, description string, nameAlias string, qosInstPolAttr models.QOSInstancePolicyAttributes) (*models.QOSInstancePolicy, error) {
rn := fmt.Sprintf(models.RnqosInstPol, name)
parentDn := fmt.Sprintf(models.ParentDnqosInstPol)
qosInstPol := models.NewQOSInstancePolicy(rn, parentDn, description, nameAlias, qosInstPolAttr)
err := sm.Save(qosInstPol)
return qosInstPol, err
}
func (sm *ServiceManager) ReadQOSInstancePolicy(name string) (*models.QOSInstancePolicy, error) {
dn := fmt.Sprintf(models.DnqosInstPol, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
qosInstPol := models.QOSInstancePolicyFromContainer(cont)
return qosInstPol, nil
}
func (sm *ServiceManager) DeleteQOSInstancePolicy(name string) error {
dn := fmt.Sprintf(models.DnqosInstPol, name)
return sm.DeleteByDn(dn, models.QosinstpolClassName)
}
func (sm *ServiceManager) UpdateQOSInstancePolicy(name string, description string, nameAlias string, qosInstPolAttr models.QOSInstancePolicyAttributes) (*models.QOSInstancePolicy, error) {
rn := fmt.Sprintf(models.RnqosInstPol, name)
parentDn := fmt.Sprintf(models.ParentDnqosInstPol)
qosInstPol := models.NewQOSInstancePolicy(rn, parentDn, description, nameAlias, qosInstPolAttr)
qosInstPol.Status = "modified"
err := sm.Save(qosInstPol)
return qosInstPol, err
}
func (sm *ServiceManager) ListQOSInstancePolicy() ([]*models.QOSInstancePolicy, error) {
dnUrl := fmt.Sprintf("%s/uni/infra/qosInstPol.json", models.BaseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.QOSInstancePolicyListFromContainer(cont)
return list, err
}