-
Notifications
You must be signed in to change notification settings - Fork 29
/
infraPortTrackPol_service.go
52 lines (39 loc) · 1.79 KB
/
infraPortTrackPol_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
47
48
49
50
51
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreatePortTracking(name string, description string, nameAlias string, infraPortTrackPolAttr models.PortTrackingAttributes) (*models.PortTracking, error) {
rn := fmt.Sprintf(models.RninfraPortTrackPol , name)
parentDn := fmt.Sprintf(models.ParentDninfraPortTrackPol, )
infraPortTrackPol := models.NewPortTracking(rn, parentDn, description, nameAlias, infraPortTrackPolAttr)
err := sm.Save(infraPortTrackPol)
return infraPortTrackPol, err
}
func (sm *ServiceManager) ReadPortTracking(name string, ) (*models.PortTracking, error) {
dn := fmt.Sprintf(models.DninfraPortTrackPol, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
infraPortTrackPol := models.PortTrackingFromContainer(cont)
return infraPortTrackPol, nil
}
func (sm *ServiceManager) DeletePortTracking(name string, ) error {
dn := fmt.Sprintf(models.DninfraPortTrackPol, name)
return sm.DeleteByDn(dn, models.InfraporttrackpolClassName)
}
func (sm *ServiceManager) UpdatePortTracking(name string, description string, nameAlias string, infraPortTrackPolAttr models.PortTrackingAttributes) (*models.PortTracking, error) {
rn := fmt.Sprintf(models.RninfraPortTrackPol , name)
parentDn := fmt.Sprintf(models.ParentDninfraPortTrackPol, )
infraPortTrackPol := models.NewPortTracking(rn, parentDn, description, nameAlias, infraPortTrackPolAttr)
infraPortTrackPol.Status = "modified"
err := sm.Save(infraPortTrackPol)
return infraPortTrackPol, err
}
func (sm *ServiceManager) ListPortTracking() ([]*models.PortTracking, error) {
dnUrl := fmt.Sprintf("%s/uni/infra/infraPortTrackPol.json", models.BaseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.PortTrackingListFromContainer(cont)
return list, err
}