UNPKG

@azure/arm-compute

Version:
262 lines 10.9 kB
"use strict"; /* * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CloudServicesUpdateDomainImpl = void 0; const tslib_1 = require("tslib"); const pagingHelper_js_1 = require("../pagingHelper.js"); const coreClient = tslib_1.__importStar(require("@azure/core-client")); const Mappers = tslib_1.__importStar(require("../models/mappers.js")); const Parameters = tslib_1.__importStar(require("../models/parameters.js")); const core_lro_1 = require("@azure/core-lro"); const lroImpl_js_1 = require("../lroImpl.js"); /// <reference lib="esnext.asynciterable" /> /** Class containing CloudServicesUpdateDomain operations. */ class CloudServicesUpdateDomainImpl { client; /** * Initialize a new instance of the class CloudServicesUpdateDomain class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets a list of all update domains in a cloud service. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ listUpdateDomains(resourceGroupName, cloudServiceName, options) { const iter = this.listUpdateDomainsPagingAll(resourceGroupName, cloudServiceName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options, settings); }, }; } async *listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listUpdateDomains(resourceGroupName, cloudServiceName, options); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listUpdateDomainsNext(resourceGroupName, cloudServiceName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listUpdateDomainsPagingAll(resourceGroupName, cloudServiceName, options) { for await (const page of this.listUpdateDomainsPagingPage(resourceGroupName, cloudServiceName, options)) { yield* page; } } /** * Updates the role instances in the specified update domain. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param updateDomain Specifies an integer value that identifies the update domain. Update domains are * identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of * 1, and so on. * @param options The options parameters. */ async beginWalkUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { currentRawResponse = rawResponse; providedCallback?.(rawResponse, flatResponse); }; const updatedArgs = { ...args, options: { ...args.options, onResponse: callback, }, }; const flatResponse = await directSendOperation(updatedArgs, spec); return { flatResponse, rawResponse: { statusCode: currentRawResponse.status, body: currentRawResponse.parsedBody, headers: currentRawResponse.headers.toJSON(), }, }; }; const lro = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, cloudServiceName, updateDomain, options }, spec: walkUpdateDomainOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * Updates the role instances in the specified update domain. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param updateDomain Specifies an integer value that identifies the update domain. Update domains are * identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of * 1, and so on. * @param options The options parameters. */ async beginWalkUpdateDomainAndWait(resourceGroupName, cloudServiceName, updateDomain, options) { const poller = await this.beginWalkUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options); return poller.pollUntilDone(); } /** * Gets the specified update domain of a cloud service. Use nextLink property in the response to get * the next page of update domains. Do this till nextLink is null to fetch all the update domains. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param updateDomain Specifies an integer value that identifies the update domain. Update domains are * identified with a zero-based index: the first update domain has an ID of 0, the second has an ID of * 1, and so on. * @param options The options parameters. */ getUpdateDomain(resourceGroupName, cloudServiceName, updateDomain, options) { return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, updateDomain, options }, getUpdateDomainOperationSpec); } /** * Gets a list of all update domains in a cloud service. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ _listUpdateDomains(resourceGroupName, cloudServiceName, options) { return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, options }, listUpdateDomainsOperationSpec); } /** * ListUpdateDomainsNext * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param nextLink The nextLink from the previous successful call to the ListUpdateDomains method. * @param options The options parameters. */ _listUpdateDomainsNext(resourceGroupName, cloudServiceName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, nextLink, options }, listUpdateDomainsNextOperationSpec); } } exports.CloudServicesUpdateDomainImpl = CloudServicesUpdateDomainImpl; // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const walkUpdateDomainOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", httpMethod: "PUT", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters39, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, Parameters.updateDomain, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const getUpdateDomainOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains/{updateDomain}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.UpdateDomain, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, Parameters.updateDomain, ], headerParameters: [Parameters.accept], serializer, }; const listUpdateDomainsOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/updateDomains", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.UpdateDomainListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const listUpdateDomainsNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.UpdateDomainListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=cloudServicesUpdateDomain.js.map