/* * 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 { ElasticPoolOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { SqlManagementClient } from "../sqlManagementClient"; import { ElasticPoolOperation, ElasticPoolOperationsListByElasticPoolNextOptionalParams, ElasticPoolOperationsListByElasticPoolOptionalParams, ElasticPoolOperationsListByElasticPoolResponse, ElasticPoolOperationsCancelOptionalParams, ElasticPoolOperationsListByElasticPoolNextResponse } from "../models"; /// /** Class containing ElasticPoolOperations operations. */ export class ElasticPoolOperationsImpl implements ElasticPoolOperations { private readonly client: SqlManagementClient; /** * Initialize a new instance of the class ElasticPoolOperations class. * @param client Reference to the service client */ constructor(client: SqlManagementClient) { this.client = client; } /** * Gets a list of operations performed on the elastic pool. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param serverName The name of the server. * @param elasticPoolName * @param options The options parameters. */ public listByElasticPool( resourceGroupName: string, serverName: string, elasticPoolName: string, options?: ElasticPoolOperationsListByElasticPoolOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByElasticPoolPagingAll( resourceGroupName, serverName, elasticPoolName, 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.listByElasticPoolPagingPage( resourceGroupName, serverName, elasticPoolName, options, settings ); } }; } private async *listByElasticPoolPagingPage( resourceGroupName: string, serverName: string, elasticPoolName: string, options?: ElasticPoolOperationsListByElasticPoolOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ElasticPoolOperationsListByElasticPoolResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByElasticPool( resourceGroupName, serverName, elasticPoolName, options ); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByElasticPoolNext( resourceGroupName, serverName, elasticPoolName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByElasticPoolPagingAll( resourceGroupName: string, serverName: string, elasticPoolName: string, options?: ElasticPoolOperationsListByElasticPoolOptionalParams ): AsyncIterableIterator { for await (const page of this.listByElasticPoolPagingPage( resourceGroupName, serverName, elasticPoolName, options )) { yield* page; } } /** * Cancels the asynchronous operation on the elastic pool. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param serverName The name of the server. * @param elasticPoolName * @param operationId The operation identifier. * @param options The options parameters. */ cancel( resourceGroupName: string, serverName: string, elasticPoolName: string, operationId: string, options?: ElasticPoolOperationsCancelOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, serverName, elasticPoolName, operationId, options }, cancelOperationSpec ); } /** * Gets a list of operations performed on the elastic pool. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param serverName The name of the server. * @param elasticPoolName * @param options The options parameters. */ private _listByElasticPool( resourceGroupName: string, serverName: string, elasticPoolName: string, options?: ElasticPoolOperationsListByElasticPoolOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, serverName, elasticPoolName, options }, listByElasticPoolOperationSpec ); } /** * ListByElasticPoolNext * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param serverName The name of the server. * @param elasticPoolName * @param nextLink The nextLink from the previous successful call to the ListByElasticPool method. * @param options The options parameters. */ private _listByElasticPoolNext( resourceGroupName: string, serverName: string, elasticPoolName: string, nextLink: string, options?: ElasticPoolOperationsListByElasticPoolNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, serverName, elasticPoolName, nextLink, options }, listByElasticPoolNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const cancelOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations/{operationId}/cancel", httpMethod: "POST", responses: { 200: {}, default: {} }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName, Parameters.elasticPoolName, Parameters.operationId ], serializer }; const listByElasticPoolOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/elasticPools/{elasticPoolName}/operations", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ElasticPoolOperationListResult }, default: {} }, queryParameters: [Parameters.apiVersion3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName, Parameters.elasticPoolName ], headerParameters: [Parameters.accept], serializer }; const listByElasticPoolNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ElasticPoolOperationListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName, Parameters.elasticPoolName, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer };