-
Notifications
You must be signed in to change notification settings - Fork 1
/
prober_pool.go
111 lines (96 loc) · 3.67 KB
/
prober_pool.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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"
// ProberPoolList holds a list of ProberPool configuration.
type ProberPoolList struct {
Items []ProberPool `json:"items,omitempty"`
Kind string `json:"kind,omitempty"`
SelfLink string `json:"selflink,omitempty"`
}
// ProberPool holds the configuration of a single ProberPool.
type ProberPool struct {
Enabled bool `json:"enabled,omitempty"`
FullPath string `json:"fullPath,omitempty"`
Generation int `json:"generation,omitempty"`
Kind string `json:"kind,omitempty"`
LoadBalancingMode string `json:"loadBalancingMode,omitempty"`
MembersReference struct {
Members []ProberPoolMembers `json:"items,omitempty"`
IsSubcollection bool `json:"isSubcollection,omitempty"`
Link string `json:"link,omitempty"`
} `json:"membersReference,omitempty"`
Name string `json:"name,omitempty"`
Partition string `json:"partition,omitempty"`
SelfLink string `json:"selfLink,omitempty"`
}
// ProberPoolMembersList holds a list of ProberPoolMembers configuration.
type ProberPoolMembersList struct {
Items []ProberPoolMembers `json:"items"`
Kind string `json:"kind"`
SelfLink string `json:"selflink"`
}
// ProberPoolMembers holds the configuration of a single ProberPoolMembers.
type ProberPoolMembers struct {
Enabled bool `json:"enabled"`
FullPath string `json:"fullPath"`
Generation int `json:"generation"`
Kind string `json:"kind"`
Name string `json:"name"`
Order int `json:"order"`
SelfLink string `json:"selfLink"`
}
// ProberPoolMembersEndpoint represents the REST resource for managing ProberPoolMembers.
const ProberPoolMembersEndpoint = "/members"
// ProberPoolEndpoint represents the REST resource for managing ProberPool.
const ProberPoolEndpoint = "/prober-pool"
// ProberPoolResource provides an API to manage ProberPool configurations.
type ProberPoolResource struct {
c *f5.Client
}
// ListAll lists all the ProberPool configurations.
func (r *ProberPoolResource) ListAll() (*ProberPoolList, error) {
var list ProberPoolList
if err := r.c.ReadQuery(BasePath+ProberPoolEndpoint, &list); err != nil {
return nil, err
}
return &list, nil
}
// Get a single ProberPool configuration identified by id.
func (r *ProberPoolResource) Get(id string) (*ProberPool, error) {
var item ProberPool
if err := r.c.ReadQuery(BasePath+ProberPoolEndpoint, &item); err != nil {
return nil, err
}
return &item, nil
}
// GetMembers lists all the ProberPoolMembers configurations.
func (r *ProberPoolResource) GetMembers(id string) (*ProberPoolMembersList, error) {
var list ProberPoolMembersList
if err := r.c.ReadQuery(BasePath+ProberPoolEndpoint+"/"+id+ProberPoolMembersEndpoint, &list); err != nil {
return nil, err
}
return &list, nil
}
// Create a new ProberPool configuration.
func (r *ProberPoolResource) Create(item ProberPool) error {
if err := r.c.ModQuery("POST", BasePath+ProberPoolEndpoint, item); err != nil {
return err
}
return nil
}
// Edit a ProberPool configuration identified by id.
func (r *ProberPoolResource) Edit(id string, item ProberPool) error {
if err := r.c.ModQuery("PUT", BasePath+ProberPoolEndpoint+"/"+id, item); err != nil {
return err
}
return nil
}
// Delete a single ProberPool configuration identified by id.
func (r *ProberPoolResource) Delete(id string) error {
if err := r.c.ModQuery("DELETE", BasePath+ProberPoolEndpoint+"/"+id, nil); err != nil {
return err
}
return nil
}