/* * 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 { RoleEligibilityScheduleInstances } 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 { RoleEligibilityScheduleInstance, RoleEligibilityScheduleInstancesListForScopeNextOptionalParams, RoleEligibilityScheduleInstancesListForScopeOptionalParams, RoleEligibilityScheduleInstancesListForScopeResponse, RoleEligibilityScheduleInstancesGetOptionalParams, RoleEligibilityScheduleInstancesGetResponse, RoleEligibilityScheduleInstancesListForScopeNextResponse } from "../models"; /// /** Class containing RoleEligibilityScheduleInstances operations. */ export class RoleEligibilityScheduleInstancesImpl implements RoleEligibilityScheduleInstances { private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleEligibilityScheduleInstances class. * @param client Reference to the service client */ constructor(client: AuthorizationManagementClient) { this.client = client; } /** * Gets role eligibility schedule instances of a role eligibility schedule. * @param scope The scope of the role eligibility schedule. * @param options The options parameters. */ public listForScope( scope: string, options?: RoleEligibilityScheduleInstancesListForScopeOptionalParams ): 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?: RoleEligibilityScheduleInstancesListForScopeOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: RoleEligibilityScheduleInstancesListForScopeResponse; 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?: RoleEligibilityScheduleInstancesListForScopeOptionalParams ): AsyncIterableIterator { for await (const page of this.listForScopePagingPage(scope, options)) { yield* page; } } /** * Gets role eligibility schedule instances of a role eligibility schedule. * @param scope The scope of the role eligibility schedule. * @param options The options parameters. */ private _listForScope( scope: string, options?: RoleEligibilityScheduleInstancesListForScopeOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, options }, listForScopeOperationSpec ); } /** * Gets the specified role eligibility schedule instance. * @param scope The scope of the role eligibility schedules. * @param roleEligibilityScheduleInstanceName The name (hash of schedule name + time) of the role * eligibility schedule to get. * @param options The options parameters. */ get( scope: string, roleEligibilityScheduleInstanceName: string, options?: RoleEligibilityScheduleInstancesGetOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, roleEligibilityScheduleInstanceName, options }, getOperationSpec ); } /** * ListForScopeNext * @param scope The scope of the role eligibility schedule. * @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?: RoleEligibilityScheduleInstancesListForScopeNextOptionalParams ): Promise { return this.client.sendOperationRequest( { scope, nextLink, options }, listForScopeNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listForScopeOperationSpec: coreClient.OperationSpec = { path: "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleEligibilityScheduleInstanceListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.filter, Parameters.apiVersion2], urlParameters: [Parameters.$host, Parameters.scope], headerParameters: [Parameters.accept], serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleEligibilityScheduleInstance }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion2], urlParameters: [ Parameters.$host, Parameters.scope, Parameters.roleEligibilityScheduleInstanceName ], headerParameters: [Parameters.accept], serializer }; const listForScopeNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleEligibilityScheduleInstanceListResult }, default: { bodyMapper: Mappers.CloudError } }, urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], headerParameters: [Parameters.accept], serializer };