/
proxy.go
156 lines (106 loc) · 5.02 KB
/
proxy.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
package isegosdk
import (
"fmt"
"github.com/go-resty/resty/v2"
)
type ProxyService service
type ResponseProxyGetProxyConnection struct {
Response *ResponseProxyGetProxyConnectionResponse `json:"response,omitempty"` // ISE Proxy connection settings
Version string `json:"version,omitempty"` //
}
type ResponseProxyGetProxyConnectionResponse struct {
BypassHosts string `json:"bypassHosts,omitempty"` // Bypass hosts for the proxy connection
Fqdn string `json:"fqdn,omitempty"` // proxy IP address or DNS-resolvable host name
Password string `json:"password,omitempty"` // Password for the proxy connection
PasswordRequired *bool `json:"passwordRequired,omitempty"` // Indicates whether password configuration is required for Proxy.
Port *int `json:"port,omitempty"` // Port for proxy connection. should be between 1 and 65535
UserName string `json:"userName,omitempty"` // User name for the proxy connection
}
type ResponseProxyUpdateProxyConnection struct {
Response *ResponseProxyUpdateProxyConnectionResponse `json:"response,omitempty"` // ISE Proxy connection settings
Version string `json:"version,omitempty"` //
}
type ResponseProxyUpdateProxyConnectionResponse struct {
BypassHosts string `json:"bypassHosts,omitempty"` // Bypass hosts for the proxy connection
Fqdn string `json:"fqdn,omitempty"` // proxy IP address or DNS-resolvable host name
Password string `json:"password,omitempty"` // Password for the proxy connection
PasswordRequired *bool `json:"passwordRequired,omitempty"` // Indicates whether password configuration is required for Proxy.
Port *int `json:"port,omitempty"` // Port for proxy connection. should be between 1 and 65535
UserName string `json:"userName,omitempty"` // User name for the proxy connection
}
type RequestProxyUpdateProxyConnection struct {
BypassHosts string `json:"bypassHosts,omitempty"` // Bypass hosts for the proxy connection
Fqdn string `json:"fqdn,omitempty"` // proxy IP address or DNS-resolvable host name
Password string `json:"password,omitempty"` // Password for the proxy connection
PasswordRequired *bool `json:"passwordRequired,omitempty"` // Indicates whether password configuration is required for Proxy.
Port *int `json:"port,omitempty"` // Port for proxy connection. should be between 1 and 65535
UserName string `json:"userName,omitempty"` // User name for the proxy connection
}
//GetProxyConnection Returns ISE proxy connection settings
/* The following functionalities are impacted by the proxy settings:
Partner Mobile Management
Endpoint Profiler Feed Service Update
Endpoint Posture Update
Endpoint Posture Agent Resources Download
CRL (Certificate Revocation List) Download
SMS Message Transmission
Social Login
Rest Auth Service Azure AD
pxGrid Cloud
*/
func (s *ProxyService) GetProxyConnection() (*ResponseProxyGetProxyConnection, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/system-settings/proxy"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetResult(&ResponseProxyGetProxyConnection{}).
SetError(&Error).
Get(path)
if err != nil {
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation GetProxyConnection")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseProxyGetProxyConnection)
return result, response, err
}
//UpdateProxyConnection Configure ISE proxy connection settings
/* The following functionalities are impacted by the proxy settings:
Partner Mobile Management
Endpoint Profiler Feed Service Update
Endpoint Posture Update
Endpoint Posture Agent Resources Download
CRL (Certificate Revocation List) Download
SMS Message Transmission
Social Login
Rest Auth Service Azure AD
pxGrid Cloud
*/
func (s *ProxyService) UpdateProxyConnection(requestProxyUpdateProxyConnection *RequestProxyUpdateProxyConnection) (*ResponseProxyUpdateProxyConnection, *resty.Response, error) {
setHost(s.client, "_ui")
path := "/api/v1/system-settings/proxy"
setCSRFToken(s.client)
response, err := s.client.R().
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetBody(requestProxyUpdateProxyConnection).
SetResult(&ResponseProxyUpdateProxyConnection{}).
SetError(&Error).
Put(path)
if err != nil {
if err.Error() == emptyStringToJSONError {
return &ResponseProxyUpdateProxyConnection{}, response, nil
}
return nil, nil, err
}
if response.IsError() {
return nil, response, fmt.Errorf("error with operation UpdateProxyConnection")
}
getCSFRToken(response.Header())
result := response.Result().(*ResponseProxyUpdateProxyConnection)
return result, response, err
}