UNPKG

@azure/arm-mysql-flexible

Version:
148 lines 5.92 kB
/* * 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 { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib"; import { setContinuationToken } from "../pagingHelper"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; /// <reference lib="esnext.asynciterable" /> /** Class containing Replicas operations. */ export class ReplicasImpl { /** * Initialize a new instance of the class Replicas class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * List all the replicas for a given server. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param serverName The name of the server. * @param options The options parameters. */ listByServer(resourceGroupName, serverName, options) { const iter = this.listByServerPagingAll(resourceGroupName, serverName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByServerPagingPage(resourceGroupName, serverName, options, settings); } }; } listByServerPagingPage(resourceGroupName, serverName, options, settings) { return __asyncGenerator(this, arguments, function* listByServerPagingPage_1() { let result; let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken; if (!continuationToken) { result = yield __await(this._listByServer(resourceGroupName, serverName, options)); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield yield __await(page); } while (continuationToken) { result = yield __await(this._listByServerNext(resourceGroupName, serverName, continuationToken, options)); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield yield __await(page); } }); } listByServerPagingAll(resourceGroupName, serverName, options) { return __asyncGenerator(this, arguments, function* listByServerPagingAll_1() { var e_1, _a; try { for (var _b = __asyncValues(this.listByServerPagingPage(resourceGroupName, serverName, options)), _c; _c = yield __await(_b.next()), !_c.done;) { const page = _c.value; yield __await(yield* __asyncDelegator(__asyncValues(page))); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) yield __await(_a.call(_b)); } finally { if (e_1) throw e_1.error; } } }); } /** * List all the replicas for a given server. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param serverName The name of the server. * @param options The options parameters. */ _listByServer(resourceGroupName, serverName, options) { return this.client.sendOperationRequest({ resourceGroupName, serverName, options }, listByServerOperationSpec); } /** * ListByServerNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param serverName The name of the server. * @param nextLink The nextLink from the previous successful call to the ListByServer method. * @param options The options parameters. */ _listByServerNext(resourceGroupName, serverName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, serverName, nextLink, options }, listByServerNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByServerOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMySQL/flexibleServers/{serverName}/replicas", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ServerListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName ], headerParameters: [Parameters.accept], serializer }; const listByServerNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ServerListResult }, default: { bodyMapper: Mappers.CloudError } }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; //# sourceMappingURL=replicas.js.map