UNPKG

@azure/arm-compute

Version:
1,146 lines 83.1 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { setContinuationToken } from "../pagingHelper.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; import { createHttpPoller } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing VirtualMachineScaleSets operations. */ export class VirtualMachineScaleSetsImpl { client; /** * Initialize a new instance of the class VirtualMachineScaleSets class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets all the VM scale sets under the specified subscription for the specified location. * @param location The name of Azure region. * @param options The options parameters. */ listByLocation(location, options) { const iter = this.listByLocationPagingAll(location, 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.listByLocationPagingPage(location, options, settings); }, }; } async *listByLocationPagingPage(location, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByLocation(location, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByLocationNext(location, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByLocationPagingAll(location, options) { for await (const page of this.listByLocationPagingPage(location, options)) { yield* page; } } /** * Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. * Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink * is null to fetch all the VM Scale Sets. * @param options The options parameters. */ listAll(options) { const iter = this.listAllPagingAll(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.listAllPagingPage(options, settings); }, }; } async *listAllPagingPage(options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listAll(options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listAllPagingAll(options) { for await (const page of this.listAllPagingPage(options)) { yield* page; } } /** * Gets a list of all VM scale sets under a resource group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ list(resourceGroupName, options) { const iter = this.listPagingAll(resourceGroupName, 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.listPagingPage(resourceGroupName, options, settings); }, }; } async *listPagingPage(resourceGroupName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._list(resourceGroupName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listNext(resourceGroupName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listPagingAll(resourceGroupName, options) { for await (const page of this.listPagingPage(resourceGroupName, options)) { yield* page; } } /** * Gets list of OS upgrades on a VM scale set instance. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ listOSUpgradeHistory(resourceGroupName, vmScaleSetName, options) { const iter = this.getOSUpgradeHistoryPagingAll(resourceGroupName, vmScaleSetName, 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.getOSUpgradeHistoryPagingPage(resourceGroupName, vmScaleSetName, options, settings); }, }; } async *getOSUpgradeHistoryPagingPage(resourceGroupName, vmScaleSetName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._getOSUpgradeHistory(resourceGroupName, vmScaleSetName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._getOSUpgradeHistoryNext(resourceGroupName, vmScaleSetName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *getOSUpgradeHistoryPagingAll(resourceGroupName, vmScaleSetName, options) { for await (const page of this.getOSUpgradeHistoryPagingPage(resourceGroupName, vmScaleSetName, options)) { yield* page; } } /** * Gets a list of SKUs available for your VM scale set, including the minimum and maximum VM instances * allowed for each SKU. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ listSkus(resourceGroupName, vmScaleSetName, options) { const iter = this.listSkusPagingAll(resourceGroupName, vmScaleSetName, 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.listSkusPagingPage(resourceGroupName, vmScaleSetName, options, settings); }, }; } async *listSkusPagingPage(resourceGroupName, vmScaleSetName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listSkus(resourceGroupName, vmScaleSetName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listSkusNext(resourceGroupName, vmScaleSetName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listSkusPagingAll(resourceGroupName, vmScaleSetName, options) { for await (const page of this.listSkusPagingPage(resourceGroupName, vmScaleSetName, options)) { yield* page; } } /** * Gets all the VM scale sets under the specified subscription for the specified location. * @param location The name of Azure region. * @param options The options parameters. */ _listByLocation(location, options) { return this.client.sendOperationRequest({ location, options }, listByLocationOperationSpec); } /** * Gets a list of all VM Scale Sets in the subscription, regardless of the associated resource group. * Use nextLink property in the response to get the next page of VM Scale Sets. Do this till nextLink * is null to fetch all the VM Scale Sets. * @param options The options parameters. */ _listAll(options) { return this.client.sendOperationRequest({ options }, listAllOperationSpec); } /** * Gets a list of all VM scale sets under a resource group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ _list(resourceGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, options }, listOperationSpec); } /** * Display information about a virtual machine scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ get(resourceGroupName, vmScaleSetName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, options }, getOperationSpec); } /** * Create or update a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param parameters The scale set object. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, vmScaleSetName, parameters, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, parameters, options }, spec: createOrUpdateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Create or update a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param parameters The scale set object. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, vmScaleSetName, parameters, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, vmScaleSetName, parameters, options); return poller.pollUntilDone(); } /** * Update a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param parameters The scale set object. * @param options The options parameters. */ async beginUpdate(resourceGroupName, vmScaleSetName, parameters, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, parameters, options }, spec: updateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Update a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param parameters The scale set object. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, vmScaleSetName, parameters, options) { const poller = await this.beginUpdate(resourceGroupName, vmScaleSetName, parameters, options); return poller.pollUntilDone(); } /** * Deletes a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginDelete(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Deletes a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginDelete(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginApproveRollingUpgrade(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: approveRollingUpgradeOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Approve upgrade on deferred rolling upgrades for OS disks in the virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginApproveRollingUpgradeAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginApproveRollingUpgrade(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Converts SinglePlacementGroup property to false for a existing virtual machine scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param parameters The input object for ConvertToSinglePlacementGroup API. * @param options The options parameters. */ convertToSinglePlacementGroup(resourceGroupName, vmScaleSetName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, parameters, options }, convertToSinglePlacementGroupOperationSpec); } /** * Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and * releases the compute resources. You are not billed for the compute resources that this virtual * machine scale set deallocates. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginDeallocate(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: deallocateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Deallocates specific virtual machines in a VM scale set. Shuts down the virtual machines and * releases the compute resources. You are not billed for the compute resources that this virtual * machine scale set deallocates. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginDeallocateAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginDeallocate(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Deletes virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param vmInstanceIDs A list of virtual machine instance IDs from the VM scale set. * @param options The options parameters. */ async beginDeleteInstances(resourceGroupName, vmScaleSetName, vmInstanceIDs, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, vmInstanceIDs, options }, spec: deleteInstancesOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Deletes virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param vmInstanceIDs A list of virtual machine instance IDs from the VM scale set. * @param options The options parameters. */ async beginDeleteInstancesAndWait(resourceGroupName, vmScaleSetName, vmInstanceIDs, options) { const poller = await this.beginDeleteInstances(resourceGroupName, vmScaleSetName, vmInstanceIDs, options); return poller.pollUntilDone(); } /** * Manual platform update domain walk to update virtual machines in a service fabric virtual machine * scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param platformUpdateDomain The platform update domain for which a manual recovery walk is requested * @param options The options parameters. */ forceRecoveryServiceFabricPlatformUpdateDomainWalk(resourceGroupName, vmScaleSetName, platformUpdateDomain, options) { return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, platformUpdateDomain, options }, forceRecoveryServiceFabricPlatformUpdateDomainWalkOperationSpec); } /** * Gets the status of a VM scale set instance. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ getInstanceView(resourceGroupName, vmScaleSetName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, options }, getInstanceViewOperationSpec); } /** * Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param vmInstanceIDs A list of virtual machine instance IDs from the VM scale set. * @param options The options parameters. */ async beginUpdateInstances(resourceGroupName, vmScaleSetName, vmInstanceIDs, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, vmInstanceIDs, options }, spec: updateInstancesOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Upgrades one or more virtual machines to the latest SKU set in the VM scale set model. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param vmInstanceIDs A list of virtual machine instance IDs from the VM scale set. * @param options The options parameters. */ async beginUpdateInstancesAndWait(resourceGroupName, vmScaleSetName, vmInstanceIDs, options) { const poller = await this.beginUpdateInstances(resourceGroupName, vmScaleSetName, vmInstanceIDs, options); return poller.pollUntilDone(); } /** * Gets list of OS upgrades on a VM scale set instance. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ _getOSUpgradeHistory(resourceGroupName, vmScaleSetName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, options }, getOSUpgradeHistoryOperationSpec); } /** * Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which * are not eligible for perform maintenance will be failed. Please refer to best practices for more * details: * https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginPerformMaintenance(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: performMaintenanceOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Perform maintenance on one or more virtual machines in a VM scale set. Operation on instances which * are not eligible for perform maintenance will be failed. Please refer to best practices for more * details: * https://docs.microsoft.com/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-maintenance-notifications * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginPerformMaintenanceAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginPerformMaintenance(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still * attached and you are getting charged for the resources. Instead, use deallocate to release resources * and avoid charges. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginPowerOff(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: powerOffOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Power off (stop) one or more virtual machines in a VM scale set. Note that resources are still * attached and you are getting charged for the resources. Instead, use deallocate to release resources * and avoid charges. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginPowerOffAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginPowerOff(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine Instances * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReapply(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: reapplyOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Reapplies the Virtual Machine Scale Set Virtual Machine Profile to the Virtual Machine Instances * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReapplyAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginReapply(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and * powers them back on. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginRedeploy(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: redeployOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Shuts down all the virtual machines in the virtual machine scale set, moves them to a new node, and * powers them back on. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginRedeployAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginRedeploy(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don't * have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is * reset to initial state. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReimage(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: reimageOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Reimages (upgrade the operating system) one or more virtual machines in a VM scale set which don't * have a ephemeral OS disk, for virtual machines who have a ephemeral OS disk the virtual machine is * reset to initial state. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReimageAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginReimage(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This * operation is only supported for managed disks. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReimageAll(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: reimageAllOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Reimages all the disks ( including data disks ) in the virtual machines in a VM scale set. This * operation is only supported for managed disks. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginReimageAllAndWait(resourceGroupName, vmScaleSetName, options) { const poller = await this.beginReimageAll(resourceGroupName, vmScaleSetName, options); return poller.pollUntilDone(); } /** * Restarts one or more virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginRestart(resourceGroupName, vmScaleSetName, 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, vmScaleSetName, options }, spec: restartOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Restarts one or more virtual machines in a VM scale set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmScaleSetName The name of the VM scale set. * @param options The options parameters. */ async beginRestartAndWait(resourceGroupName, vmScaleSetName,