/
aci_bindings.go
118 lines (90 loc) · 4.43 KB
/
aci_bindings.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
package isegosdk
import (
"fmt"
"github.com/go-resty/resty/v2"
"github.com/google/go-querystring/query"
)
type AciBindingsService service
type GetAciBindingsQueryParams struct {
Page int `url:"page,omitempty"` //Page number
Size int `url:"size,omitempty"` //Number of objects returned per page
Sort string `url:"sort,omitempty"` //sort type - asc or desc
SortBy string `url:"sortBy,omitempty"` //sort column by which objects needs to be sorted
FilterBy []string `url:"filterBy,omitempty"` //
FilterValue []string `url:"filterValue,omitempty"` //
}
type ResponseAciBindingsGetAciBindings struct {
AciBindings *ResponseAciBindingsGetAciBindingsAciBindings `json:"ACIBindings,omitempty"` //
}
type ResponseAciBindingsGetAciBindingsAciBindings struct {
ID string `json:"id,omitempty"` // Resource UUID value
Name string `json:"name,omitempty"` // Resource Name
Description string `json:"description,omitempty"` //
IP string `json:"ip,omitempty"` // Binding IPv4 address. Each binding will be exclusively identified by its IP address and virtual network
SgtValue string `json:"sgtValue,omitempty"` // Security Group Tag (SGT) value. The valid range for SGT values is 0-65534
Vn string `json:"vn,omitempty"` // Virtual network. Each binding will be exclusively identified by its IP address and virtual network
Psn string `json:"psn,omitempty"` // Cisco ISE Policy Service node (PSN) IP address
LearnedFrom string `json:"learnedFrom,omitempty"` // Binding Source
LearnedBy string `json:"learnedBy,omitempty"` // Binding Type
}
type ResponseAciBindingsGetVersion struct {
VersionInfo *ResponseAciBindingsGetVersionVersionInfo `json:"VersionInfo,omitempty"` //
}
type ResponseAciBindingsGetVersionVersionInfo struct {
CurrentServerVersion string `json:"currentServerVersion,omitempty"` //
SupportedVersions string `json:"supportedVersions,omitempty"` //
Link *ResponseAciBindingsGetVersionVersionInfoLink `json:"link,omitempty"` //
}
type ResponseAciBindingsGetVersionVersionInfoLink struct {
Rel string `json:"rel,omitempty"` //
Href string `json:"href,omitempty"` //
Type string `json:"type,omitempty"` //
}
//GetAciBindings Get all binding information
/* This API allows clients to retrieve all the bindings that were sent to Cisco ISE by ACI or received on ACI from Cisco ISE.The binding information will be identical to the information on ACI bindings page in the Cisco ISE UI. Filtering will be based on one attribute only, such as ip/sgt/vn/psn/learnedFrom/learnedBy with CONTAINS mode of search.
@param getAciBindingsQueryParams Filtering parameter
*/
func (s *AciBindingsService) GetAciBindings(getAciBindingsQueryParams *GetAciBindingsQueryParams) (*ResponseAciBindingsGetAciBindings, *resty.Response, error) {
setHost(s.client, "_ers")
path := "/ers/config/acibindings/getall"
queryString, _ := query.Values(getAciBindingsQueryParams)
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetQueryString(queryString.Encode()).SetResult(&ResponseAciBindingsGetAciBindings{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetAciBindings")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseAciBindingsGetAciBindings)
return result, response, err
}
//GetVersion Get ACI bindings version information
/* This API helps to retrieve the version information related to the Cisco ACI bindings.
*/
func (s *AciBindingsService) GetVersion() (*ResponseAciBindingsGetVersion, *resty.Response, error) {
setHost(s.client, "_ers")
path := "/ers/config/acibindings/versioninfo"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseAciBindingsGetVersion{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetVersion")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseAciBindingsGetVersion)
return result, response, err
}