-
Notifications
You must be signed in to change notification settings - Fork 29
/
firmwareDownload_service.go
47 lines (40 loc) · 1.61 KB
/
firmwareDownload_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
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateDownload(name string, description string, firmwareDownloadAttr models.DownloadAttributes) (*models.Download, error) {
rn := fmt.Sprintf("download-%s", name)
parentDn := fmt.Sprintf("uni/fabric/fwrepop")
firmwareDownload := models.NewDownload(rn, parentDn, description, firmwareDownloadAttr)
err := sm.Save(firmwareDownload)
return firmwareDownload, err
}
func (sm *ServiceManager) ReadDownload(name string) (*models.Download, error) {
dn := fmt.Sprintf("uni/fabric/fwrepop/download-%s", name)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
firmwareDownload := models.DownloadFromContainer(cont)
return firmwareDownload, nil
}
func (sm *ServiceManager) DeleteDownload(name string) error {
dn := fmt.Sprintf("uni/fabric/fwrepop/download-%s", name)
return sm.DeleteByDn(dn, models.FirmwareDownloadClassName)
}
func (sm *ServiceManager) UpdateDownload(name string, description string, firmwareDownloadAttr models.DownloadAttributes) (*models.Download, error) {
rn := fmt.Sprintf("download-%s", name)
parentDn := fmt.Sprintf("uni/fabric/fwrepop")
firmwareDownload := models.NewDownload(rn, parentDn, description, firmwareDownloadAttr)
firmwareDownload.Status = "modified"
err := sm.Save(firmwareDownload)
return firmwareDownload, err
}
func (sm *ServiceManager) ListDownload() ([]*models.Download, error) {
baseurlStr := "/api/node/class"
dnUrl := fmt.Sprintf("%s/firmwareDownload.json", baseurlStr)
cont, err := sm.GetViaURL(dnUrl)
list := models.DownloadListFromContainer(cont)
return list, err
}