UNPKG

@azure/arm-compute

Version:
1,148 lines (1,147 loc) 83.3 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.VirtualMachinesImpl = 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 VirtualMachines operations. */ class VirtualMachinesImpl { client; /** * Initialize a new instance of the class VirtualMachines class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets all the virtual machines 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); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByLocationNext(location, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listByLocationPagingAll(location, options) { for await (const page of this.listByLocationPagingPage(location, options)) { yield* page; } } /** * Lists all of the virtual machines in the specified subscription. Use the nextLink property in the * response to get the next page of virtual machines. * @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); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listAllPagingAll(options) { for await (const page of this.listAllPagingPage(options)) { yield* page; } } /** * Lists all of the virtual machines in the specified resource group. Use the nextLink property in the * response to get the next page of virtual machines. * @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); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listNext(resourceGroupName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listPagingAll(resourceGroupName, options) { for await (const page of this.listPagingPage(resourceGroupName, options)) { yield* page; } } /** * Lists all available virtual machine sizes to which the specified virtual machine can be resized. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ listAvailableSizes(resourceGroupName, vmName, options) { const iter = this.listAvailableSizesPagingAll(resourceGroupName, vmName, 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.listAvailableSizesPagingPage(resourceGroupName, vmName, options, settings); }, }; } async *listAvailableSizesPagingPage(resourceGroupName, vmName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listAvailableSizes(resourceGroupName, vmName, options); let page = result.value || []; continuationToken = result.nextLink; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } while (continuationToken) { result = await this._listAvailableSizesNext(resourceGroupName, vmName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken); yield page; } } async *listAvailableSizesPagingAll(resourceGroupName, vmName, options) { for await (const page of this.listAvailableSizesPagingPage(resourceGroupName, vmName, options)) { yield* page; } } /** * Gets all the virtual machines 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); } /** * Lists all of the virtual machines in the specified subscription. Use the nextLink property in the * response to get the next page of virtual machines. * @param options The options parameters. */ _listAll(options) { return this.client.sendOperationRequest({ options }, listAllOperationSpec); } /** * Lists all of the virtual machines in the specified resource group. Use the nextLink property in the * response to get the next page of virtual machines. * @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); } /** * Retrieves information about the model view or the instance view of a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ get(resourceGroupName, vmName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmName, options }, getOperationSpec); } /** * The operation to create or update a virtual machine. Please note some properties can be set only * during virtual machine creation. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Create Virtual Machine operation. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, vmName, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, vmName, parameters, options }, spec: createOrUpdateOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to create or update a virtual machine. Please note some properties can be set only * during virtual machine creation. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Create Virtual Machine operation. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, vmName, parameters, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, vmName, parameters, options); return poller.pollUntilDone(); } /** * The operation to update a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Update Virtual Machine operation. * @param options The options parameters. */ async beginUpdate(resourceGroupName, vmName, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, vmName, parameters, options }, spec: updateOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to update a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Update Virtual Machine operation. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, vmName, parameters, options) { const poller = await this.beginUpdate(resourceGroupName, vmName, parameters, options); return poller.pollUntilDone(); } /** * The operation to delete a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginDelete(resourceGroupName, vmName, 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, vmName, options }, spec: deleteOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to delete a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, vmName, options) { const poller = await this.beginDelete(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Assess patches on the VM. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginAssessPatches(resourceGroupName, vmName, 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, vmName, options }, spec: assessPatchesOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Assess patches on the VM. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginAssessPatchesAndWait(resourceGroupName, vmName, options) { const poller = await this.beginAssessPatches(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Attach and detach data disks to/from the virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the attach and detach data disks operation on the virtual * machine. * @param options The options parameters. */ async beginAttachDetachDataDisks(resourceGroupName, vmName, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, vmName, parameters, options }, spec: attachDetachDataDisksOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Attach and detach data disks to/from the virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the attach and detach data disks operation on the virtual * machine. * @param options The options parameters. */ async beginAttachDetachDataDisksAndWait(resourceGroupName, vmName, parameters, options) { const poller = await this.beginAttachDetachDataDisks(resourceGroupName, vmName, parameters, options); return poller.pollUntilDone(); } /** * Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to * create similar VMs. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Capture Virtual Machine operation. * @param options The options parameters. */ async beginCapture(resourceGroupName, vmName, 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 = (0, lroImpl_js_1.createLroSpec)({ sendOperationFn, args: { resourceGroupName, vmName, parameters, options }, spec: captureOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Captures the VM by copying virtual hard disks of the VM and outputs a template that can be used to * create similar VMs. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param parameters Parameters supplied to the Capture Virtual Machine operation. * @param options The options parameters. */ async beginCaptureAndWait(resourceGroupName, vmName, parameters, options) { const poller = await this.beginCapture(resourceGroupName, vmName, parameters, options); return poller.pollUntilDone(); } /** * Converts virtual machine disks from blob-based to managed disks. Virtual machine must be * stop-deallocated before invoking this operation. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginConvertToManagedDisks(resourceGroupName, vmName, 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, vmName, options }, spec: convertToManagedDisksOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Converts virtual machine disks from blob-based to managed disks. Virtual machine must be * stop-deallocated before invoking this operation. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginConvertToManagedDisksAndWait(resourceGroupName, vmName, options) { const poller = await this.beginConvertToManagedDisks(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Shuts down the virtual machine and releases the compute resources. You are not billed for the * compute resources that this virtual machine uses. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginDeallocate(resourceGroupName, vmName, 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, vmName, options }, spec: deallocateOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Shuts down the virtual machine and releases the compute resources. You are not billed for the * compute resources that this virtual machine uses. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginDeallocateAndWait(resourceGroupName, vmName, options) { const poller = await this.beginDeallocate(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Sets the OS state of the virtual machine to generalized. It is recommended to sysprep the virtual * machine before performing this operation. For Windows, please refer to [Create a managed image of a * generalized VM in * Azure](https://docs.microsoft.com/azure/virtual-machines/windows/capture-image-resource). For Linux, * please refer to [How to create an image of a virtual machine or * VHD](https://docs.microsoft.com/azure/virtual-machines/linux/capture-image). * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ generalize(resourceGroupName, vmName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmName, options }, generalizeOperationSpec); } /** * Installs patches on the VM. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param installPatchesInput Input for InstallPatches as directly received by the API * @param options The options parameters. */ async beginInstallPatches(resourceGroupName, vmName, installPatchesInput, 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, vmName, installPatchesInput, options }, spec: installPatchesOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Installs patches on the VM. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param installPatchesInput Input for InstallPatches as directly received by the API * @param options The options parameters. */ async beginInstallPatchesAndWait(resourceGroupName, vmName, installPatchesInput, options) { const poller = await this.beginInstallPatches(resourceGroupName, vmName, installPatchesInput, options); return poller.pollUntilDone(); } /** * Retrieves information about the run-time state of a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ instanceView(resourceGroupName, vmName, options) { return this.client.sendOperationRequest({ resourceGroupName, vmName, options }, instanceViewOperationSpec); } /** * Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginMigrateToVMScaleSet(resourceGroupName, vmName, 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, vmName, options }, spec: migrateToVMScaleSetOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Migrate a virtual machine from availability set to Flexible Virtual Machine Scale Set. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginMigrateToVMScaleSetAndWait(resourceGroupName, vmName, options) { const poller = await this.beginMigrateToVMScaleSet(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * The operation to perform maintenance on a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginPerformMaintenance(resourceGroupName, vmName, 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, vmName, options }, spec: performMaintenanceOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to perform maintenance on a virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginPerformMaintenanceAndWait(resourceGroupName, vmName, options) { const poller = await this.beginPerformMaintenance(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the * same provisioned resources. You are still charged for this virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginPowerOff(resourceGroupName, vmName, 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, vmName, options }, spec: powerOffOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to power off (stop) a virtual machine. The virtual machine can be restarted with the * same provisioned resources. You are still charged for this virtual machine. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginPowerOffAndWait(resourceGroupName, vmName, options) { const poller = await this.beginPowerOff(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * The operation to reapply a virtual machine's state. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginReapply(resourceGroupName, vmName, 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, vmName, options }, spec: reapplyOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * The operation to reapply a virtual machine's state. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginReapplyAndWait(resourceGroupName, vmName, options) { const poller = await this.beginReapply(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Shuts down the virtual machine, moves it to a new node, and powers it back on. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginRedeploy(resourceGroupName, vmName, 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, vmName, options }, spec: redeployOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Shuts down the virtual machine, moves it to a new node, and powers it back on. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginRedeployAndWait(resourceGroupName, vmName, options) { const poller = await this.beginRedeploy(resourceGroupName, vmName, options); return poller.pollUntilDone(); } /** * Reimages (upgrade the operating system) a virtual machine 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. NOTE: * The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is * detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk * will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before * performing the reimage. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param vmName The name of the virtual machine. * @param options The options parameters. */ async beginReimage(resourceGroupName, vmName, 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, vmName, options }, spec: reimageOperationSpec, }); const poller = await (0, core_lro_1.createHttpPoller)(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Reimages (upgrade the operating system) a virtual machine 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. NOTE: * The retaining of old OS disk depends on the value of deleteOption of OS disk. If deleteOption is * detach, the old OS disk will be preserved after reimage. If deleteOption is delete, the old OS disk * will be deleted after reimage. The deleteOption of the OS disk should be updated accordingly before * performing the reimage. * @param resourceGroupName The name of the resource group. The name is case insensitive.