-
Notifications
You must be signed in to change notification settings - Fork 29
/
snmpCommunityP_service.go
46 lines (37 loc) · 1.72 KB
/
snmpCommunityP_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) CreateSNMPCommunity(name string, parent_dn string, description string, nameAlias string, snmpCommunityPAttr models.SNMPCommunityAttributes) (*models.SNMPCommunity, error) {
rn := fmt.Sprintf(models.RnsnmpCommunityP, name)
snmpCommunityP := models.NewSNMPCommunity(rn, parent_dn, description, nameAlias, snmpCommunityPAttr)
err := sm.Save(snmpCommunityP)
return snmpCommunityP, err
}
func (sm *ServiceManager) ReadSNMPCommunity(name string, parent_dn string) (*models.SNMPCommunity, error) {
dn := fmt.Sprintf(models.DnsnmpCommunityP, parent_dn, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
snmpCommunityP := models.SNMPCommunityFromContainer(cont)
return snmpCommunityP, nil
}
func (sm *ServiceManager) DeleteSNMPCommunity(name string, parent_dn string) error {
dn := fmt.Sprintf(models.DnsnmpCommunityP, parent_dn, name)
return sm.DeleteByDn(dn, models.SnmpcommunitypClassName)
}
func (sm *ServiceManager) UpdateSNMPCommunity(name string, parent_dn string, description string, nameAlias string, snmpCommunityPAttr models.SNMPCommunityAttributes) (*models.SNMPCommunity, error) {
rn := fmt.Sprintf(models.RnsnmpCommunityP, name)
snmpCommunityP := models.NewSNMPCommunity(rn, parent_dn, description, nameAlias, snmpCommunityPAttr)
snmpCommunityP.Status = "modified"
err := sm.Save(snmpCommunityP)
return snmpCommunityP, err
}
func (sm *ServiceManager) ListSNMPCommunity(parent_dn string) ([]*models.SNMPCommunity, error) {
dnUrl := fmt.Sprintf("%s/%s/snmpCommunityP.json", models.BaseurlStr, parent_dn)
cont, err := sm.GetViaURL(dnUrl)
list := models.SNMPCommunityListFromContainer(cont)
return list, err
}