/
node_group.go
255 lines (196 loc) · 8.84 KB
/
node_group.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package isegosdk
import (
"fmt"
"strings"
"github.com/go-resty/resty/v2"
)
type NodeGroupService service
type ResponseNodeGroupGetNodeGroups struct {
Response *[]ResponseNodeGroupGetNodeGroupsResponse `json:"response,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupsResponse struct {
Name string `json:"name,omitempty"` //
Description string `json:"description,omitempty"` //
MarCache *ResponseNodeGroupGetNodeGroupsResponseMarCache `json:"mar-cache,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupsResponseMarCache struct {
Enabled *bool `json:"enabled,omitempty"` //
ReplicationTimeout *int `json:"replication-timeout,omitempty"` //
ReplicationAttempts *int `json:"replication-attempts,omitempty"` //
QueryTimeout *int `json:"query-timeout,omitempty"` //
QueryAttempts *int `json:"query-attempts,omitempty"` //
}
type ResponseNodeGroupGetNodeGroup struct {
Name string `json:"name,omitempty"` //
Description string `json:"description,omitempty"` //
MarCache *ResponseNodeGroupGetNodeGroupMarCache `json:"mar-cache,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupMarCache struct {
Enabled *bool `json:"enabled,omitempty"` //
ReplicationTimeout *int `json:"replication-timeout,omitempty"` //
ReplicationAttempts *int `json:"replication-attempts,omitempty"` //
QueryTimeout *int `json:"query-timeout,omitempty"` //
QueryAttempts *int `json:"query-attempts,omitempty"` //
}
type ResponseNodeGroupCreateNodeGroup struct {
Code *int `json:"code,omitempty"` //
Message string `json:"message,omitempty"` //
RootCause string `json:"rootCause,omitempty"` //
}
type ResponseNodeGroupUpdateNodeGroup struct {
Code *int `json:"code,omitempty"` //
Message string `json:"message,omitempty"` //
RootCause string `json:"rootCause,omitempty"` //
}
type ResponseNodeGroupDeleteNodeGroup struct {
Code *int `json:"code,omitempty"` //
Message string `json:"message,omitempty"` //
RootCause string `json:"rootCause,omitempty"` //
}
type RequestNodeGroupCreateNodeGroup struct {
Description string `json:"description,omitempty"` //
MarCache *RequestNodeGroupCreateNodeGroupMarCache `json:"mar-cache,omitempty"` //
}
type RequestNodeGroupCreateNodeGroupMarCache struct {
Enabled *bool `json:"enabled,omitempty"` //
ReplicationTimeout *int `json:"replication-timeout,omitempty"` //
ReplicationAttempts *int `json:"replication-attempts,omitempty"` //
QueryTimeout *int `json:"query-timeout,omitempty"` //
QueryAttempts *int `json:"query-attempts,omitempty"` //
}
type RequestNodeGroupUpdateNodeGroup struct {
Description string `json:"description,omitempty"` //
MarCache *RequestNodeGroupUpdateNodeGroupMarCache `json:"mar-cache,omitempty"` //
}
type RequestNodeGroupUpdateNodeGroupMarCache struct {
Enabled *bool `json:"enabled,omitempty"` //
ReplicationTimeout *int `json:"replication-timeout,omitempty"` //
ReplicationAttempts *int `json:"replication-attempts,omitempty"` //
QueryTimeout *int `json:"query-timeout,omitempty"` //
QueryAttempts *int `json:"query-attempts,omitempty"` //
}
//GetNodeGroups Get the list of all node group.
/* Get details of all the node groups in the cluster. To detect node failure and to reset all URL-redirected sessions on the failed node, two or more Policy Service nodes can be placed in the same node group. When a node that belongs to a node group fails, another node in the same node group issues a Change of Authorization (CoA) for all URL-redirected sessions on the failed node.
*/
func (s *NodeGroupService) GetNodeGroups() (*ResponseNodeGroupGetNodeGroups, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseNodeGroupGetNodeGroups{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetNodeGroups")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseNodeGroupGetNodeGroups)
return result, response, err
}
//GetNodeGroup Get details of a node group
/* Get details of a node group in the cluster.
@param nodegroupname node-group-name path parameter. ID of the existing node group.
*/
func (s *NodeGroupService) GetNodeGroup(nodegroupname string) (*ResponseNodeGroupGetNodeGroup, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{node-group-name}"
path = strings.Replace(path, "{node-group-name}", fmt.Sprintf("%v", nodegroupname), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseNodeGroupGetNodeGroup{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetNodeGroup")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseNodeGroupGetNodeGroup)
return result, response, err
}
//CreateNodeGroup Creates a node group.
/* Developers need to create node group in the system.Node Group is a group of PSNs, mainly used for terminating posture pending sessions when a PSN in local node group fails.Node group members can communicate over TCP/7800.
@param nodegroupname node-group-name path parameter. ID of the existing node group.
*/
func (s *NodeGroupService) CreateNodeGroup(nodegroupname string, requestNodeGroupCreateNodeGroup *RequestNodeGroupCreateNodeGroup) (*ResponseNodeGroupCreateNodeGroup, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{node-group-name}"
path = strings.Replace(path, "{node-group-name}", fmt.Sprintf("%v", nodegroupname), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestNodeGroupCreateNodeGroup).
SetResult(&ResponseNodeGroupCreateNodeGroup{}).
SetError(&Error).
Post(path)
if err != nil {
return nil, nil, err
}
getCSFRToken(response.Header())
if response.IsError() {
return nil, response, fmt.Errorf("error with operation CreateNodeGroup")
}
result := response.Result().(*ResponseNodeGroupCreateNodeGroup)
return result, response, err
}
//UpdateNodeGroup Edits an existing node group.
/* API updates an existing node group in the system.
@param nodegroupname node-group-name path parameter. ID of the existing node group.
*/
func (s *NodeGroupService) UpdateNodeGroup(nodegroupname string, requestNodeGroupUpdateNodeGroup *RequestNodeGroupUpdateNodeGroup) (*ResponseNodeGroupUpdateNodeGroup, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{node-group-name}"
path = strings.Replace(path, "{node-group-name}", fmt.Sprintf("%v", nodegroupname), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestNodeGroupUpdateNodeGroup).
SetResult(&ResponseNodeGroupUpdateNodeGroup{}).
SetError(&Error).
Put(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation UpdateNodeGroup")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseNodeGroupUpdateNodeGroup)
return result, response, err
}
//DeleteNodeGroup Delete a node group.
/* Developers need to delete node group in the system.
@param nodegroupname node-group-name path parameter. ID of the existing node group.
*/
func (s *NodeGroupService) DeleteNodeGroup(nodegroupname string) (*ResponseNodeGroupDeleteNodeGroup, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{node-group-name}"
path = strings.Replace(path, "{node-group-name}", fmt.Sprintf("%v", nodegroupname), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseNodeGroupDeleteNodeGroup{}).
SetError(&Error).
Delete(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation DeleteNodeGroup")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseNodeGroupDeleteNodeGroup)
return result, response, err
}