/*
 * 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;

/**
 * Get all the resources for a resource group.
 *
 * @param {string} resourceGroupName The resource group with the resources to
 * get.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.filter] The filter to apply on the
 * operation.<br><br>The properties you can use for eq (equals) or ne (not
 * equals) are: location, resourceType, name, resourceGroup, identity,
 * identity/principalId, plan, plan/publisher, plan/product, plan/name,
 * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
 * resource type, use: $filter=resourceType eq
 * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
 * property) in the filter. The properties you can use for substring are: name
 * and resourceGroup.<br><br>For example, to get all resources with 'demo'
 * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
 * link more than one substringof together by adding and/or
 * operators.<br><br>You can filter by tag names and values. For example, to
 * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
 * eq 'Value1'<br><br>You can use some properties together when filtering. The
 * combinations you can use are: substringof and/or resourceType, plan and
 * plan/publisher and plan/name, identity and identity/principalId.
 *
 * @param {string} [options.expand] The $expand query parameter. You can expand
 * createdTime and changedTime. For example, to expand both properties, use
 * $expand=changedTime,createdTime
 *
 * @param {number} [options.top] The number of results to return. If null is
 * passed, returns all resources.
 *
 * @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 ResourceListResult} 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 _listByResourceGroup(resourceGroupName, 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 filter = (options && options.filter !== undefined) ? options.filter : undefined;
  let expand = (options && options.expand !== undefined) ? options.expand : undefined;
  let top = (options && options.top !== undefined) ? options.top : undefined;
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter must be of type string.');
    }
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (top !== null && top !== undefined && typeof top !== 'number') {
      throw new Error('top must be of type number.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion 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}/resources';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  if (top !== null && top !== undefined) {
    queryParameters.push('$top=' + encodeURIComponent(top.toString()));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.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['ResourceListResult']().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);
  });
}


/**
 * @summary Moves resources from one resource group to another resource group.
 *
 * The resources to move must be in the same source resource group. The target
 * resource group may be in a different subscription. When moving resources,
 * both the source group and the target group are locked for the duration of
 * the operation. Write and delete operations are blocked on the groups until
 * the move completes.
 *
 * @param {string} sourceResourceGroupName The name of the resource group
 * containing the resources to move.
 *
 * @param {object} parameters Parameters for moving resources.
 *
 * @param {array} [parameters.resources] The IDs of the resources.
 *
 * @param {string} [parameters.targetResourceGroup] The target resource group.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _moveResources(sourceResourceGroupName, 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.beginMoveResources(sourceResourceGroupName, 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

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * @summary Validates whether resources can be moved from one resource group to
 * another resource group.
 *
 * This operation checks whether the specified resources can be moved to the
 * target. The resources to move must be in the same source resource group. The
 * target resource group may be in a different subscription. If validation
 * succeeds, it returns HTTP response code 204 (no content). If validation
 * fails, it returns HTTP response code 409 (Conflict) with an error message.
 * Retrieve the URL in the Location header value to check the result of the
 * long-running operation.
 *
 * @param {string} sourceResourceGroupName The name of the resource group
 * containing the resources to validate for move.
 *
 * @param {object} parameters Parameters for moving resources.
 *
 * @param {array} [parameters.resources] The IDs of the resources.
 *
 * @param {string} [parameters.targetResourceGroup] The target resource group.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _validateMoveResources(sourceResourceGroupName, 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.beginValidateMoveResources(sourceResourceGroupName, 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

      return callback(null, result, httpRequest, response);
    });
  });
}

/**
 * Get all the resources in a subscription.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.filter] The filter to apply on the
 * operation.<br><br>The properties you can use for eq (equals) or ne (not
 * equals) are: location, resourceType, name, resourceGroup, identity,
 * identity/principalId, plan, plan/publisher, plan/product, plan/name,
 * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
 * resource type, use: $filter=resourceType eq
 * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
 * property) in the filter. The properties you can use for substring are: name
 * and resourceGroup.<br><br>For example, to get all resources with 'demo'
 * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
 * link more than one substringof together by adding and/or
 * operators.<br><br>You can filter by tag names and values. For example, to
 * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
 * eq 'Value1'<br><br>You can use some properties together when filtering. The
 * combinations you can use are: substringof and/or resourceType, plan and
 * plan/publisher and plan/name, identity and identity/principalId.
 *
 * @param {string} [options.expand] The $expand query parameter. You can expand
 * createdTime and changedTime. For example, to expand both properties, use
 * $expand=changedTime,createdTime
 *
 * @param {number} [options.top] The number of results to return. If null is
 * passed, returns all resource groups.
 *
 * @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 ResourceListResult} 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 _list(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 filter = (options && options.filter !== undefined) ? options.filter : undefined;
  let expand = (options && options.expand !== undefined) ? options.expand : undefined;
  let top = (options && options.top !== undefined) ? options.top : undefined;
  // Validate
  try {
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter must be of type string.');
    }
    if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
      throw new Error('expand must be of type string.');
    }
    if (top !== null && top !== undefined && typeof top !== 'number') {
      throw new Error('top must be of type number.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion 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}/resources';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  if (expand !== null && expand !== undefined) {
    queryParameters.push('$expand=' + encodeURIComponent(expand));
  }
  if (top !== null && top !== undefined) {
    queryParameters.push('$top=' + encodeURIComponent(top.toString()));
  }
  queryParameters.push('api-version=' + encodeURIComponent(this.client.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['ResourceListResult']().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);
  });
}

/**
 * Checks whether a resource exists.
 *
 * @param {string} resourceGroupName The name of the resource group containing
 * the resource to check. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The resource provider of the
 * resource to check.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type.
 *
 * @param {string} resourceName The name of the resource to check whether it
 * exists.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {boolean} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.');
  }
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (resourceProviderNamespace === null || resourceProviderNamespace === undefined || typeof resourceProviderNamespace.valueOf() !== 'string') {
      throw new Error('resourceProviderNamespace cannot be null or undefined and it must be of type string.');
    }
    if (parentResourcePath === null || parentResourcePath === undefined || typeof parentResourcePath.valueOf() !== 'string') {
      throw new Error('parentResourcePath cannot be null or undefined and it must be of type string.');
    }
    if (resourceType === null || resourceType === undefined || typeof resourceType.valueOf() !== 'string') {
      throw new Error('resourceType cannot be null or undefined and it must be of type string.');
    }
    if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
      throw new Error('resourceName cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{resourceProviderNamespace}', encodeURIComponent(resourceProviderNamespace));
  requestUrl = requestUrl.replace('{parentResourcePath}', parentResourcePath);
  requestUrl = requestUrl.replace('{resourceType}', resourceType);
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
  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 = 'HEAD';
  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 !== 204 && statusCode !== 404) {
      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;
    result = (statusCode === 204);

    return callback(null, result, httpRequest, response);
  });
}


/**
 * Deletes a resource.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource to delete. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type.
 *
 * @param {string} resourceName The name of the resource to delete.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Creates a resource.
 *
 * @param {string} resourceGroupName The name of the resource group for the
 * resource. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type of the resource to create.
 *
 * @param {string} resourceName The name of the resource to create.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Parameters for creating or updating the resource.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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['GenericResource']().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);
    });
  });
}


/**
 * Updates a resource.
 *
 * @param {string} resourceGroupName The name of the resource group for the
 * resource. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type of the resource to update.
 *
 * @param {string} resourceName The name of the resource to update.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Parameters for updating the resource.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _update(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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['GenericResource']().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 resource.
 *
 * @param {string} resourceGroupName The name of the resource group containing
 * the resource to get. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type of the resource.
 *
 * @param {string} resourceName The name of the resource to get.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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 GenericResource} 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, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.');
  }
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (resourceProviderNamespace === null || resourceProviderNamespace === undefined || typeof resourceProviderNamespace.valueOf() !== 'string') {
      throw new Error('resourceProviderNamespace cannot be null or undefined and it must be of type string.');
    }
    if (parentResourcePath === null || parentResourcePath === undefined || typeof parentResourcePath.valueOf() !== 'string') {
      throw new Error('parentResourcePath cannot be null or undefined and it must be of type string.');
    }
    if (resourceType === null || resourceType === undefined || typeof resourceType.valueOf() !== 'string') {
      throw new Error('resourceType cannot be null or undefined and it must be of type string.');
    }
    if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
      throw new Error('resourceName cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{resourceProviderNamespace}', encodeURIComponent(resourceProviderNamespace));
  requestUrl = requestUrl.replace('{parentResourcePath}', parentResourcePath);
  requestUrl = requestUrl.replace('{resourceType}', resourceType);
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
  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['GenericResource']().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);
  });
}

/**
 * Checks by ID whether a resource exists.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {boolean} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _checkExistenceById(resourceId, apiVersion, 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.');
  }
  // Validate
  try {
    if (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') {
      throw new Error('resourceId cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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('/') ? '' : '/') + '{resourceId}';
  requestUrl = requestUrl.replace('{resourceId}', resourceId);
  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 = 'HEAD';
  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 !== 204 && statusCode !== 404) {
      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;
    result = (statusCode === 204);

    return callback(null, result, httpRequest, response);
  });
}


/**
 * Deletes a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _deleteById(resourceId, apiVersion, 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.beginDeleteById(resourceId, apiVersion, 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

      return callback(null, result, httpRequest, response);
    });
  });
}


/**
 * Create a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Create or update resource parameters.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _createOrUpdateById(resourceId, apiVersion, 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.beginCreateOrUpdateById(resourceId, apiVersion, 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['GenericResource']().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);
    });
  });
}


/**
 * Updates a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Update resource parameters.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _updateById(resourceId, apiVersion, 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.beginUpdateById(resourceId, apiVersion, 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['GenericResource']().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 resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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 GenericResource} 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 _getById(resourceId, apiVersion, 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.');
  }
  // Validate
  try {
    if (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') {
      throw new Error('resourceId cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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('/') ? '' : '/') + '{resourceId}';
  requestUrl = requestUrl.replace('{resourceId}', resourceId);
  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['GenericResource']().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);
  });
}

/**
 * @summary Moves resources from one resource group to another resource group.
 *
 * The resources to move must be in the same source resource group. The target
 * resource group may be in a different subscription. When moving resources,
 * both the source group and the target group are locked for the duration of
 * the operation. Write and delete operations are blocked on the groups until
 * the move completes.
 *
 * @param {string} sourceResourceGroupName The name of the resource group
 * containing the resources to move.
 *
 * @param {object} parameters Parameters for moving resources.
 *
 * @param {array} [parameters.resources] The IDs of the resources.
 *
 * @param {string} [parameters.targetResourceGroup] The target resource group.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _beginMoveResources(sourceResourceGroupName, 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.');
  }
  // Validate
  try {
    if (sourceResourceGroupName === null || sourceResourceGroupName === undefined || typeof sourceResourceGroupName.valueOf() !== 'string') {
      throw new Error('sourceResourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (sourceResourceGroupName !== null && sourceResourceGroupName !== undefined) {
      if (sourceResourceGroupName.length > 90)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (sourceResourceGroupName.length < 1)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion 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/{sourceResourceGroupName}/moveResources';
  requestUrl = requestUrl.replace('{sourceResourceGroupName}', encodeURIComponent(sourceResourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.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['ResourcesMoveInfo']().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 !== 202 && statusCode !== 204) {
      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;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * @summary Validates whether resources can be moved from one resource group to
 * another resource group.
 *
 * This operation checks whether the specified resources can be moved to the
 * target. The resources to move must be in the same source resource group. The
 * target resource group may be in a different subscription. If validation
 * succeeds, it returns HTTP response code 204 (no content). If validation
 * fails, it returns HTTP response code 409 (Conflict) with an error message.
 * Retrieve the URL in the Location header value to check the result of the
 * long-running operation.
 *
 * @param {string} sourceResourceGroupName The name of the resource group
 * containing the resources to validate for move.
 *
 * @param {object} parameters Parameters for moving resources.
 *
 * @param {array} [parameters.resources] The IDs of the resources.
 *
 * @param {string} [parameters.targetResourceGroup] The target resource group.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _beginValidateMoveResources(sourceResourceGroupName, 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.');
  }
  // Validate
  try {
    if (sourceResourceGroupName === null || sourceResourceGroupName === undefined || typeof sourceResourceGroupName.valueOf() !== 'string') {
      throw new Error('sourceResourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (sourceResourceGroupName !== null && sourceResourceGroupName !== undefined) {
      if (sourceResourceGroupName.length > 90)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (sourceResourceGroupName.length < 1)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (sourceResourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"sourceResourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion 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/{sourceResourceGroupName}/validateMoveResources';
  requestUrl = requestUrl.replace('{sourceResourceGroupName}', encodeURIComponent(sourceResourceGroupName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.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['ResourcesMoveInfo']().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 !== 202 && statusCode !== 204 && statusCode !== 409) {
      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;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Deletes a resource.
 *
 * @param {string} resourceGroupName The name of the resource group that
 * contains the resource to delete. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type.
 *
 * @param {string} resourceName The name of the resource to delete.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.');
  }
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (resourceProviderNamespace === null || resourceProviderNamespace === undefined || typeof resourceProviderNamespace.valueOf() !== 'string') {
      throw new Error('resourceProviderNamespace cannot be null or undefined and it must be of type string.');
    }
    if (parentResourcePath === null || parentResourcePath === undefined || typeof parentResourcePath.valueOf() !== 'string') {
      throw new Error('parentResourcePath cannot be null or undefined and it must be of type string.');
    }
    if (resourceType === null || resourceType === undefined || typeof resourceType.valueOf() !== 'string') {
      throw new Error('resourceType cannot be null or undefined and it must be of type string.');
    }
    if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
      throw new Error('resourceName cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{resourceProviderNamespace}', encodeURIComponent(resourceProviderNamespace));
  requestUrl = requestUrl.replace('{parentResourcePath}', parentResourcePath);
  requestUrl = requestUrl.replace('{resourceType}', resourceType);
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
  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 = 'DELETE';
  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 && statusCode !== 202 && statusCode !== 204) {
      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;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Creates a resource.
 *
 * @param {string} resourceGroupName The name of the resource group for the
 * resource. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type of the resource to create.
 *
 * @param {string} resourceName The name of the resource to create.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Parameters for creating or updating the resource.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.');
  }
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (resourceProviderNamespace === null || resourceProviderNamespace === undefined || typeof resourceProviderNamespace.valueOf() !== 'string') {
      throw new Error('resourceProviderNamespace cannot be null or undefined and it must be of type string.');
    }
    if (parentResourcePath === null || parentResourcePath === undefined || typeof parentResourcePath.valueOf() !== 'string') {
      throw new Error('parentResourcePath cannot be null or undefined and it must be of type string.');
    }
    if (resourceType === null || resourceType === undefined || typeof resourceType.valueOf() !== 'string') {
      throw new Error('resourceType cannot be null or undefined and it must be of type string.');
    }
    if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
      throw new Error('resourceName cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{resourceProviderNamespace}', encodeURIComponent(resourceProviderNamespace));
  requestUrl = requestUrl.replace('{parentResourcePath}', parentResourcePath);
  requestUrl = requestUrl.replace('{resourceType}', resourceType);
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
  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 = 'PUT';
  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['GenericResource']().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 !== 201 && 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['GenericResource']().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);
      }
    }
    // Deserialize Response
    if (statusCode === 201) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['GenericResource']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Updates a resource.
 *
 * @param {string} resourceGroupName The name of the resource group for the
 * resource. The name is case insensitive.
 *
 * @param {string} resourceProviderNamespace The namespace of the resource
 * provider.
 *
 * @param {string} parentResourcePath The parent resource identity.
 *
 * @param {string} resourceType The resource type of the resource to update.
 *
 * @param {string} resourceName The name of the resource to update.
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Parameters for updating the resource.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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.');
  }
  // 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 (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._\(\)]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._\(\)]+$/');
      }
    }
    if (resourceProviderNamespace === null || resourceProviderNamespace === undefined || typeof resourceProviderNamespace.valueOf() !== 'string') {
      throw new Error('resourceProviderNamespace cannot be null or undefined and it must be of type string.');
    }
    if (parentResourcePath === null || parentResourcePath === undefined || typeof parentResourcePath.valueOf() !== 'string') {
      throw new Error('parentResourcePath cannot be null or undefined and it must be of type string.');
    }
    if (resourceType === null || resourceType === undefined || typeof resourceType.valueOf() !== 'string') {
      throw new Error('resourceType cannot be null or undefined and it must be of type string.');
    }
    if (resourceName === null || resourceName === undefined || typeof resourceName.valueOf() !== 'string') {
      throw new Error('resourceName cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{resourceProviderNamespace}', encodeURIComponent(resourceProviderNamespace));
  requestUrl = requestUrl.replace('{parentResourcePath}', parentResourcePath);
  requestUrl = requestUrl.replace('{resourceType}', resourceType);
  requestUrl = requestUrl.replace('{resourceName}', encodeURIComponent(resourceName));
  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 = 'PATCH';
  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['GenericResource']().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['GenericResource']().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);
  });
}

/**
 * Deletes a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @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.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {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 _beginDeleteById(resourceId, apiVersion, 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.');
  }
  // Validate
  try {
    if (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') {
      throw new Error('resourceId cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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('/') ? '' : '/') + '{resourceId}';
  requestUrl = requestUrl.replace('{resourceId}', resourceId);
  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 = 'DELETE';
  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 && statusCode !== 202 && statusCode !== 204) {
      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;

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Create a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Create or update resource parameters.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _beginCreateOrUpdateById(resourceId, apiVersion, 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.');
  }
  // Validate
  try {
    if (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') {
      throw new Error('resourceId cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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.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('/') ? '' : '/') + '{resourceId}';
  requestUrl = requestUrl.replace('{resourceId}', resourceId);
  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 = 'PUT';
  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['GenericResource']().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 !== 201 && 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['GenericResource']().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);
      }
    }
    // Deserialize Response
    if (statusCode === 201) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['GenericResource']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

    return callback(null, result, httpRequest, response);
  });
}

/**
 * Updates a resource by ID.
 *
 * @param {string} resourceId The fully qualified ID of the resource, including
 * the resource name and resource type. Use the format,
 * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
 *
 * @param {string} apiVersion The API version to use for the operation.
 *
 * @param {object} parameters Update resource parameters.
 *
 * @param {object} [parameters.plan] The plan of the resource.
 *
 * @param {string} [parameters.plan.name] The plan ID.
 *
 * @param {string} [parameters.plan.publisher] The publisher ID.
 *
 * @param {string} [parameters.plan.product] The offer ID.
 *
 * @param {string} [parameters.plan.promotionCode] The promotion code.
 *
 * @param {string} [parameters.plan.version] The plan's version.
 *
 * @param {object} [parameters.properties] The resource properties.
 *
 * @param {string} [parameters.kind] The kind of the resource.
 *
 * @param {string} [parameters.managedBy] ID of the resource that manages this
 * resource.
 *
 * @param {object} [parameters.sku] The SKU of the resource.
 *
 * @param {string} [parameters.sku.name] The SKU name.
 *
 * @param {string} [parameters.sku.tier] The SKU tier.
 *
 * @param {string} [parameters.sku.size] The SKU size.
 *
 * @param {string} [parameters.sku.family] The SKU family.
 *
 * @param {string} [parameters.sku.model] The SKU model.
 *
 * @param {number} [parameters.sku.capacity] The SKU capacity.
 *
 * @param {object} [parameters.identity] The identity of the resource.
 *
 * @param {string} [parameters.identity.type] The identity type. Possible
 * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
 * UserAssigned', 'None'
 *
 * @param {object} [parameters.identity.userAssignedIdentities] The list of
 * user identities associated with the resource. The user identity dictionary
 * key references will be ARM resource ids in the form:
 * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
 *
 * @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 GenericResource} 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 _beginUpdateById(resourceId, apiVersion, 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.');
  }
  // Validate
  try {
    if (resourceId === null || resourceId === undefined || typeof resourceId.valueOf() !== 'string') {
      throw new Error('resourceId cannot be null or undefined and it must be of type string.');
    }
    if (apiVersion === null || apiVersion === undefined || typeof apiVersion.valueOf() !== 'string') {
      throw new Error('apiVersion 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.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('/') ? '' : '/') + '{resourceId}';
  requestUrl = requestUrl.replace('{resourceId}', resourceId);
  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 = 'PATCH';
  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['GenericResource']().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['GenericResource']().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);
  });
}

/**
 * Get all the resources for a resource group.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @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 ResourceListResult} 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 _listByResourceGroupNext(nextPageLink, 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.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink 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 requestUrl = '{nextLink}';
  requestUrl = requestUrl.replace('{nextLink}', nextPageLink);

  // 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['ResourceListResult']().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);
  });
}

/**
 * Get all the resources in a subscription.
 *
 * @param {string} nextPageLink The NextLink from the previous successful call
 * to List operation.
 *
 * @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 ResourceListResult} 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 _listNext(nextPageLink, 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.');
  }
  // Validate
  try {
    if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
      throw new Error('nextPageLink 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 requestUrl = '{nextLink}';
  requestUrl = requestUrl.replace('{nextLink}', nextPageLink);

  // 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['ResourceListResult']().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);
  });
}

/** Class representing a Resources. */
class Resources {
  /**
   * Create a Resources.
   * @param {ResourceManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._listByResourceGroup = _listByResourceGroup;
    this._moveResources = _moveResources;
    this._validateMoveResources = _validateMoveResources;
    this._list = _list;
    this._checkExistence = _checkExistence;
    this._deleteMethod = _deleteMethod;
    this._createOrUpdate = _createOrUpdate;
    this._update = _update;
    this._get = _get;
    this._checkExistenceById = _checkExistenceById;
    this._deleteById = _deleteById;
    this._createOrUpdateById = _createOrUpdateById;
    this._updateById = _updateById;
    this._getById = _getById;
    this._beginMoveResources = _beginMoveResources;
    this._beginValidateMoveResources = _beginValidateMoveResources;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginUpdate = _beginUpdate;
    this._beginDeleteById = _beginDeleteById;
    this._beginCreateOrUpdateById = _beginCreateOrUpdateById;
    this._beginUpdateById = _beginUpdateById;
    this._listByResourceGroupNext = _listByResourceGroupNext;
    this._listNext = _listNext;
  }

  /**
   * Get all the resources for a resource group.
   *
   * @param {string} resourceGroupName The resource group with the resources to
   * get.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.filter] The filter to apply on the
   * operation.<br><br>The properties you can use for eq (equals) or ne (not
   * equals) are: location, resourceType, name, resourceGroup, identity,
   * identity/principalId, plan, plan/publisher, plan/product, plan/name,
   * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
   * resource type, use: $filter=resourceType eq
   * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
   * property) in the filter. The properties you can use for substring are: name
   * and resourceGroup.<br><br>For example, to get all resources with 'demo'
   * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
   * link more than one substringof together by adding and/or
   * operators.<br><br>You can filter by tag names and values. For example, to
   * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
   * eq 'Value1'<br><br>You can use some properties together when filtering. The
   * combinations you can use are: substringof and/or resourceType, plan and
   * plan/publisher and plan/name, identity and identity/principalId.
   *
   * @param {string} [options.expand] The $expand query parameter. You can expand
   * createdTime and changedTime. For example, to expand both properties, use
   * $expand=changedTime,createdTime
   *
   * @param {number} [options.top] The number of results to return. If null is
   * passed, returns all resources.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ResourceListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get all the resources for a resource group.
   *
   * @param {string} resourceGroupName The resource group with the resources to
   * get.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.filter] The filter to apply on the
   * operation.<br><br>The properties you can use for eq (equals) or ne (not
   * equals) are: location, resourceType, name, resourceGroup, identity,
   * identity/principalId, plan, plan/publisher, plan/product, plan/name,
   * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
   * resource type, use: $filter=resourceType eq
   * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
   * property) in the filter. The properties you can use for substring are: name
   * and resourceGroup.<br><br>For example, to get all resources with 'demo'
   * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
   * link more than one substringof together by adding and/or
   * operators.<br><br>You can filter by tag names and values. For example, to
   * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
   * eq 'Value1'<br><br>You can use some properties together when filtering. The
   * combinations you can use are: substringof and/or resourceType, plan and
   * plan/publisher and plan/name, identity and identity/principalId.
   *
   * @param {string} [options.expand] The $expand query parameter. You can expand
   * createdTime and changedTime. For example, to expand both properties, use
   * $expand=changedTime,createdTime
   *
   * @param {number} [options.top] The number of results to return. If null is
   * passed, returns all resources.
   *
   * @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 {ResourceListResult} - 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 ResourceListResult} 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.
   */
  listByResourceGroup(resourceGroupName, 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._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroup(resourceGroupName, options, optionalCallback);
    }
  }

  /**
   * @summary Moves resources from one resource group to another resource group.
   *
   * The resources to move must be in the same source resource group. The target
   * resource group may be in a different subscription. When moving resources,
   * both the source group and the target group are locked for the duration of
   * the operation. Write and delete operations are blocked on the groups until
   * the move completes.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  moveResourcesWithHttpOperationResponse(sourceResourceGroupName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._moveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Moves resources from one resource group to another resource group.
   *
   * The resources to move must be in the same source resource group. The target
   * resource group may be in a different subscription. When moving resources,
   * both the source group and the target group are locked for the duration of
   * the operation. Write and delete operations are blocked on the groups until
   * the move completes.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  moveResources(sourceResourceGroupName, 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._moveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._moveResources(sourceResourceGroupName, parameters, options, optionalCallback);
    }
  }

  /**
   * @summary Validates whether resources can be moved from one resource group to
   * another resource group.
   *
   * This operation checks whether the specified resources can be moved to the
   * target. The resources to move must be in the same source resource group. The
   * target resource group may be in a different subscription. If validation
   * succeeds, it returns HTTP response code 204 (no content). If validation
   * fails, it returns HTTP response code 409 (Conflict) with an error message.
   * Retrieve the URL in the Location header value to check the result of the
   * long-running operation.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to validate for move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  validateMoveResourcesWithHttpOperationResponse(sourceResourceGroupName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._validateMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Validates whether resources can be moved from one resource group to
   * another resource group.
   *
   * This operation checks whether the specified resources can be moved to the
   * target. The resources to move must be in the same source resource group. The
   * target resource group may be in a different subscription. If validation
   * succeeds, it returns HTTP response code 204 (no content). If validation
   * fails, it returns HTTP response code 409 (Conflict) with an error message.
   * Retrieve the URL in the Location header value to check the result of the
   * long-running operation.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to validate for move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  validateMoveResources(sourceResourceGroupName, 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._validateMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._validateMoveResources(sourceResourceGroupName, parameters, options, optionalCallback);
    }
  }

  /**
   * Get all the resources in a subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.filter] The filter to apply on the
   * operation.<br><br>The properties you can use for eq (equals) or ne (not
   * equals) are: location, resourceType, name, resourceGroup, identity,
   * identity/principalId, plan, plan/publisher, plan/product, plan/name,
   * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
   * resource type, use: $filter=resourceType eq
   * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
   * property) in the filter. The properties you can use for substring are: name
   * and resourceGroup.<br><br>For example, to get all resources with 'demo'
   * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
   * link more than one substringof together by adding and/or
   * operators.<br><br>You can filter by tag names and values. For example, to
   * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
   * eq 'Value1'<br><br>You can use some properties together when filtering. The
   * combinations you can use are: substringof and/or resourceType, plan and
   * plan/publisher and plan/name, identity and identity/principalId.
   *
   * @param {string} [options.expand] The $expand query parameter. You can expand
   * createdTime and changedTime. For example, to expand both properties, use
   * $expand=changedTime,createdTime
   *
   * @param {number} [options.top] The number of results to return. If null is
   * passed, returns all resource groups.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<ResourceListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listWithHttpOperationResponse(options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._list(options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get all the resources in a subscription.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.filter] The filter to apply on the
   * operation.<br><br>The properties you can use for eq (equals) or ne (not
   * equals) are: location, resourceType, name, resourceGroup, identity,
   * identity/principalId, plan, plan/publisher, plan/product, plan/name,
   * plan/version, and plan/promotionCode.<br><br>For example, to filter by a
   * resource type, use: $filter=resourceType eq
   * 'Microsoft.Network/virtualNetworks'<br><br>You can use substringof(value,
   * property) in the filter. The properties you can use for substring are: name
   * and resourceGroup.<br><br>For example, to get all resources with 'demo'
   * anywhere in the name, use: $filter=substringof('demo', name)<br><br>You can
   * link more than one substringof together by adding and/or
   * operators.<br><br>You can filter by tag names and values. For example, to
   * filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue
   * eq 'Value1'<br><br>You can use some properties together when filtering. The
   * combinations you can use are: substringof and/or resourceType, plan and
   * plan/publisher and plan/name, identity and identity/principalId.
   *
   * @param {string} [options.expand] The $expand query parameter. You can expand
   * createdTime and changedTime. For example, to expand both properties, use
   * $expand=changedTime,createdTime
   *
   * @param {number} [options.top] The number of results to return. If null is
   * passed, returns all resource groups.
   *
   * @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 {ResourceListResult} - 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 ResourceListResult} 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.
   */
  list(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._list(options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._list(options, optionalCallback);
    }
  }

  /**
   * Checks whether a resource exists.
   *
   * @param {string} resourceGroupName The name of the resource group containing
   * the resource to check. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The resource provider of the
   * resource to check.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to check whether it
   * exists.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<Boolean>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  checkExistenceWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Checks whether a resource exists.
   *
   * @param {string} resourceGroupName The name of the resource group containing
   * the resource to check. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The resource provider of the
   * resource to check.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to check whether it
   * exists.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {Boolean} - 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.
   *
   *                      {boolean} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._checkExistence(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Deletes a resource.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource to delete. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to delete.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a resource.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource to delete. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to delete.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._deleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Creates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to create.
   *
   * @param {string} resourceName The name of the resource to create.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for creating or updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to create.
   *
   * @param {string} resourceName The name of the resource to create.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for creating or updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to update.
   *
   * @param {string} resourceName The name of the resource to update.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to update.
   *
   * @param {string} resourceName The name of the resource to update.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  update(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._update(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Gets a resource.
   *
   * @param {string} resourceGroupName The name of the resource group containing
   * the resource to get. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource.
   *
   * @param {string} resourceName The name of the resource to get.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a resource.
   *
   * @param {string} resourceGroupName The name of the resource group containing
   * the resource to get. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource.
   *
   * @param {string} resourceName The name of the resource to get.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {GenericResource} - 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 GenericResource} 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.
   */
  get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Checks by ID whether a resource exists.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<Boolean>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  checkExistenceByIdWithHttpOperationResponse(resourceId, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._checkExistenceById(resourceId, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Checks by ID whether a resource exists.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {Boolean} - 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.
   *
   *                      {boolean} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  checkExistenceById(resourceId, apiVersion, 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._checkExistenceById(resourceId, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._checkExistenceById(resourceId, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Deletes a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteByIdWithHttpOperationResponse(resourceId, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteById(resourceId, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteById(resourceId, apiVersion, 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._deleteById(resourceId, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteById(resourceId, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Create a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Create or update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateByIdWithHttpOperationResponse(resourceId, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Create or update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  createOrUpdateById(resourceId, apiVersion, 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._createOrUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdateById(resourceId, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateByIdWithHttpOperationResponse(resourceId, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._updateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  updateById(resourceId, apiVersion, 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._updateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._updateById(resourceId, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Gets a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getByIdWithHttpOperationResponse(resourceId, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getById(resourceId, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {GenericResource} - 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 GenericResource} 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.
   */
  getById(resourceId, apiVersion, 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._getById(resourceId, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getById(resourceId, apiVersion, options, optionalCallback);
    }
  }

  /**
   * @summary Moves resources from one resource group to another resource group.
   *
   * The resources to move must be in the same source resource group. The target
   * resource group may be in a different subscription. When moving resources,
   * both the source group and the target group are locked for the duration of
   * the operation. Write and delete operations are blocked on the groups until
   * the move completes.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginMoveResourcesWithHttpOperationResponse(sourceResourceGroupName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Moves resources from one resource group to another resource group.
   *
   * The resources to move must be in the same source resource group. The target
   * resource group may be in a different subscription. When moving resources,
   * both the source group and the target group are locked for the duration of
   * the operation. Write and delete operations are blocked on the groups until
   * the move completes.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginMoveResources(sourceResourceGroupName, 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._beginMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginMoveResources(sourceResourceGroupName, parameters, options, optionalCallback);
    }
  }

  /**
   * @summary Validates whether resources can be moved from one resource group to
   * another resource group.
   *
   * This operation checks whether the specified resources can be moved to the
   * target. The resources to move must be in the same source resource group. The
   * target resource group may be in a different subscription. If validation
   * succeeds, it returns HTTP response code 204 (no content). If validation
   * fails, it returns HTTP response code 409 (Conflict) with an error message.
   * Retrieve the URL in the Location header value to check the result of the
   * long-running operation.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to validate for move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginValidateMoveResourcesWithHttpOperationResponse(sourceResourceGroupName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginValidateMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * @summary Validates whether resources can be moved from one resource group to
   * another resource group.
   *
   * This operation checks whether the specified resources can be moved to the
   * target. The resources to move must be in the same source resource group. The
   * target resource group may be in a different subscription. If validation
   * succeeds, it returns HTTP response code 204 (no content). If validation
   * fails, it returns HTTP response code 409 (Conflict) with an error message.
   * Retrieve the URL in the Location header value to check the result of the
   * long-running operation.
   *
   * @param {string} sourceResourceGroupName The name of the resource group
   * containing the resources to validate for move.
   *
   * @param {object} parameters Parameters for moving resources.
   *
   * @param {array} [parameters.resources] The IDs of the resources.
   *
   * @param {string} [parameters.targetResourceGroup] The target resource group.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginValidateMoveResources(sourceResourceGroupName, 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._beginValidateMoveResources(sourceResourceGroupName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginValidateMoveResources(sourceResourceGroupName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a resource.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource to delete. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to delete.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a resource.
   *
   * @param {string} resourceGroupName The name of the resource group that
   * contains the resource to delete. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type.
   *
   * @param {string} resourceName The name of the resource to delete.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Creates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to create.
   *
   * @param {string} resourceName The name of the resource to create.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for creating or updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to create.
   *
   * @param {string} resourceName The name of the resource to create.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for creating or updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to update.
   *
   * @param {string} resourceName The name of the resource to update.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateWithHttpOperationResponse(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates a resource.
   *
   * @param {string} resourceGroupName The name of the resource group for the
   * resource. The name is case insensitive.
   *
   * @param {string} resourceProviderNamespace The namespace of the resource
   * provider.
   *
   * @param {string} parentResourcePath The parent resource identity.
   *
   * @param {string} resourceType The resource type of the resource to update.
   *
   * @param {string} resourceName The name of the resource to update.
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Parameters for updating the resource.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, 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._beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdate(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteByIdWithHttpOperationResponse(resourceId, apiVersion, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteById(resourceId, apiVersion, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @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 {null} - 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.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteById(resourceId, apiVersion, 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._beginDeleteById(resourceId, apiVersion, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteById(resourceId, apiVersion, options, optionalCallback);
    }
  }

  /**
   * Create a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Create or update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateByIdWithHttpOperationResponse(resourceId, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Create or update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  beginCreateOrUpdateById(resourceId, apiVersion, 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._beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdateById(resourceId, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Updates a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<GenericResource>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateByIdWithHttpOperationResponse(resourceId, apiVersion, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates a resource by ID.
   *
   * @param {string} resourceId The fully qualified ID of the resource, including
   * the resource name and resource type. Use the format,
   * /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
   *
   * @param {string} apiVersion The API version to use for the operation.
   *
   * @param {object} parameters Update resource parameters.
   *
   * @param {object} [parameters.plan] The plan of the resource.
   *
   * @param {string} [parameters.plan.name] The plan ID.
   *
   * @param {string} [parameters.plan.publisher] The publisher ID.
   *
   * @param {string} [parameters.plan.product] The offer ID.
   *
   * @param {string} [parameters.plan.promotionCode] The promotion code.
   *
   * @param {string} [parameters.plan.version] The plan's version.
   *
   * @param {object} [parameters.properties] The resource properties.
   *
   * @param {string} [parameters.kind] The kind of the resource.
   *
   * @param {string} [parameters.managedBy] ID of the resource that manages this
   * resource.
   *
   * @param {object} [parameters.sku] The SKU of the resource.
   *
   * @param {string} [parameters.sku.name] The SKU name.
   *
   * @param {string} [parameters.sku.tier] The SKU tier.
   *
   * @param {string} [parameters.sku.size] The SKU size.
   *
   * @param {string} [parameters.sku.family] The SKU family.
   *
   * @param {string} [parameters.sku.model] The SKU model.
   *
   * @param {number} [parameters.sku.capacity] The SKU capacity.
   *
   * @param {object} [parameters.identity] The identity of the resource.
   *
   * @param {string} [parameters.identity.type] The identity type. Possible
   * values include: 'SystemAssigned', 'UserAssigned', 'SystemAssigned,
   * UserAssigned', 'None'
   *
   * @param {object} [parameters.identity.userAssignedIdentities] The list of
   * user identities associated with the resource. The user identity dictionary
   * key references will be ARM resource ids in the form:
   * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
   *
   * @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} [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 {GenericResource} - 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 GenericResource} 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.
   */
  beginUpdateById(resourceId, apiVersion, 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._beginUpdateById(resourceId, apiVersion, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdateById(resourceId, apiVersion, parameters, options, optionalCallback);
    }
  }

  /**
   * Get all the resources for a resource group.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @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<ResourceListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get all the resources for a resource group.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @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 {ResourceListResult} - 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 ResourceListResult} 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.
   */
  listByResourceGroupNext(nextPageLink, 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._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByResourceGroupNext(nextPageLink, options, optionalCallback);
    }
  }

  /**
   * Get all the resources in a subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @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<ResourceListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get all the resources in a subscription.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @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 {ResourceListResult} - 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 ResourceListResult} 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.
   */
  listNext(nextPageLink, 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._listNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = Resources;
