-
Notifications
You must be signed in to change notification settings - Fork 29
/
trigRecurrWindowP_service.go
46 lines (39 loc) · 1.9 KB
/
trigRecurrWindowP_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) CreateRecurringWindow(name string, scheduler string, nameAlias string, trigRecurrWindowPAttr models.RecurringWindowAttributes) (*models.RecurringWindow, error) {
rn := fmt.Sprintf(models.RntrigRecurrWindowP, name)
parentDn := fmt.Sprintf(models.ParentDntrigRecurrWindowP, scheduler)
trigRecurrWindowP := models.NewRecurringWindow(rn, parentDn, nameAlias, trigRecurrWindowPAttr)
err := sm.Save(trigRecurrWindowP)
return trigRecurrWindowP, err
}
func (sm *ServiceManager) ReadRecurringWindow(name string, scheduler string) (*models.RecurringWindow, error) {
dn := fmt.Sprintf(models.DntrigRecurrWindowP, scheduler, name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
trigRecurrWindowP := models.RecurringWindowFromContainer(cont)
return trigRecurrWindowP, nil
}
func (sm *ServiceManager) DeleteRecurringWindow(name string, scheduler string) error {
dn := fmt.Sprintf(models.DntrigRecurrWindowP, scheduler, name)
return sm.DeleteByDn(dn, models.TrigrecurrwindowpClassName)
}
func (sm *ServiceManager) UpdateRecurringWindow(name string, scheduler string, nameAlias string, trigRecurrWindowPAttr models.RecurringWindowAttributes) (*models.RecurringWindow, error) {
rn := fmt.Sprintf(models.RntrigRecurrWindowP, name)
parentDn := fmt.Sprintf(models.ParentDntrigRecurrWindowP, scheduler)
trigRecurrWindowP := models.NewRecurringWindow(rn, parentDn, nameAlias, trigRecurrWindowPAttr)
trigRecurrWindowP.Status = "modified"
err := sm.Save(trigRecurrWindowP)
return trigRecurrWindowP, err
}
func (sm *ServiceManager) ListRecurringWindow(scheduler string) ([]*models.RecurringWindow, error) {
dnUrl := fmt.Sprintf("%s/uni/fabric/schedp-%s/trigRecurrWindowP.json", models.BaseurlStr, scheduler)
cont, err := sm.GetViaURL(dnUrl)
list := models.RecurringWindowListFromContainer(cont)
return list, err
}