UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

1,129 lines (1,072 loc) 373 kB
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ 'use strict'; const msRest = require('ms-rest'); const msRestAzure = require('ms-rest-azure'); const WebResource = msRest.WebResource; /** * Captures the VM by copying virtual hard disks of the VM and outputs a * template that can be used to create similar VMs. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} parameters Parameters supplied to the Capture Virtual * Machine operation. * * @param {string} parameters.vhdPrefix The captured virtual hard disk's name * prefix. * * @param {string} parameters.destinationContainerName The destination * container name. * * @param {boolean} parameters.overwriteVhds Specifies whether to overwrite the * destination virtual hard disk, in case of conflict. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link VirtualMachineCaptureResult} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _capture(resourceGroupName, vmName, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Send request this.beginCapture(resourceGroupName, vmName, parameters, options, (err, parsedResult, httpRequest, response) => { if (err) return callback(err); let initialResult = new msRest.HttpOperationResponse(); initialResult.request = httpRequest; initialResult.response = response; initialResult.body = response.body; client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { if (err) return callback(err); // Create Result let result = null; httpRequest = pollingResult.request; response = pollingResult.response; let responseBody = pollingResult.body; if (responseBody === '') responseBody = null; // Deserialize Response let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['VirtualMachineCaptureResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * The operation to create or update a virtual machine. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} parameters Parameters supplied to the Create Virtual Machine * operation. * * @param {object} [parameters.plan] Specifies information about the * marketplace image used to create the virtual machine. This element is only * used for marketplace images. Before you can use a marketplace image from an * API, you must enable the image for programmatic use. In the Azure portal, * find the marketplace image that you want to use and then click **Want to * deploy programmatically, Get Started ->**. Enter any required information * and then click **Save**. * * @param {string} [parameters.plan.name] The plan ID. * * @param {string} [parameters.plan.publisher] The publisher ID. * * @param {string} [parameters.plan.product] Specifies the product of the image * from the marketplace. This is the same value as Offer under the * imageReference element. * * @param {string} [parameters.plan.promotionCode] The promotion code. * * @param {object} [parameters.hardwareProfile] Specifies the hardware settings * for the virtual machine. * * @param {string} [parameters.hardwareProfile.vmSize] Specifies the size of * the virtual machine. For more information about virtual machine sizes, see * [Sizes for virtual * machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-sizes?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). * <br><br> The available VM sizes depend on region and availability set. For a * list of available sizes use these APIs: <br><br> [List all available * virtual machine sizes in an availability * set](virtualmachines-list-sizes-availability-set.md) <br><br> [List all * available virtual machine sizes in a * region](virtualmachines-list-sizes-region.md) <br><br> [List all available * virtual machine sizes for * resizing](virtualmachines-list-sizes-for-resizing.md). Possible values * include: 'Basic_A0', 'Basic_A1', 'Basic_A2', 'Basic_A3', 'Basic_A4', * 'Standard_A0', 'Standard_A1', 'Standard_A2', 'Standard_A3', 'Standard_A4', * 'Standard_A5', 'Standard_A6', 'Standard_A7', 'Standard_A8', 'Standard_A9', * 'Standard_A10', 'Standard_A11', 'Standard_A1_v2', 'Standard_A2_v2', * 'Standard_A4_v2', 'Standard_A8_v2', 'Standard_A2m_v2', 'Standard_A4m_v2', * 'Standard_A8m_v2', 'Standard_D1', 'Standard_D2', 'Standard_D3', * 'Standard_D4', 'Standard_D11', 'Standard_D12', 'Standard_D13', * 'Standard_D14', 'Standard_D1_v2', 'Standard_D2_v2', 'Standard_D3_v2', * 'Standard_D4_v2', 'Standard_D5_v2', 'Standard_D11_v2', 'Standard_D12_v2', * 'Standard_D13_v2', 'Standard_D14_v2', 'Standard_D15_v2', 'Standard_DS1', * 'Standard_DS2', 'Standard_DS3', 'Standard_DS4', 'Standard_DS11', * 'Standard_DS12', 'Standard_DS13', 'Standard_DS14', 'Standard_DS1_v2', * 'Standard_DS2_v2', 'Standard_DS3_v2', 'Standard_DS4_v2', 'Standard_DS5_v2', * 'Standard_DS11_v2', 'Standard_DS12_v2', 'Standard_DS13_v2', * 'Standard_DS14_v2', 'Standard_DS15_v2', 'Standard_F1', 'Standard_F2', * 'Standard_F4', 'Standard_F8', 'Standard_F16', 'Standard_F1s', * 'Standard_F2s', 'Standard_F4s', 'Standard_F8s', 'Standard_F16s', * 'Standard_G1', 'Standard_G2', 'Standard_G3', 'Standard_G4', 'Standard_G5', * 'Standard_GS1', 'Standard_GS2', 'Standard_GS3', 'Standard_GS4', * 'Standard_GS5', 'Standard_H8', 'Standard_H16', 'Standard_H8m', * 'Standard_H16m', 'Standard_H16r', 'Standard_H16mr', 'Standard_L4s', * 'Standard_L8s', 'Standard_L16s', 'Standard_L32s', 'Standard_NC6', * 'Standard_NC12', 'Standard_NC24', 'Standard_NC24r', 'Standard_NV6', * 'Standard_NV12', 'Standard_NV24' * * @param {object} [parameters.storageProfile] Specifies the storage settings * for the virtual machine disks. * * @param {object} [parameters.storageProfile.imageReference] Specifies * information about the image to use. You can specify information about * platform images, marketplace images, or virtual machine images. This element * is required when you want to use a platform image, marketplace image, or * virtual machine image, but is not used in other creation operations. * * @param {string} [parameters.storageProfile.imageReference.publisher] The * image publisher. * * @param {string} [parameters.storageProfile.imageReference.offer] Specifies * the offer of the platform image or marketplace image used to create the * virtual machine. * * @param {string} [parameters.storageProfile.imageReference.sku] The image * SKU. * * @param {string} [parameters.storageProfile.imageReference.version] Specifies * the version of the platform image or marketplace image used to create the * virtual machine. The allowed formats are Major.Minor.Build or 'latest'. * Major, Minor, and Build are decimal numbers. Specify 'latest' to use the * latest version of an image available at deploy time. Even if you use * 'latest', the VM image will not automatically update after deploy time even * if a new version becomes available. * * @param {string} [parameters.storageProfile.imageReference.id] Resource Id * * @param {object} [parameters.storageProfile.osDisk] Specifies information * about the operating system disk used by the virtual machine. <br><br> For * more information about disks, see [About disks and VHDs for Azure virtual * machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). * * @param {string} [parameters.storageProfile.osDisk.osType] This property * allows you to specify the type of the OS that is included in the disk if * creating a VM from user-image or a specialized VHD. <br><br> Possible values * are: <br><br> **Windows** <br><br> **Linux**. Possible values include: * 'Windows', 'Linux' * * @param {object} [parameters.storageProfile.osDisk.encryptionSettings] * Specifies the encryption settings for the OS Disk. <br><br> Minimum * api-version: 2015-06-15 * * @param {object} * [parameters.storageProfile.osDisk.encryptionSettings.diskEncryptionKey] * Specifies the location of the disk encryption key, which is a Key Vault * Secret. * * @param {string} * parameters.storageProfile.osDisk.encryptionSettings.diskEncryptionKey.secretUrl * The URL referencing a secret in a Key Vault. * * @param {object} * parameters.storageProfile.osDisk.encryptionSettings.diskEncryptionKey.sourceVault * The relative URL of the Key Vault containing the secret. * * @param {object} * [parameters.storageProfile.osDisk.encryptionSettings.keyEncryptionKey] * Specifies the location of the key encryption key in Key Vault. * * @param {string} * parameters.storageProfile.osDisk.encryptionSettings.keyEncryptionKey.keyUrl * The URL referencing a key encryption key in Key Vault. * * @param {object} * parameters.storageProfile.osDisk.encryptionSettings.keyEncryptionKey.sourceVault * The relative URL of the Key Vault containing the key. * * @param {boolean} * [parameters.storageProfile.osDisk.encryptionSettings.enabled] Specifies * whether disk encryption should be enabled on the virtual machine. * * @param {string} [parameters.storageProfile.osDisk.name] The disk name. * * @param {object} [parameters.storageProfile.osDisk.vhd] The virtual hard * disk. * * @param {object} [parameters.storageProfile.osDisk.image] The source user * image virtual hard disk. The virtual hard disk will be copied before being * attached to the virtual machine. If SourceImage is provided, the destination * virtual hard drive must not exist. * * @param {string} [parameters.storageProfile.osDisk.image.uri] Specifies the * virtual hard disk's uri. * * @param {string} [parameters.storageProfile.osDisk.caching] Specifies the * caching requirements. <br><br> Possible values are: <br><br> **None** * <br><br> **ReadOnly** <br><br> **ReadWrite** <br><br> Default: **None for * Standard storage. ReadOnly for Premium storage**. Possible values include: * 'None', 'ReadOnly', 'ReadWrite' * * @param {string} parameters.storageProfile.osDisk.createOption Specifies how * the virtual machine should be created.<br><br> Possible values are:<br><br> * **Attach** \u2013 This value is used when you are using a specialized disk * to create the virtual machine.<br><br> **FromImage** \u2013 This value is * used when you are using an image to create the virtual machine. If you are * using a platform image, you also use the imageReference element described * above. If you are using a marketplace image, you also use the plan element * previously described. Possible values include: 'fromImage', 'empty', * 'attach' * * @param {number} [parameters.storageProfile.osDisk.diskSizeGB] Specifies the * size of an empty data disk in gigabytes. This element can be used to * overwrite the name of the disk in a virtual machine image. <br><br> This * value cannot be larger than 1023 GB * * @param {object} [parameters.storageProfile.osDisk.managedDisk] The managed * disk parameters. * * @param {string} * [parameters.storageProfile.osDisk.managedDisk.storageAccountType] Specifies * the storage account type for the managed disk. Possible values are: * Standard_LRS or Premium_LRS. Possible values include: 'Standard_LRS', * 'Premium_LRS' * * @param {string} [parameters.storageProfile.osDisk.managedDisk.id] Resource * Id * * @param {array} [parameters.storageProfile.dataDisks] Specifies the * parameters that are used to add a data disk to a virtual machine. <br><br> * For more information about disks, see [About disks and VHDs for Azure * virtual * machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-about-disks-vhds?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). * * @param {object} [parameters.osProfile] Specifies the operating system * settings for the virtual machine. * * @param {string} [parameters.osProfile.computerName] Specifies the host OS * name of the virtual machine. <br><br> **Max-length (Windows):** 15 * characters <br><br> **Max-length (Linux):** 64 characters. <br><br> For * naming conventions and restrictions see [Azure infrastructure services * implementation * guidelines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-infrastructure-subscription-accounts-guidelines?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#1-naming-conventions). * * @param {string} [parameters.osProfile.adminUsername] Specifies the name of * the administrator account. <br><br> **Windows-only restriction:** Cannot end * in "." <br><br> **Disallowed values:** "administrator", "admin", "user", * "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", "a", * "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", * "john", "owner", "root", "server", "sql", "support", "support_388945a0", * "sys", "test2", "test3", "user4", "user5". <br><br> **Minimum-length * (Linux):** 1 character <br><br> **Max-length (Linux):** 64 characters * <br><br> **Max-length (Windows):** 20 characters <br><br><li> For root * access to the Linux VM, see [Using root privileges on Linux virtual machines * in * Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-use-root-privileges?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)<br><li> * For a list of built-in system users on Linux that should not be used in this * field, see [Selecting User Names for Linux on * Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-usernames?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) * * @param {string} [parameters.osProfile.adminPassword] Specifies the password * of the administrator account. <br><br> **Minimum-length (Windows):** 8 * characters <br><br> **Minimum-length (Linux):** 6 characters <br><br> * **Max-length (Windows):** 123 characters <br><br> **Max-length (Linux):** 72 * characters <br><br> **Complexity requirements:** 3 out of 4 conditions below * need to be fulfilled <br> Has lower characters <br>Has upper characters <br> * Has a digit <br> Has a special character (Regex match [\W_]) <br><br> * **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", * "Pa$$word", "pass@word1", "Password!", "Password1", "Password22", * "iloveyou!" <br><br> For resetting the password, see [How to reset the * Remote Desktop service or its login password in a Windows * VM](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-reset-rdp?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json) * <br><br> For resetting root password, see [Manage users, SSH, and check or * repair disks on Azure Linux VMs using the VMAccess * Extension](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-vmaccess-extension?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json#reset-root-password) * * @param {string} [parameters.osProfile.customData] Specifies a base-64 * encoded string of custom data. The base-64 encoded string is decoded to a * binary array that is saved as a file on the Virtual Machine. The maximum * length of the binary array is 65535 bytes. <br><br> For using cloud-init for * your VM, see [Using cloud-init to customize a Linux VM during * creation](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-cloud-init?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) * * @param {object} [parameters.osProfile.windowsConfiguration] Specifies * Windows operating system settings on the virtual machine. * * @param {boolean} * [parameters.osProfile.windowsConfiguration.provisionVMAgent] Indicates * whether virtual machine agent should be provisioned on the virtual machine. * <br><br> When this property is not specified in the request body, default * behavior is to set it to true. This will ensure that VM Agent is installed * on the VM so that extensions can be added to the VM later. * * @param {boolean} * [parameters.osProfile.windowsConfiguration.enableAutomaticUpdates] Indicates * whether virtual machine is enabled for automatic updates. * * @param {string} [parameters.osProfile.windowsConfiguration.timeZone] * Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time" * * @param {array} * [parameters.osProfile.windowsConfiguration.additionalUnattendContent] * Specifies additional base-64 encoded XML formatted information that can be * included in the Unattend.xml file, which is used by Windows Setup. * * @param {object} [parameters.osProfile.windowsConfiguration.winRM] Specifies * the Windows Remote Management listeners. This enables remote Windows * PowerShell. * * @param {array} [parameters.osProfile.windowsConfiguration.winRM.listeners] * The list of Windows Remote Management listeners * * @param {object} [parameters.osProfile.linuxConfiguration] Specifies the * Linux operating system settings on the virtual machine. <br><br>For a list * of supported Linux distributions, see [Linux on Azure-Endorsed * Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-endorsed-distros?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json) * <br><br> For running non-endorsed distributions, see [Information for * Non-Endorsed * Distributions](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-create-upload-generic?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json). * * @param {boolean} * [parameters.osProfile.linuxConfiguration.disablePasswordAuthentication] * Specifies whether password authentication should be disabled. * * @param {object} [parameters.osProfile.linuxConfiguration.ssh] Specifies the * ssh key configuration for a Linux OS. * * @param {array} [parameters.osProfile.linuxConfiguration.ssh.publicKeys] The * list of SSH public keys used to authenticate with linux based VMs. * * @param {array} [parameters.osProfile.secrets] Specifies set of certificates * that should be installed onto the virtual machine. * * @param {object} [parameters.networkProfile] Specifies the network interfaces * of the virtual machine. * * @param {array} [parameters.networkProfile.networkInterfaces] Specifies the * list of resource Ids for the network interfaces associated with the virtual * machine. * * @param {object} [parameters.diagnosticsProfile] Specifies the boot * diagnostic settings state. <br><br>Minimum api-version: 2015-06-15. * * @param {object} [parameters.diagnosticsProfile.bootDiagnostics] Boot * Diagnostics is a debugging feature which allows you to view Console Output * and Screenshot to diagnose VM status. <br><br> For Linux Virtual Machines, * you can easily view the output of your console log. <br><br> For both * Windows and Linux virtual machines, Azure also enables you to see a * screenshot of the VM from the hypervisor. * * @param {boolean} [parameters.diagnosticsProfile.bootDiagnostics.enabled] * Whether boot diagnostics should be enabled on the Virtual Machine. * * @param {string} [parameters.diagnosticsProfile.bootDiagnostics.storageUri] * Uri of the storage account to use for placing the console output and * screenshot. * * @param {object} [parameters.availabilitySet] Specifies information about the * availability set that the virtual machine should be assigned to. Virtual * machines specified in the same availability set are allocated to different * nodes to maximize availability. For more information about availability * sets, see [Manage the availability of virtual * machines](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-manage-availability?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). * <br><br> For more information on Azure planned maintainance, see [Planned * maintenance for virtual machines in * Azure](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-planned-maintenance?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json) * <br><br> Currently, a VM can only be added to availability set at creation * time. An existing VM cannot be added to an availability set. * * @param {string} [parameters.availabilitySet.id] Resource Id * * @param {string} [parameters.licenseType] Specifies that the image or disk * that is being used was licensed on-premises. This element is only used for * images that contain the Windows Server operating system. <br><br> Possible * values are: <br><br> Windows_Client <br><br> Windows_Server <br><br> If this * element is included in a request for an update, the value must match the * initial value. This value cannot be updated. <br><br> For more information, * see [Azure Hybrid Use Benefit for Windows * Server](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-hybrid-use-benefit-licensing?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json) * <br><br> Minimum api-version: 2015-06-15 * * @param {object} [parameters.identity] The identity of the virtual machine, * if configured. * * @param {string} [parameters.identity.type] The type of identity used for the * virtual machine. Currently, the only supported type is 'SystemAssigned', * which implicitly creates an identity. Possible values include: * 'SystemAssigned' * * @param {array} [parameters.zones] The virtual machine zones. * * @param {string} parameters.location Resource location * * @param {object} [parameters.tags] Resource tags * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link VirtualMachine} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _createOrUpdate(resourceGroupName, vmName, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Send request this.beginCreateOrUpdate(resourceGroupName, vmName, parameters, options, (err, parsedResult, httpRequest, response) => { if (err) return callback(err); let initialResult = new msRest.HttpOperationResponse(); initialResult.request = httpRequest; initialResult.response = response; initialResult.body = response.body; client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { if (err) return callback(err); // Create Result let result = null; httpRequest = pollingResult.request; response = pollingResult.response; let responseBody = pollingResult.body; if (responseBody === '') responseBody = null; // Deserialize Response let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['VirtualMachine']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * The operation to delete a virtual machine. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link OperationStatusResponse} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Send request this.beginDeleteMethod(resourceGroupName, vmName, options, (err, parsedResult, httpRequest, response) => { if (err) return callback(err); let initialResult = new msRest.HttpOperationResponse(); initialResult.request = httpRequest; initialResult.response = response; initialResult.body = response.body; client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { if (err) return callback(err); // Create Result let result = null; httpRequest = pollingResult.request; response = pollingResult.response; let responseBody = pollingResult.body; if (responseBody === '') responseBody = null; // Deserialize Response let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['OperationStatusResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * Retrieves information about the model view or the instance view of a virtual * machine. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {string} [options.expand] The expand expression to apply on the * operation. Possible values include: 'instanceView' * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link VirtualMachine} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } let expand = (options && options.expand !== undefined) ? options.expand : undefined; let apiVersion = '2017-03-30'; // Validate try { if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (vmName === null || vmName === undefined || typeof vmName.valueOf() !== 'string') { throw new Error('vmName cannot be null or undefined and it must be of type string.'); } if (expand) { let allowedValues = [ 'instanceView' ]; if (!allowedValues.some( function(item) { return item === expand; })) { throw new Error(expand + ' is not a valid value. The valid values are: ' + allowedValues); } } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{vmName}', encodeURIComponent(vmName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; if (expand !== null && expand !== undefined) { queryParameters.push('$expand=' + encodeURIComponent(expand)); } queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; // Deserialize Response if (statusCode === 200) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['VirtualMachine']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Retrieves information about the run-time state of a virtual machine. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link VirtualMachineInstanceView} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _instanceView(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } let apiVersion = '2017-03-30'; // Validate try { if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (vmName === null || vmName === undefined || typeof vmName.valueOf() !== 'string') { throw new Error('vmName cannot be null or undefined and it must be of type string.'); } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView'; requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); requestUrl = requestUrl.replace('{vmName}', encodeURIComponent(vmName)); requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['CloudError']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; // Deserialize Response if (statusCode === 200) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['VirtualMachineInstanceView']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Converts virtual machine disks from blob-based to managed disks. Virtual * machine must be stop-deallocated before invoking this operation. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link OperationStatusResponse} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _convertToManagedDisks(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Send request this.beginConvertToManagedDisks(resourceGroupName, vmName, options, (err, parsedResult, httpRequest, response) => { if (err) return callback(err); let initialResult = new msRest.HttpOperationResponse(); initialResult.request = httpRequest; initialResult.response = response; initialResult.body = response.body; client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { if (err) return callback(err); // Create Result let result = null; httpRequest = pollingResult.request; response = pollingResult.response; let responseBody = pollingResult.body; if (responseBody === '') responseBody = null; // Deserialize Response let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['OperationStatusResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * Shuts down the virtual machine and releases the compute resources. You are * not billed for the compute resources that this virtual machine uses. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link OperationStatusResponse} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deallocate(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Send request this.beginDeallocate(resourceGroupName, vmName, options, (err, parsedResult, httpRequest, response) => { if (err) return callback(err); let initialResult = new msRest.HttpOperationResponse(); initialResult.request = httpRequest; initialResult.response = response; initialResult.body = response.body; client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => { if (err) return callback(err); // Create Result let result = null; httpRequest = pollingResult.request; response = pollingResult.response; let responseBody = pollingResult.body; if (responseBody === '') responseBody = null; // Deserialize Response let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['OperationStatusResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } return callback(null, result, httpRequest, response); }); }); } /** * Sets the state of the virtual machine to generalized. * * @param {string} resourceGroupName The name of the resource group. * * @param {string} vmName The name of the virtual machine. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link OperationStatusResponse} for more * information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _generalize(resourceGroupName, vmName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } let apiVersion = '2017-03-30'; // Validate try { if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); } if (vmName === null || vmName === undefined || typeof vmName.valueOf() !== 'string') { throw new Error('vmName cannot be null or undefined and it must be of type string.'); } if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Constr