@@ -26,6 +26,7 @@ import { RoleCreateResponse } from "../models/RoleCreateResponse";
2626import { RoleResponse } from "../models/RoleResponse" ;
2727import { RolesResponse } from "../models/RolesResponse" ;
2828import { RolesSort } from "../models/RolesSort" ;
29+ import { RoleTemplateArray } from "../models/RoleTemplateArray" ;
2930import { RoleUpdateRequest } from "../models/RoleUpdateRequest" ;
3031import { RoleUpdateResponse } from "../models/RoleUpdateResponse" ;
3132import { UsersResponse } from "../models/UsersResponse" ;
@@ -420,6 +421,36 @@ export class RolesApiRequestFactory extends BaseAPIRequestFactory {
420421 return requestContext ;
421422 }
422423
424+ public async listRoleTemplates (
425+ _options ?: Configuration
426+ ) : Promise < RequestContext > {
427+ const _config = _options || this . configuration ;
428+
429+ logger . warn ( "Using unstable operation 'listRoleTemplates'" ) ;
430+ if ( ! _config . unstableOperations [ "v2.listRoleTemplates" ] ) {
431+ throw new Error ( "Unstable operation 'listRoleTemplates' is disabled" ) ;
432+ }
433+
434+ // Path Params
435+ const localVarPath = "/api/v2/roles/templates" ;
436+
437+ // Make Request Context
438+ const requestContext = _config
439+ . getServer ( "v2.RolesApi.listRoleTemplates" )
440+ . makeRequestContext ( localVarPath , HttpMethod . GET ) ;
441+ requestContext . setHeaderParam ( "Accept" , "application/json" ) ;
442+ requestContext . setHttpConfig ( _config . httpConfig ) ;
443+
444+ // Apply auth methods
445+ applySecurityAuthentication ( _config , requestContext , [
446+ "apiKeyAuth" ,
447+ "appKeyAuth" ,
448+ "AuthZ" ,
449+ ] ) ;
450+
451+ return requestContext ;
452+ }
453+
423454 public async listRoleUsers (
424455 roleId : string ,
425456 pageSize ?: number ,
@@ -1184,6 +1215,64 @@ export class RolesApiResponseProcessor {
11841215 ) ;
11851216 }
11861217
1218+ /**
1219+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
1220+ * to the expected objects
1221+ *
1222+ * @params response Response returned by the server for a request to listRoleTemplates
1223+ * @throws ApiException if the response code was not in [200, 299]
1224+ */
1225+ public async listRoleTemplates (
1226+ response : ResponseContext
1227+ ) : Promise < RoleTemplateArray > {
1228+ const contentType = ObjectSerializer . normalizeMediaType (
1229+ response . headers [ "content-type" ]
1230+ ) ;
1231+ if ( response . httpStatusCode === 200 ) {
1232+ const body : RoleTemplateArray = ObjectSerializer . deserialize (
1233+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1234+ "RoleTemplateArray"
1235+ ) as RoleTemplateArray ;
1236+ return body ;
1237+ }
1238+ if ( response . httpStatusCode === 429 ) {
1239+ const bodyText = ObjectSerializer . parse (
1240+ await response . body . text ( ) ,
1241+ contentType
1242+ ) ;
1243+ let body : APIErrorResponse ;
1244+ try {
1245+ body = ObjectSerializer . deserialize (
1246+ bodyText ,
1247+ "APIErrorResponse"
1248+ ) as APIErrorResponse ;
1249+ } catch ( error ) {
1250+ logger . debug ( `Got error deserializing error: ${ error } ` ) ;
1251+ throw new ApiException < APIErrorResponse > (
1252+ response . httpStatusCode ,
1253+ bodyText
1254+ ) ;
1255+ }
1256+ throw new ApiException < APIErrorResponse > ( response . httpStatusCode , body ) ;
1257+ }
1258+
1259+ // Work around for missing responses in specification, e.g. for petstore.yaml
1260+ if ( response . httpStatusCode >= 200 && response . httpStatusCode <= 299 ) {
1261+ const body : RoleTemplateArray = ObjectSerializer . deserialize (
1262+ ObjectSerializer . parse ( await response . body . text ( ) , contentType ) ,
1263+ "RoleTemplateArray" ,
1264+ ""
1265+ ) as RoleTemplateArray ;
1266+ return body ;
1267+ }
1268+
1269+ const body = ( await response . body . text ( ) ) || "" ;
1270+ throw new ApiException < string > (
1271+ response . httpStatusCode ,
1272+ 'Unknown API Status Code!\nBody: "' + body + '"'
1273+ ) ;
1274+ }
1275+
11871276 /**
11881277 * Unwraps the actual response sent by the server from the response context and deserializes the response content
11891278 * to the expected objects
@@ -1809,6 +1898,24 @@ export class RolesApi {
18091898 } ) ;
18101899 }
18111900
1901+ /**
1902+ * List all role templates
1903+ * @param param The request object
1904+ */
1905+ public listRoleTemplates (
1906+ options ?: Configuration
1907+ ) : Promise < RoleTemplateArray > {
1908+ const requestContextPromise =
1909+ this . requestFactory . listRoleTemplates ( options ) ;
1910+ return requestContextPromise . then ( ( requestContext ) => {
1911+ return this . configuration . httpApi
1912+ . send ( requestContext )
1913+ . then ( ( responseContext ) => {
1914+ return this . responseProcessor . listRoleTemplates ( responseContext ) ;
1915+ } ) ;
1916+ } ) ;
1917+ }
1918+
18121919 /**
18131920 * Gets all users of a role.
18141921 * @param param The request object
0 commit comments