55import * as utils from "../internal/utils" ;
66import * as operations from "./models/operations" ;
77import * as shared from "./models/shared" ;
8+ import { SDKConfiguration } from "./sdk" ;
89import { AxiosInstance , AxiosRequestConfig , AxiosResponse } from "axios" ;
910
1011/**
1112 * REST APIs for managing ApiEndpoint entities
1213 */
1314export class ApiEndpoints {
14- _defaultClient : AxiosInstance ;
15- _securityClient : AxiosInstance ;
16- _serverURL : string ;
17- _language : string ;
18- _sdkVersion : string ;
19- _genVersion : string ;
20-
21- constructor (
22- defaultClient : AxiosInstance ,
23- securityClient : AxiosInstance ,
24- serverURL : string ,
25- language : string ,
26- sdkVersion : string ,
27- genVersion : string
28- ) {
29- this . _defaultClient = defaultClient ;
30- this . _securityClient = securityClient ;
31- this . _serverURL = serverURL ;
32- this . _language = language ;
33- this . _sdkVersion = sdkVersion ;
34- this . _genVersion = genVersion ;
15+ private sdkConfiguration : SDKConfiguration ;
16+
17+ constructor ( sdkConfig : SDKConfiguration ) {
18+ this . sdkConfiguration = sdkConfig ;
3519 }
3620
3721 /**
@@ -48,20 +32,24 @@ export class ApiEndpoints {
4832 req = new operations . DeleteApiEndpointRequest ( req ) ;
4933 }
5034
51- const baseURL : string = this . _serverURL ;
35+ const baseURL : string = utils . templateUrl (
36+ this . sdkConfiguration . serverURL ,
37+ this . sdkConfiguration . serverDefaults
38+ ) ;
5239 const url : string = utils . generateURL (
5340 baseURL ,
5441 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
5542 req
5643 ) ;
5744
58- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
45+ const client : AxiosInstance =
46+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
5947
6048 const headers = { ...config ?. headers } ;
6149 headers [ "Accept" ] = "application/json" ;
6250 headers [
6351 "user-agent"
64- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
52+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
6553
6654 const httpRes : AxiosResponse = await client . request ( {
6755 validateStatus : ( ) => true ,
@@ -110,20 +98,24 @@ export class ApiEndpoints {
11098 req = new operations . FindApiEndpointRequest ( req ) ;
11199 }
112100
113- const baseURL : string = this . _serverURL ;
101+ const baseURL : string = utils . templateUrl (
102+ this . sdkConfiguration . serverURL ,
103+ this . sdkConfiguration . serverDefaults
104+ ) ;
114105 const url : string = utils . generateURL (
115106 baseURL ,
116107 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/find/{displayName}" ,
117108 req
118109 ) ;
119110
120- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
111+ const client : AxiosInstance =
112+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
121113
122114 const headers = { ...config ?. headers } ;
123115 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
124116 headers [
125117 "user-agent"
126- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
118+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
127119
128120 const httpRes : AxiosResponse = await client . request ( {
129121 validateStatus : ( ) => true ,
@@ -175,20 +167,24 @@ export class ApiEndpoints {
175167 req = new operations . GenerateOpenApiSpecForApiEndpointRequest ( req ) ;
176168 }
177169
178- const baseURL : string = this . _serverURL ;
170+ const baseURL : string = utils . templateUrl (
171+ this . sdkConfiguration . serverURL ,
172+ this . sdkConfiguration . serverDefaults
173+ ) ;
179174 const url : string = utils . generateURL (
180175 baseURL ,
181176 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/openapi" ,
182177 req
183178 ) ;
184179
185- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
180+ const client : AxiosInstance =
181+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
186182
187183 const headers = { ...config ?. headers } ;
188184 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
189185 headers [
190186 "user-agent"
191- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
187+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
192188
193189 const httpRes : AxiosResponse = await client . request ( {
194190 validateStatus : ( ) => true ,
@@ -243,20 +239,24 @@ export class ApiEndpoints {
243239 req = new operations . GeneratePostmanCollectionForApiEndpointRequest ( req ) ;
244240 }
245241
246- const baseURL : string = this . _serverURL ;
242+ const baseURL : string = utils . templateUrl (
243+ this . sdkConfiguration . serverURL ,
244+ this . sdkConfiguration . serverDefaults
245+ ) ;
247246 const url : string = utils . generateURL (
248247 baseURL ,
249248 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/postman" ,
250249 req
251250 ) ;
252251
253- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
252+ const client : AxiosInstance =
253+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
254254
255255 const headers = { ...config ?. headers } ;
256256 headers [ "Accept" ] = "application/json;q=1, application/octet-stream;q=0" ;
257257 headers [
258258 "user-agent"
259- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
259+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
260260
261261 const httpRes : AxiosResponse = await client . request ( {
262262 validateStatus : ( ) => true ,
@@ -308,16 +308,20 @@ export class ApiEndpoints {
308308 req = new operations . GetAllApiEndpointsRequest ( req ) ;
309309 }
310310
311- const baseURL : string = this . _serverURL ;
311+ const baseURL : string = utils . templateUrl (
312+ this . sdkConfiguration . serverURL ,
313+ this . sdkConfiguration . serverDefaults
314+ ) ;
312315 const url : string = utils . generateURL ( baseURL , "/v1/apis/{apiID}/api_endpoints" , req ) ;
313316
314- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
317+ const client : AxiosInstance =
318+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
315319
316320 const headers = { ...config ?. headers } ;
317321 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
318322 headers [
319323 "user-agent"
320- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
324+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
321325
322326 const httpRes : AxiosResponse = await client . request ( {
323327 validateStatus : ( ) => true ,
@@ -372,20 +376,24 @@ export class ApiEndpoints {
372376 req = new operations . GetAllForVersionApiEndpointsRequest ( req ) ;
373377 }
374378
375- const baseURL : string = this . _serverURL ;
379+ const baseURL : string = utils . templateUrl (
380+ this . sdkConfiguration . serverURL ,
381+ this . sdkConfiguration . serverDefaults
382+ ) ;
376383 const url : string = utils . generateURL (
377384 baseURL ,
378385 "/v1/apis/{apiID}/version/{versionID}/api_endpoints" ,
379386 req
380387 ) ;
381388
382- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
389+ const client : AxiosInstance =
390+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
383391
384392 const headers = { ...config ?. headers } ;
385393 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
386394 headers [
387395 "user-agent"
388- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
396+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
389397
390398 const httpRes : AxiosResponse = await client . request ( {
391399 validateStatus : ( ) => true ,
@@ -440,20 +448,24 @@ export class ApiEndpoints {
440448 req = new operations . GetApiEndpointRequest ( req ) ;
441449 }
442450
443- const baseURL : string = this . _serverURL ;
451+ const baseURL : string = utils . templateUrl (
452+ this . sdkConfiguration . serverURL ,
453+ this . sdkConfiguration . serverDefaults
454+ ) ;
444455 const url : string = utils . generateURL (
445456 baseURL ,
446457 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
447458 req
448459 ) ;
449460
450- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
461+ const client : AxiosInstance =
462+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
451463
452464 const headers = { ...config ?. headers } ;
453465 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
454466 headers [
455467 "user-agent"
456- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
468+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
457469
458470 const httpRes : AxiosResponse = await client . request ( {
459471 validateStatus : ( ) => true ,
@@ -504,7 +516,10 @@ export class ApiEndpoints {
504516 req = new operations . UpsertApiEndpointRequest ( req ) ;
505517 }
506518
507- const baseURL : string = this . _serverURL ;
519+ const baseURL : string = utils . templateUrl (
520+ this . sdkConfiguration . serverURL ,
521+ this . sdkConfiguration . serverDefaults
522+ ) ;
508523 const url : string = utils . generateURL (
509524 baseURL ,
510525 "/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
@@ -521,15 +536,16 @@ export class ApiEndpoints {
521536 }
522537 }
523538
524- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
539+ const client : AxiosInstance =
540+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
525541
526542 const headers = { ...reqBodyHeaders , ...config ?. headers } ;
527543 if ( reqBody == null || Object . keys ( reqBody ) . length === 0 )
528544 throw new Error ( "request body is required" ) ;
529545 headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
530546 headers [
531547 "user-agent"
532- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
548+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
533549
534550 const httpRes : AxiosResponse = await client . request ( {
535551 validateStatus : ( ) => true ,
0 commit comments