5
5
import * as utils from "../internal/utils" ;
6
6
import * as operations from "./models/operations" ;
7
7
import * as shared from "./models/shared" ;
8
+ import { SDKConfiguration } from "./sdk" ;
8
9
import { AxiosInstance , AxiosRequestConfig , AxiosResponse } from "axios" ;
9
10
10
11
/**
11
12
* REST APIs for managing ApiEndpoint entities
12
13
*/
13
14
export 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 ;
35
19
}
36
20
37
21
/**
@@ -48,20 +32,24 @@ export class ApiEndpoints {
48
32
req = new operations . DeleteApiEndpointRequest ( req ) ;
49
33
}
50
34
51
- const baseURL : string = this . _serverURL ;
35
+ const baseURL : string = utils . templateUrl (
36
+ this . sdkConfiguration . serverURL ,
37
+ this . sdkConfiguration . serverDefaults
38
+ ) ;
52
39
const url : string = utils . generateURL (
53
40
baseURL ,
54
41
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
55
42
req
56
43
) ;
57
44
58
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
45
+ const client : AxiosInstance =
46
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
59
47
60
48
const headers = { ...config ?. headers } ;
61
49
headers [ "Accept" ] = "application/json" ;
62
50
headers [
63
51
"user-agent"
64
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
52
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
65
53
66
54
const httpRes : AxiosResponse = await client . request ( {
67
55
validateStatus : ( ) => true ,
@@ -110,20 +98,24 @@ export class ApiEndpoints {
110
98
req = new operations . FindApiEndpointRequest ( req ) ;
111
99
}
112
100
113
- const baseURL : string = this . _serverURL ;
101
+ const baseURL : string = utils . templateUrl (
102
+ this . sdkConfiguration . serverURL ,
103
+ this . sdkConfiguration . serverDefaults
104
+ ) ;
114
105
const url : string = utils . generateURL (
115
106
baseURL ,
116
107
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/find/{displayName}" ,
117
108
req
118
109
) ;
119
110
120
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
111
+ const client : AxiosInstance =
112
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
121
113
122
114
const headers = { ...config ?. headers } ;
123
115
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
124
116
headers [
125
117
"user-agent"
126
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
118
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
127
119
128
120
const httpRes : AxiosResponse = await client . request ( {
129
121
validateStatus : ( ) => true ,
@@ -175,20 +167,24 @@ export class ApiEndpoints {
175
167
req = new operations . GenerateOpenApiSpecForApiEndpointRequest ( req ) ;
176
168
}
177
169
178
- const baseURL : string = this . _serverURL ;
170
+ const baseURL : string = utils . templateUrl (
171
+ this . sdkConfiguration . serverURL ,
172
+ this . sdkConfiguration . serverDefaults
173
+ ) ;
179
174
const url : string = utils . generateURL (
180
175
baseURL ,
181
176
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/openapi" ,
182
177
req
183
178
) ;
184
179
185
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
180
+ const client : AxiosInstance =
181
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
186
182
187
183
const headers = { ...config ?. headers } ;
188
184
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
189
185
headers [
190
186
"user-agent"
191
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
187
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
192
188
193
189
const httpRes : AxiosResponse = await client . request ( {
194
190
validateStatus : ( ) => true ,
@@ -243,20 +239,24 @@ export class ApiEndpoints {
243
239
req = new operations . GeneratePostmanCollectionForApiEndpointRequest ( req ) ;
244
240
}
245
241
246
- const baseURL : string = this . _serverURL ;
242
+ const baseURL : string = utils . templateUrl (
243
+ this . sdkConfiguration . serverURL ,
244
+ this . sdkConfiguration . serverDefaults
245
+ ) ;
247
246
const url : string = utils . generateURL (
248
247
baseURL ,
249
248
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}/generate/postman" ,
250
249
req
251
250
) ;
252
251
253
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
252
+ const client : AxiosInstance =
253
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
254
254
255
255
const headers = { ...config ?. headers } ;
256
256
headers [ "Accept" ] = "application/json;q=1, application/octet-stream;q=0" ;
257
257
headers [
258
258
"user-agent"
259
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
259
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
260
260
261
261
const httpRes : AxiosResponse = await client . request ( {
262
262
validateStatus : ( ) => true ,
@@ -308,16 +308,20 @@ export class ApiEndpoints {
308
308
req = new operations . GetAllApiEndpointsRequest ( req ) ;
309
309
}
310
310
311
- const baseURL : string = this . _serverURL ;
311
+ const baseURL : string = utils . templateUrl (
312
+ this . sdkConfiguration . serverURL ,
313
+ this . sdkConfiguration . serverDefaults
314
+ ) ;
312
315
const url : string = utils . generateURL ( baseURL , "/v1/apis/{apiID}/api_endpoints" , req ) ;
313
316
314
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
317
+ const client : AxiosInstance =
318
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
315
319
316
320
const headers = { ...config ?. headers } ;
317
321
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
318
322
headers [
319
323
"user-agent"
320
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
324
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
321
325
322
326
const httpRes : AxiosResponse = await client . request ( {
323
327
validateStatus : ( ) => true ,
@@ -372,20 +376,24 @@ export class ApiEndpoints {
372
376
req = new operations . GetAllForVersionApiEndpointsRequest ( req ) ;
373
377
}
374
378
375
- const baseURL : string = this . _serverURL ;
379
+ const baseURL : string = utils . templateUrl (
380
+ this . sdkConfiguration . serverURL ,
381
+ this . sdkConfiguration . serverDefaults
382
+ ) ;
376
383
const url : string = utils . generateURL (
377
384
baseURL ,
378
385
"/v1/apis/{apiID}/version/{versionID}/api_endpoints" ,
379
386
req
380
387
) ;
381
388
382
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
389
+ const client : AxiosInstance =
390
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
383
391
384
392
const headers = { ...config ?. headers } ;
385
393
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
386
394
headers [
387
395
"user-agent"
388
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
396
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
389
397
390
398
const httpRes : AxiosResponse = await client . request ( {
391
399
validateStatus : ( ) => true ,
@@ -440,20 +448,24 @@ export class ApiEndpoints {
440
448
req = new operations . GetApiEndpointRequest ( req ) ;
441
449
}
442
450
443
- const baseURL : string = this . _serverURL ;
451
+ const baseURL : string = utils . templateUrl (
452
+ this . sdkConfiguration . serverURL ,
453
+ this . sdkConfiguration . serverDefaults
454
+ ) ;
444
455
const url : string = utils . generateURL (
445
456
baseURL ,
446
457
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
447
458
req
448
459
) ;
449
460
450
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
461
+ const client : AxiosInstance =
462
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
451
463
452
464
const headers = { ...config ?. headers } ;
453
465
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
454
466
headers [
455
467
"user-agent"
456
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
468
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
457
469
458
470
const httpRes : AxiosResponse = await client . request ( {
459
471
validateStatus : ( ) => true ,
@@ -504,7 +516,10 @@ export class ApiEndpoints {
504
516
req = new operations . UpsertApiEndpointRequest ( req ) ;
505
517
}
506
518
507
- const baseURL : string = this . _serverURL ;
519
+ const baseURL : string = utils . templateUrl (
520
+ this . sdkConfiguration . serverURL ,
521
+ this . sdkConfiguration . serverDefaults
522
+ ) ;
508
523
const url : string = utils . generateURL (
509
524
baseURL ,
510
525
"/v1/apis/{apiID}/version/{versionID}/api_endpoints/{apiEndpointID}" ,
@@ -521,15 +536,16 @@ export class ApiEndpoints {
521
536
}
522
537
}
523
538
524
- const client : AxiosInstance = this . _securityClient || this . _defaultClient ;
539
+ const client : AxiosInstance =
540
+ this . sdkConfiguration . securityClient || this . sdkConfiguration . defaultClient ;
525
541
526
542
const headers = { ...reqBodyHeaders , ...config ?. headers } ;
527
543
if ( reqBody == null || Object . keys ( reqBody ) . length === 0 )
528
544
throw new Error ( "request body is required" ) ;
529
545
headers [ "Accept" ] = "application/json;q=1, application/json;q=0" ;
530
546
headers [
531
547
"user-agent"
532
- ] = `speakeasy-sdk/${ this . _language } ${ this . _sdkVersion } ${ this . _genVersion } ` ;
548
+ ] = `speakeasy-sdk/${ this . sdkConfiguration . language } ${ this . sdkConfiguration . sdkVersion } ${ this . sdkConfiguration . genVersion } ` ;
533
549
534
550
const httpRes : AxiosResponse = await client . request ( {
535
551
validateStatus : ( ) => true ,
0 commit comments