forked from CiscoISE/ciscoise-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_group.go
669 lines (442 loc) · 19.9 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
package isegosdk
import (
"fmt"
"strings"
"github.com/go-resty/resty/v2"
"github.com/google/go-querystring/query"
)
type NodeGroupService service
type DeleteNodeGroupQueryParams struct {
ForceDelete bool `url:"forceDelete,omitempty"` //Force delete the group even if the node group contains one or more nodes.
}
type ResponseNodeGroupGetNodeGroups struct {
Response *[]ResponseNodeGroupGetNodeGroupsResponse `json:"response,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupsResponse struct {
Description string `json:"description,omitempty"` //
MarCache *ResponseNodeGroupGetNodeGroupsResponseMarCache `json:"marCache,omitempty"` //
Name string `json:"name,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupsResponseMarCache struct {
QueryAttempts *int `json:"query-attempts,omitempty"` // The number of times Cisco ISE attempts to perform the cache entry query. (0 - 5).
QueryTimeout *int `json:"query-timeout,omitempty"` // The time, in seconds, after which the cache entry query times out. (1 - 10).
ReplicationAttempts *int `json:"replication-attempts,omitempty"` // The number of times Cisco ISE attempts to perform MAR cache entry replication. (0 - 5).
ReplicationTimeout *int `json:"replication-timeout,omitempty"` // The time, in seconds, after which the cache entry replication times out. (1 - 10).
}
type ResponseNodeGroupCreateNodeGroup struct {
Success *ResponseNodeGroupCreateNodeGroupSuccess `json:"success,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupCreateNodeGroupSuccess struct {
Message string `json:"message,omitempty"` //
}
type ResponseNodeGroupGetNodeGroup struct {
Response *ResponseNodeGroupGetNodeGroupResponse `json:"response,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupResponse struct {
Description string `json:"description,omitempty"` //
MarCache *ResponseNodeGroupGetNodeGroupResponseMarCache `json:"marCache,omitempty"` //
Name string `json:"name,omitempty"` //
}
type ResponseNodeGroupGetNodeGroupResponseMarCache struct {
QueryAttempts *int `json:"query-attempts,omitempty"` // The number of times Cisco ISE attempts to perform the cache entry query. (0 - 5).
QueryTimeout *int `json:"query-timeout,omitempty"` // The time, in seconds, after which the cache entry query times out. (1 - 10).
ReplicationAttempts *int `json:"replication-attempts,omitempty"` // The number of times Cisco ISE attempts to perform MAR cache entry replication. (0 - 5).
ReplicationTimeout *int `json:"replication-timeout,omitempty"` // The time, in seconds, after which the cache entry replication times out. (1 - 10).
}
type ResponseNodeGroupUpdateNodeGroup struct {
Success *ResponseNodeGroupUpdateNodeGroupSuccess `json:"success,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupUpdateNodeGroupSuccess struct {
Message string `json:"message,omitempty"` //
}
type ResponseNodeGroupDeleteNodeGroup struct {
Success *ResponseNodeGroupDeleteNodeGroupSuccess `json:"success,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupDeleteNodeGroupSuccess struct {
Message string `json:"message,omitempty"` //
}
type ResponseNodeGroupAddNode struct {
Success *ResponseNodeGroupAddNodeSuccess `json:"success,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupAddNodeSuccess struct {
Message string `json:"message,omitempty"` //
}
type ResponseNodeGroupGetNodes struct {
Response *[]ResponseNodeGroupGetNodesResponse `json:"response,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupGetNodesResponse struct {
Hostname string `json:"hostname,omitempty"` //
}
type ResponseNodeGroupRemoveNode struct {
Success *ResponseNodeGroupRemoveNodeSuccess `json:"success,omitempty"` //
Version string `json:"version,omitempty"` //
}
type ResponseNodeGroupRemoveNodeSuccess struct {
Message string `json:"message,omitempty"` //
}
type RequestNodeGroupCreateNodeGroup struct {
Description string `json:"description,omitempty"` //
MarCache *RequestNodeGroupCreateNodeGroupMarCache `json:"marCache,omitempty"` //
Name string `json:"name,omitempty"` //
}
type RequestNodeGroupCreateNodeGroupMarCache struct {
QueryAttempts *int `json:"query-attempts,omitempty"` // The number of times Cisco ISE attempts to perform the cache entry query. (0 - 5).
QueryTimeout *int `json:"query-timeout,omitempty"` // The time, in seconds, after which the cache entry query times out. (1 - 10).
ReplicationAttempts *int `json:"replication-attempts,omitempty"` // The number of times Cisco ISE attempts to perform MAR cache entry replication. (0 - 5).
ReplicationTimeout *int `json:"replication-timeout,omitempty"` // The time, in seconds, after which the cache entry replication times out. (1 - 10).
}
type RequestNodeGroupUpdateNodeGroup struct {
Description string `json:"description,omitempty"` //
MarCache *RequestNodeGroupUpdateNodeGroupMarCache `json:"marCache,omitempty"` //
Name string `json:"name,omitempty"` //
}
type RequestNodeGroupUpdateNodeGroupMarCache struct {
QueryAttempts *int `json:"query-attempts,omitempty"` // The number of times Cisco ISE attempts to perform the cache entry query. (0 - 5).
QueryTimeout *int `json:"query-timeout,omitempty"` // The time, in seconds, after which the cache entry query times out. (1 - 10).
ReplicationAttempts *int `json:"replication-attempts,omitempty"` // The number of times Cisco ISE attempts to perform MAR cache entry replication. (0 - 5).
ReplicationTimeout *int `json:"replication-timeout,omitempty"` // The time, in seconds, after which the cache entry replication times out. (1 - 10).
}
type RequestNodeGroupAddNode struct {
Hostname string `json:"hostname,omitempty"` //
}
type RequestNodeGroupRemoveNode struct {
Hostname string `json:"hostname,omitempty"` //
}
//GetNodeGroups Retrieve the list of all the node groups.
/* This API retrieves the details of all the node groups in the cluster.
Each node group retrieved consists of name, description and MAR cache details like query-attempts, query-timeout, replication-attempts, replication-timeout.
*/
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 Retrieve the details of a node group
/* This API retrieves the details of a node group in the cluster using a node group name.
@param nodeGroupName nodeGroupName path parameter. Name 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/{nodeGroupName}"
path = strings.Replace(path, "{nodeGroupName}", 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
}
//GetNodes Retrieve the list of nodes in a given node group.
/* This API retrieves the list of nodes associated with a node group in the cluster with a given node group name.
@param nodeGroupName nodeGroupName path parameter. Name of the existing node group.
*/
func (s *NodeGroupService) GetNodes(nodeGroupName string) (*ResponseNodeGroupGetNodes, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{nodeGroupName}/node"
path = strings.Replace(path, "{nodeGroupName}", fmt.Sprintf("%v", nodeGroupName), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseNodeGroupGetNodes{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetNodes")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseNodeGroupGetNodes)
return result, response, err
}
//CreateNodeGroup Create a node group.
/*
This API creates a node group in the cluster. A node group is a group of PSNs, where the PSNs maintain a heartbeat with each other. It is used primarily to terminate or transfer posture-pending sessions when a PSN in a local node group fails. Node group members can communicate over TCP/7800.
The following parameters are used in the request body of the API:
PARAMETER
DESCRIPTION
EXAMPLE
name
* required
Name of the node group(
valid-range:
1-100 characters)
{"name": "site1"}
description
Description of the node group (
valid-range:
0-256 characters)
{"name": "site2", "description": "sample"}
query-attempts
The number of times Cisco ISE attempts to perform the cache entry query. (
valid-range:
0 5,
default-value:
1)
{"name": "site3","marCache": {"query-attempts": 1}}
query-timeout
The time, in seconds, after which a cache entry query times out. (
valid-range:
1 10,
default-value:
2) second(s)
{"name": "site4","marCache": {"query-timeout": 2}}
replication-attempts
The number of times Cisco ISE attempts to perform MAR cache entry replication. (
valid-range:
0 5,
default-value:
2)
{"name": "site5","marCache": {"replication-attempts": 2}}
replication-timeout
The time, in seconds, after which the cache entry replication times out. (
valid-range:
1 10,
default-value:
5) second(s)
{"name": "site6","marCache": {"replication-timeout": 5}}
NOTE 1:
: Node group name and description cannot contain any of the following characters: ! % ^ : ; , . ~ @ # & [ { ( | ) } ] ` > < / \ " + = ?
NOTE 2:
: Parameter marCache stands for Machine Access Restriction (MAR) cache that provides an additional means of controlling authorization for Active Directory-authentication users. We can enable the marCache for a nodegroup by providing key "marCache" in json request. Additionally we may also provide any combination of parameters query-attempts, query-timeout, replication-attempts, replication-timeout in marCache object. If no value is specified for a particular parameter its default value will be recorded.If no marCache object is given, marCache will be considered as disabled.
*/
func (s *NodeGroupService) CreateNodeGroup(requestNodeGroupCreateNodeGroup *RequestNodeGroupCreateNodeGroup) (*ResponseNodeGroupCreateNodeGroup, *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").
SetBody(requestNodeGroupCreateNodeGroup).
SetResult(&ResponseNodeGroupCreateNodeGroup{}).
SetError(&Error).
Post(path)
if err != nil {
if err.Error() == emptyStringToJSONError {
return &ResponseNodeGroupCreateNodeGroup{}, response, 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
}
//AddNode Add a node to a node group.
/*
This API adds a node to the node group in the cluster. 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 the URL-redirected sessions on the failed node.
The following parameters are used in the request body of the API:
PARAMETER
DESCRIPTION
EXAMPLE
hostname
* required
Name of the host name
{"hostname": "isenode"}
@param nodeGroupName nodeGroupName path parameter. Name of the existing node group.
*/
func (s *NodeGroupService) AddNode(nodeGroupName string, requestNodeGroupAddNode *RequestNodeGroupAddNode) (*ResponseNodeGroupAddNode, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{nodeGroupName}/add-node"
path = strings.Replace(path, "{nodeGroupName}", fmt.Sprintf("%v", nodeGroupName), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestNodeGroupAddNode).
SetResult(&ResponseNodeGroupAddNode{}).
SetError(&Error).
Post(path)
if err != nil {
if err.Error() == emptyStringToJSONError {
return &ResponseNodeGroupAddNode{}, response, nil
}
return nil, nil, err
}
getCSFRToken(response.Header())
if response.IsError() {
return nil, response, fmt.Errorf("error with operation AddNode")
}
result := response.Result().(*ResponseNodeGroupAddNode)
return result, response, err
}
//RemoveNode Remove a node from a node group.
/*
Purpose of this API is to remove a node from a node group in the cluster. Removing node from the node group does not delete the node, but failover is no longer carried out if the node is not part any node group.
The following parameters are used in the request body of the API:
PARAMETER
DESCRIPTION
EXAMPLE
hostname
* required
Name of the host name
{"hostname": "isenode"}
@param nodeGroupName nodeGroupName path parameter. Name of the existing node group.
*/
func (s *NodeGroupService) RemoveNode(nodeGroupName string, requestNodeGroupRemoveNode *RequestNodeGroupRemoveNode) (*ResponseNodeGroupRemoveNode, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{nodeGroupName}/remove-node"
path = strings.Replace(path, "{nodeGroupName}", fmt.Sprintf("%v", nodeGroupName), -1)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestNodeGroupRemoveNode).
SetResult(&ResponseNodeGroupRemoveNode{}).
SetError(&Error).
Post(path)
if err != nil {
if err.Error() == emptyStringToJSONError {
return &ResponseNodeGroupRemoveNode{}, response, nil
}
return nil, nil, err
}
getCSFRToken(response.Header())
if response.IsError() {
return nil, response, fmt.Errorf("error with operation RemoveNode")
}
result := response.Result().(*ResponseNodeGroupRemoveNode)
return result, response, err
}
//UpdateNodeGroup Update an existing node group.
/*
Purpose of this API is to update an existing node group.
The following parameters are used in the request body of the API:
PARAMETER
DESCRIPTION
EXAMPLE
name
* required
Name of the node group existing in ISE(
valid-range:
1-100 characters)
NOTE :
name of an existing node group cannot be modified. "name" parameter should be identical to the node group name(nodeGroupName) provided in the path
{"name": "site1"}
description
Description of the node group (
valid-range:
0-256 characters)
{"name": "site2", "description": "sample"}
query-attempts
The number of times Cisco ISE attempts to perform the cache entry query. (
valid-range:
0 5,
default-value:
1)
{"name": "site3","marCache": {"query-attempts": 1}}
query-timeout
The time, in seconds, after which a cache entry query times out. (
valid-range:
1 10,
default-value:
2) second(s)
{"name": "site4","marCache": {"query-timeout": 2}}
replication-attempts
The number of times Cisco ISE attempts to perform MAR cache entry replication. (
valid-range:
0 5,
default-value:
2)
{"name": "site5","marCache": {"replication-attempts": 2}}
replication-timeout
The time, in seconds, after which the cache entry replication times out. (
valid-range:
1 10,
default-value:
5) second(s)
{"name": "site6","marCache": {"replication-timeout": 5}}
NOTE 1:
Node group name and description cannot contain any of the following characters: ! % ^ : ; , . ~ @ # & [ { ( | ) } ] ` > < / \ " + = ?
NOTE 2:
Parameter marCache stands for Machine Access Restriction (MAR) cache that provides an additional means of controlling authorization for Active Directory-authentication users. We can enable the marCache for a nodegroup by providing key "marCache" in json request. Additionally we may also provide any combination of parameters query-attempts, query-timeout, replication-attempts, replication-timeout in marCache object. If no value is specified for a particular parameter its default value will be recorded. If no marCache object is given, marCache will be disabled.
@param nodeGroupName nodeGroupName path parameter. Name 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/{nodeGroupName}"
path = strings.Replace(path, "{nodeGroupName}", 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 {
if err.Error() == emptyStringToJSONError {
return &ResponseNodeGroupUpdateNodeGroup{}, response, 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.
/* Delete an existing node group in the cluster. Deleting the node group does not delete the nodes, but failover is no longer carried out among the nodes.
@param nodeGroupName nodeGroupName path parameter. Name of the existing node group.
@param deleteNodeGroupQueryParams Filtering parameter
*/
func (s *NodeGroupService) DeleteNodeGroup(nodeGroupName string, deleteNodeGroupQueryParams *DeleteNodeGroupQueryParams) (*ResponseNodeGroupDeleteNodeGroup, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/deployment/node-group/{nodeGroupName}"
path = strings.Replace(path, "{nodeGroupName}", fmt.Sprintf("%v", nodeGroupName), -1)
queryString, _ := query.Values(deleteNodeGroupQueryParams)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetQueryString(queryString.Encode()).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
}