/* * 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 { ManagedDatabaseMoveOperations } 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 { ManagedDatabaseMoveOperationResult, ManagedDatabaseMoveOperationsListByLocationNextOptionalParams, ManagedDatabaseMoveOperationsListByLocationOptionalParams, ManagedDatabaseMoveOperationsListByLocationResponse, ManagedDatabaseMoveOperationsGetOptionalParams, ManagedDatabaseMoveOperationsGetResponse, ManagedDatabaseMoveOperationsListByLocationNextResponse } from "../models"; /// /** Class containing ManagedDatabaseMoveOperations operations. */ export class ManagedDatabaseMoveOperationsImpl implements ManagedDatabaseMoveOperations { private readonly client: SqlManagementClient; /** * Initialize a new instance of the class ManagedDatabaseMoveOperations class. * @param client Reference to the service client */ constructor(client: SqlManagementClient) { this.client = client; } /** * Lists managed database move operations. * @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 locationName * @param options The options parameters. */ public listByLocation( resourceGroupName: string, locationName: string, options?: ManagedDatabaseMoveOperationsListByLocationOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByLocationPagingAll( resourceGroupName, locationName, 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.listByLocationPagingPage( resourceGroupName, locationName, options, settings ); } }; } private async *listByLocationPagingPage( resourceGroupName: string, locationName: string, options?: ManagedDatabaseMoveOperationsListByLocationOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedDatabaseMoveOperationsListByLocationResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByLocation( resourceGroupName, locationName, options ); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByLocationNext( resourceGroupName, locationName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByLocationPagingAll( resourceGroupName: string, locationName: string, options?: ManagedDatabaseMoveOperationsListByLocationOptionalParams ): AsyncIterableIterator { for await (const page of this.listByLocationPagingPage( resourceGroupName, locationName, options )) { yield* page; } } /** * Lists managed database move operations. * @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 locationName * @param options The options parameters. */ private _listByLocation( resourceGroupName: string, locationName: string, options?: ManagedDatabaseMoveOperationsListByLocationOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, locationName, options }, listByLocationOperationSpec ); } /** * Gets a managed database move operation. * @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 locationName * @param operationId * @param options The options parameters. */ get( resourceGroupName: string, locationName: string, operationId: string, options?: ManagedDatabaseMoveOperationsGetOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, locationName, operationId, options }, getOperationSpec ); } /** * ListByLocationNext * @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 locationName * @param nextLink The nextLink from the previous successful call to the ListByLocation method. * @param options The options parameters. */ private _listByLocationNext( resourceGroupName: string, locationName: string, nextLink: string, options?: ManagedDatabaseMoveOperationsListByLocationNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, locationName, nextLink, options }, listByLocationNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByLocationOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedDatabaseMoveOperationListResult }, default: {} }, queryParameters: [ Parameters.filter1, Parameters.onlyLatestPerDatabase, Parameters.apiVersion8 ], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.locationName ], headerParameters: [Parameters.accept], serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults/{operationId}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedDatabaseMoveOperationResult }, default: {} }, queryParameters: [Parameters.apiVersion8], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.locationName, Parameters.operationId ], headerParameters: [Parameters.accept], serializer }; const listByLocationNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedDatabaseMoveOperationListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, Parameters.locationName ], headerParameters: [Parameters.accept], serializer };