-
Notifications
You must be signed in to change notification settings - Fork 1
/
distributed_app.go
82 lines (71 loc) · 2.73 KB
/
distributed_app.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
// 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 gtm
import "github.com/hillmai/f5client/f5"
// DistributedAppList holds a list of DistributedApp uration.
type DistributedAppList struct {
Items []DistributedApp `json:"items,omitempty"`
Kind string `json:"kind,omitempty"`
SelfLink string `json:"selflink,omitempty"`
}
// DistributedApp holds the uration of a single DistributedApp.
type DistributedApp struct {
DependencyLevel string `json:"dependencyLevel,omitempty"`
FullPath string `json:"fullPath,omitempty"`
Generation int `json:"generation,omitempty"`
Kind string `json:"kind,omitempty"`
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
PersistCidrIpv4 int `json:"persistCidrIpv4,omitempty"`
PersistCidrIpv6 int `json:"persistCidrIpv6,omitempty"`
Persistence string `json:"persistence,omitempty"`
SelfLink string `json:"selfLink,omitempty"`
TTLPersistence int `json:"ttlPersistence,omitempty"`
Wideips []struct {
Name string `json:"name,omitempty"`
} `json:"wideips,omitempty"`
}
// DistributedAppEndpoint represents the REST resource for managing DistributedApp.
const DistributedAppEndpoint = "/distributed-app"
// DistributedAppResource provides an API to manage DistributedApp urations.
type DistributedAppResource struct {
c *f5.Client
}
// ListAll lists all the DistributedApp urations.
func (r *DistributedAppResource) ListAll() (*DistributedAppList, error) {
var list DistributedAppList
if err := r.c.ReadQuery(BasePath+DistributedAppEndpoint, &list); err != nil {
return nil, err
}
return &list, nil
}
// Get a single DistributedApp uration identified by id.
func (r *DistributedAppResource) Get(id string) (*DistributedApp, error) {
var item DistributedApp
if err := r.c.ReadQuery(BasePath+DistributedAppEndpoint, &item); err != nil {
return nil, err
}
return &item, nil
}
// Create a new DistributedApp uration.
func (r *DistributedAppResource) Create(item DistributedApp) error {
if err := r.c.ModQuery("POST", BasePath+DistributedAppEndpoint, item); err != nil {
return err
}
return nil
}
// Edit a DistributedApp uration identified by id.
func (r *DistributedAppResource) Edit(id string, item DistributedApp) error {
if err := r.c.ModQuery("PUT", BasePath+DistributedAppEndpoint+"/"+id, item); err != nil {
return err
}
return nil
}
// Delete a single DistributedApp uration identified by id.
func (r *DistributedAppResource) Delete(id string) error {
if err := r.c.ModQuery("DELETE", BasePath+DistributedAppEndpoint+"/"+id, nil); err != nil {
return err
}
return nil
}