-
Notifications
You must be signed in to change notification settings - Fork 29
/
tacacsTacacsDest_service.go
46 lines (39 loc) · 2.3 KB
/
tacacsTacacsDest_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) CreateTACACSDestination(port string, host string, tacacs_monitoring_destination_group string, description string, nameAlias string, tacacsTacacsDestAttr models.TACACSDestinationAttributes) (*models.TACACSDestination, error) {
rn := fmt.Sprintf(models.RntacacsTacacsDest, host, port)
parentDn := fmt.Sprintf(models.ParentDntacacsTacacsDest, tacacs_monitoring_destination_group)
tacacsTacacsDest := models.NewTACACSDestination(rn, parentDn, description, nameAlias, tacacsTacacsDestAttr)
err := sm.Save(tacacsTacacsDest)
return tacacsTacacsDest, err
}
func (sm *ServiceManager) ReadTACACSDestination(port string, host string, tacacs_monitoring_destination_group string) (*models.TACACSDestination, error) {
dn := fmt.Sprintf(models.DntacacsTacacsDest, tacacs_monitoring_destination_group, host, port)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
tacacsTacacsDest := models.TACACSDestinationFromContainer(cont)
return tacacsTacacsDest, nil
}
func (sm *ServiceManager) DeleteTACACSDestination(port string, host string, tacacs_monitoring_destination_group string) error {
dn := fmt.Sprintf(models.DntacacsTacacsDest, tacacs_monitoring_destination_group, host, port)
return sm.DeleteByDn(dn, models.TacacstacacsdestClassName)
}
func (sm *ServiceManager) UpdateTACACSDestination(port string, host string, tacacs_monitoring_destination_group string, description string, nameAlias string, tacacsTacacsDestAttr models.TACACSDestinationAttributes) (*models.TACACSDestination, error) {
rn := fmt.Sprintf(models.RntacacsTacacsDest, host, port)
parentDn := fmt.Sprintf(models.ParentDntacacsTacacsDest, tacacs_monitoring_destination_group)
tacacsTacacsDest := models.NewTACACSDestination(rn, parentDn, description, nameAlias, tacacsTacacsDestAttr)
tacacsTacacsDest.Status = "modified"
err := sm.Save(tacacsTacacsDest)
return tacacsTacacsDest, err
}
func (sm *ServiceManager) ListTACACSDestination(tacacs_monitoring_destination_group string) ([]*models.TACACSDestination, error) {
dnUrl := fmt.Sprintf("%s/uni/fabric/tacacsgroup-%s/tacacsTacacsDest.json", models.BaseurlStr, tacacs_monitoring_destination_group)
cont, err := sm.GetViaURL(dnUrl)
list := models.TACACSDestinationListFromContainer(cont)
return list, err
}