-
Notifications
You must be signed in to change notification settings - Fork 29
/
snmpCtxP_service.go
46 lines (39 loc) · 1.73 KB
/
snmpCtxP_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) CreateSNMPContextProfile(vrf string, tenant string, nameAlias string, snmpCtxPAttr models.SNMPContextProfileAttributes) (*models.SNMPContextProfile, error) {
rn := fmt.Sprintf(models.RnsnmpCtxP)
parentDn := fmt.Sprintf(models.ParentDnsnmpCtxP, tenant, vrf)
snmpCtxP := models.NewSNMPContextProfile(rn, parentDn, nameAlias, snmpCtxPAttr)
err := sm.Save(snmpCtxP)
return snmpCtxP, err
}
func (sm *ServiceManager) ReadSNMPContextProfile(vrf string, tenant string) (*models.SNMPContextProfile, error) {
dn := fmt.Sprintf(models.DnsnmpCtxP, tenant, vrf)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
snmpCtxP := models.SNMPContextProfileFromContainer(cont)
return snmpCtxP, nil
}
func (sm *ServiceManager) DeleteSNMPContextProfile(vrf string, tenant string) error {
dn := fmt.Sprintf(models.DnsnmpCtxP, tenant, vrf)
return sm.DeleteByDn(dn, models.SnmpctxpClassName)
}
func (sm *ServiceManager) UpdateSNMPContextProfile(vrf string, tenant string, nameAlias string, snmpCtxPAttr models.SNMPContextProfileAttributes) (*models.SNMPContextProfile, error) {
rn := fmt.Sprintf(models.RnsnmpCtxP)
parentDn := fmt.Sprintf(models.ParentDnsnmpCtxP, tenant, vrf)
snmpCtxP := models.NewSNMPContextProfile(rn, parentDn, nameAlias, snmpCtxPAttr)
snmpCtxP.Status = "modified"
err := sm.Save(snmpCtxP)
return snmpCtxP, err
}
func (sm *ServiceManager) ListSNMPContextProfile(vrf string, tenant string) ([]*models.SNMPContextProfile, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/ctx-%s/snmpCtxP.json", models.BaseurlStr, tenant, vrf)
cont, err := sm.GetViaURL(dnUrl)
list := models.SNMPContextProfileListFromContainer(cont)
return list, err
}