-
Notifications
You must be signed in to change notification settings - Fork 20
/
folder.go
87 lines (75 loc) · 2.62 KB
/
folder.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright e-Xpert Solutions SA. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sys
import "github.com/e-XpertSolutions/f5-rest-client/f5"
// FolderConfigList holds a list of Folder configuration.
type FolderConfigList struct {
Items []FolderConfig `json:"items"`
Kind string `json:"kind"`
SelfLink string `json:"selflink"`
}
// FolderConfig holds the configuration of a single Folder.
type FolderConfig struct {
DeviceGroup string `json:"deviceGroup"`
FullPath string `json:"fullPath"`
Generation int `json:"generation"`
Hidden string `json:"hidden"`
InheritedDevicegroup string `json:"inheritedDevicegroup"`
InheritedTrafficGroup string `json:"inheritedTrafficGroup"`
Kind string `json:"kind"`
Name string `json:"name"`
NoRefCheck string `json:"noRefCheck"`
SelfLink string `json:"selfLink"`
TrafficGroup string `json:"trafficGroup"`
TrafficGroupReference struct {
Link string `json:"link"`
} `json:"trafficGroupReference"`
}
type NewFolderConfig struct {
Name string `json:"name"`
Partition string `json:"partition"`
}
// FolderEndpoint represents the REST resource for managing Folder.
const FolderEndpoint = "/folder"
// FolderResource provides an API to manage Folder configurations.
type FolderResource struct {
c *f5.Client
}
// ListAll lists all the Folder configurations.
func (r *FolderResource) ListAll() (*FolderConfigList, error) {
var list FolderConfigList
if err := r.c.ReadQuery(BasePath+FolderEndpoint, &list); err != nil {
return nil, err
}
return &list, nil
}
// Get a single Folder configuration identified by id.
func (r *FolderResource) Get(id string) (*FolderConfig, error) {
var item FolderConfig
if err := r.c.ReadQuery(BasePath+FolderEndpoint+"/"+id, &item); err != nil {
return nil, err
}
return &item, nil
}
// Create a new Folder configuration.
func (r *FolderResource) Create(item NewFolderConfig) error {
if err := r.c.ModQuery("POST", BasePath+FolderEndpoint, item); err != nil {
return err
}
return nil
}
// Edit a Folder configuration identified by id.
func (r *FolderResource) Edit(id string, item FolderConfig) error {
if err := r.c.ModQuery("PUT", BasePath+FolderEndpoint+"/"+id, item); err != nil {
return err
}
return nil
}
// Delete a single Folder configuration identified by id.
func (r *FolderResource) Delete(id string) error {
if err := r.c.ModQuery("DELETE", BasePath+FolderEndpoint+"/"+id, nil); err != nil {
return err
}
return nil
}