/* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { setContinuationToken } from "../pagingHelper"; import { RoleAssignmentSchedules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleAssignmentSchedule, RoleAssignmentSchedulesListForScopeNextOptionalParams, RoleAssignmentSchedulesListForScopeOptionalParams, RoleAssignmentSchedulesListForScopeResponse, RoleAssignmentSchedulesGetOptionalParams, RoleAssignmentSchedulesGetResponse, RoleAssignmentSchedulesListForScopeNextResponse } from "../models"; /// /** Class containing RoleAssignmentSchedules operations. */ export class RoleAssignmentSchedulesImpl implements RoleAssignmentSchedules { private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleAssignmentSchedules class. * @param client Reference to the service client */ constructor(client: AuthorizationManagementClient) { this.client = client; } /** * Gets role assignment schedules for a resource scope. * @param scope The scope of the role assignments schedules. * @param options The options parameters. */ public listForScope( scope: string, options?: RoleAssignmentSchedulesListForScopeOptionalParams ): PagedAsyncIterableIterator { const iter = this.listForScopePagingAll(scope, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings?: PageSettings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, options?: RoleAssignmentSchedulesListForScopeOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: RoleAssignmentSchedulesListForScopeResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listForScope(scope, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listForScopePagingAll( scope: string, options?: RoleAssignmentSchedulesListForScopeOptionalParams ): AsyncIterableIterator { for await (const page of this.listForScopePagingPage(scope, options)) { yield* page; } } /** * Get the specified role assignment schedule for a resource scope * @param scope The scope of the role assignment schedule. * @param roleAssignmentScheduleName The name (guid) of the role assignment schedule to get. * @param options The options parameters. */ get( scope: string, roleAssignmentScheduleName: string, options?: RoleAssignmentSchedulesGetOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, roleAssignmentScheduleName, options }, getOperationSpec ); } /** * Gets role assignment schedules for a resource scope. * @param scope The scope of the role assignments schedules. * @param options The options parameters. */ private _listForScope( scope: string, options?: RoleAssignmentSchedulesListForScopeOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, options }, listForScopeOperationSpec ); } /** * ListForScopeNext * @param scope The scope of the role assignments schedules. * @param nextLink The nextLink from the previous successful call to the ListForScope method. * @param options The options parameters. */ private _listForScopeNext( scope: string, nextLink: string, options?: RoleAssignmentSchedulesListForScopeNextOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, nextLink, options }, listForScopeNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const getOperationSpec: coreClient.OperationSpec = { path: "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleAssignmentSchedule }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion2], urlParameters: [ Parameters.$host, Parameters.scope, Parameters.roleAssignmentScheduleName ], headerParameters: [Parameters.accept], serializer }; const listForScopeOperationSpec: coreClient.OperationSpec = { path: "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleAssignmentScheduleListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.filter, Parameters.apiVersion2], urlParameters: [Parameters.$host, Parameters.scope], headerParameters: [Parameters.accept], serializer }; const listForScopeNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleAssignmentScheduleListResult }, default: { bodyMapper: Mappers.CloudError } }, urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], headerParameters: [Parameters.accept], serializer };