@@ -32,6 +32,7 @@ import { RoleCreateResponse } from "./models/RoleCreateResponse";
32
32
import { RoleResponse } from "./models/RoleResponse" ;
33
33
import { RolesResponse } from "./models/RolesResponse" ;
34
34
import { RolesSort } from "./models/RolesSort" ;
35
+ import { RoleTemplateArray } from "./models/RoleTemplateArray" ;
35
36
import { RoleUpdateRequest } from "./models/RoleUpdateRequest" ;
36
37
import { RoleUpdateResponse } from "./models/RoleUpdateResponse" ;
37
38
import { UsersResponse } from "./models/UsersResponse" ;
@@ -526,6 +527,48 @@ export class RolesApiRequestFactory extends BaseAPIRequestFactory {
526
527
return requestContext ;
527
528
}
528
529
530
+ public async listRoleTemplates (
531
+ _options ?: Configuration ,
532
+ ) : Promise < RequestContext > {
533
+ const _config = _options || this . configuration ;
534
+
535
+ if ( ! _config . unstableOperations [ "RolesApi.v2.listRoleTemplates" ] ) {
536
+ throw new Error (
537
+ "Unstable operation 'listRoleTemplates' is disabled. Enable it by setting `configuration.unstableOperations['RolesApi.v2.listRoleTemplates'] = true`" ,
538
+ ) ;
539
+ }
540
+
541
+ // Path Params
542
+ const localVarPath = "/api/v2/roles/templates" ;
543
+
544
+ // Make Request Context
545
+ const { server, overrides } = _config . getServerAndOverrides (
546
+ "RolesApi.v2.listRoleTemplates" ,
547
+ RolesApi . operationServers ,
548
+ ) ;
549
+ const requestContext = server . makeRequestContext (
550
+ localVarPath ,
551
+ HttpMethod . GET ,
552
+ overrides ,
553
+ ) ;
554
+ requestContext . setHeaderParam ( "Accept" , "application/json" ) ;
555
+ requestContext . setHttpConfig ( _config . httpConfig ) ;
556
+
557
+ // Set User-Agent
558
+ if ( this . userAgent ) {
559
+ requestContext . setHeaderParam ( "User-Agent" , this . userAgent ) ;
560
+ }
561
+
562
+ // Apply auth methods
563
+ applySecurityAuthentication ( _config , requestContext , [
564
+ "apiKeyAuth" ,
565
+ "appKeyAuth" ,
566
+ "AuthZ" ,
567
+ ] ) ;
568
+
569
+ return requestContext ;
570
+ }
571
+
529
572
public async listRoleUsers (
530
573
roleId : string ,
531
574
pageSize ?: number ,
@@ -1308,6 +1351,62 @@ export class RolesApiResponseProcessor {
1308
1351
) ;
1309
1352
}
1310
1353
1354
+ /**
1355
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
1356
+ * to the expected objects
1357
+ *
1358
+ * @params response Response returned by the server for a request to listRoleTemplates
1359
+ * @throws ApiException if the response code was not in [200, 299]
1360
+ */
1361
+ public async listRoleTemplates (
1362
+ response : ResponseContext ,
1363
+ ) : Promise < RoleTemplateArray > {
1364
+ const contentType = normalizeMediaType ( response . headers [ "content-type" ] ) ;
1365
+ if ( response . httpStatusCode === 200 ) {
1366
+ const body : RoleTemplateArray = deserialize (
1367
+ parse ( await response . body . text ( ) , contentType ) ,
1368
+ TypingInfo ,
1369
+ "RoleTemplateArray" ,
1370
+ ) as RoleTemplateArray ;
1371
+ return body ;
1372
+ }
1373
+ if ( response . httpStatusCode === 429 ) {
1374
+ const bodyText = parse ( await response . body . text ( ) , contentType ) ;
1375
+ let body : APIErrorResponse ;
1376
+ try {
1377
+ body = deserialize (
1378
+ bodyText ,
1379
+ TypingInfo ,
1380
+ "APIErrorResponse" ,
1381
+ ) as APIErrorResponse ;
1382
+ } catch ( error ) {
1383
+ logger . debug ( `Got error deserializing error: ${ error } ` ) ;
1384
+ throw new ApiException < APIErrorResponse > (
1385
+ response . httpStatusCode ,
1386
+ bodyText ,
1387
+ ) ;
1388
+ }
1389
+ throw new ApiException < APIErrorResponse > ( response . httpStatusCode , body ) ;
1390
+ }
1391
+
1392
+ // Work around for missing responses in specification, e.g. for petstore.yaml
1393
+ if ( response . httpStatusCode >= 200 && response . httpStatusCode <= 299 ) {
1394
+ const body : RoleTemplateArray = deserialize (
1395
+ parse ( await response . body . text ( ) , contentType ) ,
1396
+ TypingInfo ,
1397
+ "RoleTemplateArray" ,
1398
+ "" ,
1399
+ ) as RoleTemplateArray ;
1400
+ return body ;
1401
+ }
1402
+
1403
+ const body = ( await response . body . text ( ) ) || "" ;
1404
+ throw new ApiException < string > (
1405
+ response . httpStatusCode ,
1406
+ 'Unknown API Status Code!\nBody: "' + body + '"' ,
1407
+ ) ;
1408
+ }
1409
+
1311
1410
/**
1312
1411
* Unwraps the actual response sent by the server from the response context and deserializes the response content
1313
1412
* to the expected objects
@@ -1927,6 +2026,24 @@ export class RolesApi {
1927
2026
} ) ;
1928
2027
}
1929
2028
2029
+ /**
2030
+ * List all role templates
2031
+ * @param param The request object
2032
+ */
2033
+ public listRoleTemplates (
2034
+ options ?: Configuration ,
2035
+ ) : Promise < RoleTemplateArray > {
2036
+ const requestContextPromise =
2037
+ this . requestFactory . listRoleTemplates ( options ) ;
2038
+ return requestContextPromise . then ( ( requestContext ) => {
2039
+ return this . configuration . httpApi
2040
+ . send ( requestContext )
2041
+ . then ( ( responseContext ) => {
2042
+ return this . responseProcessor . listRoleTemplates ( responseContext ) ;
2043
+ } ) ;
2044
+ } ) ;
2045
+ }
2046
+
1930
2047
/**
1931
2048
* Gets all users of a role.
1932
2049
* @param param The request object
0 commit comments