@@ -123,10 +123,12 @@ func (self *BaseClient[A]) Authenticate(credentials Credentials, configTypesOver
123
123
}
124
124
125
125
// initializeComponents assembles the lower level components necessary for the go-swagger/openapi facilities.
126
- func (self * BaseClient [A ]) initializeComponents (apiUrls []* url.URL , caPool * x509.CertPool ) {
127
- components := NewComponents ()
128
- components .HttpTransport .TLSClientConfig .RootCAs = caPool
129
- components .CaPool = caPool
126
+ func (self * BaseClient [A ]) initializeComponents (config * ApiClientConfig ) {
127
+ components := NewComponentsWithConfig (& ComponentsConfig {
128
+ Proxy : config .Proxy ,
129
+ })
130
+ components .HttpTransport .TLSClientConfig .RootCAs = config .CaPool
131
+ components .CaPool = config .CaPool
130
132
131
133
self .Components = * components
132
134
}
@@ -205,6 +207,13 @@ type ManagementApiClient struct {
205
207
BaseClient [ZitiEdgeManagement ]
206
208
}
207
209
210
+ type ApiClientConfig struct {
211
+ ApiUrls []* url.URL
212
+ CaPool * x509.CertPool
213
+ TotpCallback func (chan string )
214
+ Proxy func (r * http.Request ) (* url.URL , error )
215
+ }
216
+
208
217
// NewManagementApiClient will assemble an ManagementApiClient. The apiUrl should be the full URL
209
218
// to the Edge Management API (e.g. `https://example.com/edge/management/v1`).
210
219
//
@@ -217,16 +226,25 @@ type ManagementApiClient struct {
217
226
// to obtain and verify the target controllers CAs. Tools should allow users to verify and accept new controllers
218
227
// that have not been verified from an outside secret (such as an enrollment token).
219
228
func NewManagementApiClient (apiUrls []* url.URL , caPool * x509.CertPool , totpCallback func (chan string )) * ManagementApiClient {
229
+ return NewManagementApiClientWithConfig (& ApiClientConfig {
230
+ ApiUrls : apiUrls ,
231
+ CaPool : caPool ,
232
+ TotpCallback : totpCallback ,
233
+ Proxy : http .ProxyFromEnvironment ,
234
+ })
235
+ }
236
+
237
+ func NewManagementApiClientWithConfig (config * ApiClientConfig ) * ManagementApiClient {
220
238
ret := & ManagementApiClient {}
221
239
ret .Schemes = rest_management_api_client .DefaultSchemes
222
240
ret .ApiBinding = "edge-management"
223
241
ret .ApiVersion = "v1"
224
- ret .ApiUrls = apiUrls
225
- ret .initializeComponents (apiUrls , caPool )
242
+ ret .ApiUrls = config . ApiUrls
243
+ ret .initializeComponents (config )
226
244
227
245
transportPool := NewClientTransportPoolRandom ()
228
246
229
- for _ , apiUrl := range apiUrls {
247
+ for _ , apiUrl := range config . ApiUrls {
230
248
newRuntime := NewRuntime (apiUrl , ret .Schemes , ret .Components .HttpClient )
231
249
newRuntime .DefaultAuthentication = ret
232
250
transportPool .Add (apiUrl , newRuntime )
@@ -235,7 +253,7 @@ func NewManagementApiClient(apiUrls []*url.URL, caPool *x509.CertPool, totpCallb
235
253
newApi := rest_management_api_client .New (transportPool , nil )
236
254
api := ZitiEdgeManagement {
237
255
ZitiEdgeManagement : newApi ,
238
- TotpCallback : totpCallback ,
256
+ TotpCallback : config . TotpCallback ,
239
257
ClientTransportPool : transportPool ,
240
258
}
241
259
@@ -261,17 +279,26 @@ type ClientApiClient struct {
261
279
// to obtain and verify the target controllers CAs. Tools should allow users to verify and accept new controllers
262
280
// that have not been verified from an outside secret (such as an enrollment token).
263
281
func NewClientApiClient (apiUrls []* url.URL , caPool * x509.CertPool , totpCallback func (chan string )) * ClientApiClient {
282
+ return NewClientApiClientWithConfig (& ApiClientConfig {
283
+ ApiUrls : apiUrls ,
284
+ CaPool : caPool ,
285
+ TotpCallback : totpCallback ,
286
+ Proxy : http .ProxyFromEnvironment ,
287
+ })
288
+ }
289
+
290
+ func NewClientApiClientWithConfig (config * ApiClientConfig ) * ClientApiClient {
264
291
ret := & ClientApiClient {}
265
292
ret .ApiBinding = "edge-client"
266
293
ret .ApiVersion = "v1"
267
294
ret .Schemes = rest_client_api_client .DefaultSchemes
268
- ret .ApiUrls = apiUrls
295
+ ret .ApiUrls = config . ApiUrls
269
296
270
- ret .initializeComponents (apiUrls , caPool )
297
+ ret .initializeComponents (config )
271
298
272
299
transportPool := NewClientTransportPoolRandom ()
273
300
274
- for _ , apiUrl := range apiUrls {
301
+ for _ , apiUrl := range config . ApiUrls {
275
302
newRuntime := NewRuntime (apiUrl , ret .Schemes , ret .Components .HttpClient )
276
303
newRuntime .DefaultAuthentication = ret
277
304
transportPool .Add (apiUrl , newRuntime )
@@ -280,7 +307,7 @@ func NewClientApiClient(apiUrls []*url.URL, caPool *x509.CertPool, totpCallback
280
307
newApi := rest_client_api_client .New (transportPool , nil )
281
308
api := ZitiEdgeClient {
282
309
ZitiEdgeClient : newApi ,
283
- TotpCallback : totpCallback ,
310
+ TotpCallback : config . TotpCallback ,
284
311
ClientTransportPool : transportPool ,
285
312
}
286
313
ret .API = & api
0 commit comments