@@ -123,10 +123,12 @@ func (self *BaseClient[A]) Authenticate(credentials Credentials, configTypesOver
123123}
124124
125125// 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
130132
131133 self .Components = * components
132134}
@@ -205,6 +207,13 @@ type ManagementApiClient struct {
205207 BaseClient [ZitiEdgeManagement ]
206208}
207209
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+
208217// NewManagementApiClient will assemble an ManagementApiClient. The apiUrl should be the full URL
209218// to the Edge Management API (e.g. `https://example.com/edge/management/v1`).
210219//
@@ -217,16 +226,25 @@ type ManagementApiClient struct {
217226// to obtain and verify the target controllers CAs. Tools should allow users to verify and accept new controllers
218227// that have not been verified from an outside secret (such as an enrollment token).
219228func 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 {
220238 ret := & ManagementApiClient {}
221239 ret .Schemes = rest_management_api_client .DefaultSchemes
222240 ret .ApiBinding = "edge-management"
223241 ret .ApiVersion = "v1"
224- ret .ApiUrls = apiUrls
225- ret .initializeComponents (apiUrls , caPool )
242+ ret .ApiUrls = config . ApiUrls
243+ ret .initializeComponents (config )
226244
227245 transportPool := NewClientTransportPoolRandom ()
228246
229- for _ , apiUrl := range apiUrls {
247+ for _ , apiUrl := range config . ApiUrls {
230248 newRuntime := NewRuntime (apiUrl , ret .Schemes , ret .Components .HttpClient )
231249 newRuntime .DefaultAuthentication = ret
232250 transportPool .Add (apiUrl , newRuntime )
@@ -235,7 +253,7 @@ func NewManagementApiClient(apiUrls []*url.URL, caPool *x509.CertPool, totpCallb
235253 newApi := rest_management_api_client .New (transportPool , nil )
236254 api := ZitiEdgeManagement {
237255 ZitiEdgeManagement : newApi ,
238- TotpCallback : totpCallback ,
256+ TotpCallback : config . TotpCallback ,
239257 ClientTransportPool : transportPool ,
240258 }
241259
@@ -261,17 +279,26 @@ type ClientApiClient struct {
261279// to obtain and verify the target controllers CAs. Tools should allow users to verify and accept new controllers
262280// that have not been verified from an outside secret (such as an enrollment token).
263281func 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 {
264291 ret := & ClientApiClient {}
265292 ret .ApiBinding = "edge-client"
266293 ret .ApiVersion = "v1"
267294 ret .Schemes = rest_client_api_client .DefaultSchemes
268- ret .ApiUrls = apiUrls
295+ ret .ApiUrls = config . ApiUrls
269296
270- ret .initializeComponents (apiUrls , caPool )
297+ ret .initializeComponents (config )
271298
272299 transportPool := NewClientTransportPoolRandom ()
273300
274- for _ , apiUrl := range apiUrls {
301+ for _ , apiUrl := range config . ApiUrls {
275302 newRuntime := NewRuntime (apiUrl , ret .Schemes , ret .Components .HttpClient )
276303 newRuntime .DefaultAuthentication = ret
277304 transportPool .Add (apiUrl , newRuntime )
@@ -280,7 +307,7 @@ func NewClientApiClient(apiUrls []*url.URL, caPool *x509.CertPool, totpCallback
280307 newApi := rest_client_api_client .New (transportPool , nil )
281308 api := ZitiEdgeClient {
282309 ZitiEdgeClient : newApi ,
283- TotpCallback : totpCallback ,
310+ TotpCallback : config . TotpCallback ,
284311 ClientTransportPool : transportPool ,
285312 }
286313 ret .API = & api
0 commit comments