diff --git a/lib/services/computeManagement2/lib/models/index.d.ts b/lib/services/computeManagement2/lib/models/index.d.ts index 173a16778d..2cdfffedbc 100644 --- a/lib/services/computeManagement2/lib/models/index.d.ts +++ b/lib/services/computeManagement2/lib/models/index.d.ts @@ -5343,12 +5343,10 @@ export interface RunCommandDocument extends RunCommandDocumentBase { * @class * Initializes a new instance of the RunCommandResult class. * @constructor - * Run command operation response. - * - * @member {object} [output] Operation output data (raw JSON) + * @member {array} [value] Run command operation response. */ export interface RunCommandResult { - output?: any; + value?: InstanceViewStatus[]; } /** diff --git a/lib/services/computeManagement2/lib/models/runCommandResult.js b/lib/services/computeManagement2/lib/models/runCommandResult.js index e279a76461..4e81f03d83 100644 --- a/lib/services/computeManagement2/lib/models/runCommandResult.js +++ b/lib/services/computeManagement2/lib/models/runCommandResult.js @@ -10,14 +10,15 @@ 'use strict'; +const models = require('./index'); + /** - * Run command operation response. - * + * Class representing a RunCommandResult. */ class RunCommandResult { /** * Create a RunCommandResult. - * @member {object} [output] Operation output data (raw JSON) + * @member {array} [value] Run command operation response. */ constructor() { } @@ -36,11 +37,19 @@ class RunCommandResult { name: 'Composite', className: 'RunCommandResult', modelProperties: { - output: { + value: { required: false, - serializedName: 'properties.output', + serializedName: 'value', type: { - name: 'Object' + name: 'Sequence', + element: { + required: false, + serializedName: 'InstanceViewStatusElementType', + type: { + name: 'Composite', + className: 'InstanceViewStatus' + } + } } } } diff --git a/lib/services/computeManagement2/lib/operations/index.d.ts b/lib/services/computeManagement2/lib/operations/index.d.ts index 7cf04b0804..ec9356ff1e 100644 --- a/lib/services/computeManagement2/lib/operations/index.d.ts +++ b/lib/services/computeManagement2/lib/operations/index.d.ts @@ -6031,11 +6031,11 @@ export interface VirtualMachines { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - runCommandWithHttpOperationResponse(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + runCommandWithHttpOperationResponse(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Run command on the VM. @@ -6066,7 +6066,7 @@ export interface VirtualMachines { * * {Promise} A promise is returned. * - * @resolve {Array} - The deserialized result object. + * @resolve {RunCommandResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -6074,15 +6074,16 @@ export interface VirtualMachines { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Array} [result] - The deserialized result object if an error did not occur. + * {RunCommandResult} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; - runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; + runCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -8293,11 +8294,11 @@ export interface VirtualMachines { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - beginRunCommandWithHttpOperationResponse(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + beginRunCommandWithHttpOperationResponse(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Run command on the VM. @@ -8328,7 +8329,7 @@ export interface VirtualMachines { * * {Promise} A promise is returned. * - * @resolve {Array} - The deserialized result object. + * @resolve {RunCommandResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -8336,15 +8337,16 @@ export interface VirtualMachines { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Array} [result] - The deserialized result object if an error did not occur. + * {RunCommandResult} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; - beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; + beginRunCommand(resourceGroupName: string, vmName: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** @@ -16016,6 +16018,89 @@ export interface VirtualMachineScaleSetVMs { performMaintenance(resourceGroupName: string, vmScaleSetName: string, instanceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + runCommandWithHttpOperationResponse(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RunCommandResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RunCommandResult} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + runCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + runCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; + runCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Reimages (upgrade the operating system) a specific virtual machine in a VM * scale set. @@ -17376,6 +17461,89 @@ export interface VirtualMachineScaleSetVMs { beginPerformMaintenance(resourceGroupName: string, vmScaleSetName: string, instanceId: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + beginRunCommandWithHttpOperationResponse(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {RunCommandResult} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {RunCommandResult} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + beginRunCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + beginRunCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, callback: ServiceCallback): void; + beginRunCommand(resourceGroupName: string, vmScaleSetName: string, instanceId: string, parameters: models.RunCommandInput, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + /** * Gets a list of all virtual machines in a VM scale sets. * diff --git a/lib/services/computeManagement2/lib/operations/virtualMachineScaleSetVMs.js b/lib/services/computeManagement2/lib/operations/virtualMachineScaleSetVMs.js index e0ed37578d..0fc1a2e386 100644 --- a/lib/services/computeManagement2/lib/operations/virtualMachineScaleSetVMs.js +++ b/lib/services/computeManagement2/lib/operations/virtualMachineScaleSetVMs.js @@ -1521,6 +1521,96 @@ function _performMaintenance(resourceGroupName, vmScaleSetName, instanceId, opti }); } + +/** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @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 RunCommandResult} 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 _runCommand(resourceGroupName, vmScaleSetName, instanceId, 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.beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, 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['RunCommandResult']().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); + }); + }); +} + /** * Reimages (upgrade the operating system) a specific virtual machine in a VM * scale set. @@ -3253,6 +3343,182 @@ function _beginPerformMaintenance(resourceGroupName, vmScaleSetName, instanceId, }); } +/** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @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 RunCommandResult} 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 _beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, 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.'); + } + let apiVersion = '2018-04-01'; + // 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 (vmScaleSetName === null || vmScaleSetName === undefined || typeof vmScaleSetName.valueOf() !== 'string') { + throw new Error('vmScaleSetName cannot be null or undefined and it must be of type string.'); + } + if (instanceId === null || instanceId === undefined || typeof instanceId.valueOf() !== 'string') { + throw new Error('instanceId cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/runCommand'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{vmScaleSetName}', encodeURIComponent(vmScaleSetName)); + requestUrl = requestUrl.replace('{instanceId}', encodeURIComponent(instanceId)); + 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 = 'POST'; + 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]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['RunCommandInput']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 202) { + 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['RunCommandResult']().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); + }); +} + /** * Gets a list of all virtual machines in a VM scale sets. * @@ -3402,6 +3668,7 @@ class VirtualMachineScaleSetVMs { this._start = _start; this._redeploy = _redeploy; this._performMaintenance = _performMaintenance; + this._runCommand = _runCommand; this._beginReimage = _beginReimage; this._beginReimageAll = _beginReimageAll; this._beginDeallocate = _beginDeallocate; @@ -3412,6 +3679,7 @@ class VirtualMachineScaleSetVMs { this._beginStart = _beginStart; this._beginRedeploy = _beginRedeploy; this._beginPerformMaintenance = _beginPerformMaintenance; + this._beginRunCommand = _beginRunCommand; this._listNext = _listNext; } @@ -5328,6 +5596,116 @@ class VirtualMachineScaleSetVMs { } } + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + runCommandWithHttpOperationResponse(resourceGroupName, vmScaleSetName, instanceId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._runCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RunCommandResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(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 RunCommandResult} 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. + */ + runCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._runCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._runCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, optionalCallback); + } + } + /** * Reimages (upgrade the operating system) a specific virtual machine in a VM * scale set. @@ -6958,6 +7336,116 @@ class VirtualMachineScaleSetVMs { } } + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + beginRunCommandWithHttpOperationResponse(resourceGroupName, vmScaleSetName, instanceId, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Run command on a virtual machine in a VM scale set. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} vmScaleSetName The name of the VM scale set. + * + * @param {string} instanceId The instance ID of the virtual machine. + * + * @param {object} parameters Parameters supplied to the Run command operation. + * + * @param {string} parameters.commandId The run command id. + * + * @param {array} [parameters.script] Optional. The script to be executed. + * When this value is given, the given script will override the default script + * of the command. + * + * @param {array} [parameters.parameters] The run command parameters. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {RunCommandResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(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 RunCommandResult} 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. + */ + beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._beginRunCommand(resourceGroupName, vmScaleSetName, instanceId, parameters, options, optionalCallback); + } + } + /** * Gets a list of all virtual machines in a VM scale sets. * diff --git a/lib/services/computeManagement2/lib/operations/virtualMachines.js b/lib/services/computeManagement2/lib/operations/virtualMachines.js index e5f777a0c1..091646015b 100644 --- a/lib/services/computeManagement2/lib/operations/virtualMachines.js +++ b/lib/services/computeManagement2/lib/operations/virtualMachines.js @@ -2396,7 +2396,8 @@ function _performMaintenance(resourceGroupName, vmName, options, callback) { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -2439,21 +2440,7 @@ function _runCommand(resourceGroupName, vmName, parameters, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'InstanceViewStatusElementType', - type: { - name: 'Composite', - className: 'InstanceViewStatus' - } - } - } - }; + let resultMapper = new client.models['RunCommandResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -4782,7 +4769,8 @@ function _beginPerformMaintenance(resourceGroupName, vmName, options, callback) * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -4908,21 +4896,7 @@ function _beginRunCommand(resourceGroupName, vmName, parameters, options, callba parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = { - required: false, - serializedName: 'parsedResponse', - type: { - name: 'Sequence', - element: { - required: false, - serializedName: 'InstanceViewStatusElementType', - type: { - name: 'Composite', - className: 'InstanceViewStatus' - } - } - } - }; + let resultMapper = new client.models['RunCommandResult']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -8263,7 +8237,7 @@ class VirtualMachines { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -8310,7 +8284,7 @@ class VirtualMachines { * * {Promise} A promise is returned * - * @resolve {Array} - The deserialized result object. + * @resolve {RunCommandResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -8318,7 +8292,8 @@ class VirtualMachines { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * @@ -10849,7 +10824,7 @@ class VirtualMachines { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ @@ -10896,7 +10871,7 @@ class VirtualMachines { * * {Promise} A promise is returned * - * @resolve {Array} - The deserialized result object. + * @resolve {RunCommandResult} - The deserialized result object. * * @reject {Error} - The error object. * @@ -10904,7 +10879,8 @@ class VirtualMachines { * * {Error} err - The Error object if an error occurred, null otherwise. * - * {array} [result] - The deserialized result object if an error did not occur. + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link RunCommandResult} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. *