text:
'use strict';

const msRest = require('ms-rest');
const msRestAzure = require('ms-rest-azure');
const WebResource = msRest.WebResource;

/**
 * Creates or updates a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} snapshot Snapshot object supplied in the body of the Put
 * disk operation.
 *
 * @param {object} [snapshot.sku]
 *
 * @param {string} [snapshot.sku.name] The sku name. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @param {string} [snapshot.osType] The Operating System type. Possible values
 * include: 'Windows', 'Linux'
 *
 * @param {object} snapshot.creationData Disk source information. CreationData
 * information cannot be changed after the disk has been created.
 *
 * @param {string} snapshot.creationData.createOption This enumerates the
 * possible sources of a disk's creation. Possible values include: 'Empty',
 * 'Attach', 'FromImage', 'Import', 'Copy'
 *
 * @param {string} [snapshot.creationData.storageAccountId] If createOption is
 * Import, the Azure Resource Manager identifier of the storage account
 * containing the blob to import as a disk. Required only if the blob is in a
 * different subscription
 *
 * @param {object} [snapshot.creationData.imageReference] Disk source
 * information.
 *
 * @param {string} snapshot.creationData.imageReference.id A relative uri
 * containing either a Platform Imgage Repository or user image reference.
 *
 * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
 * created from an image's data disk, this is an index that indicates which of
 * the data disks in the image to use. For OS disks, this field is null.
 *
 * @param {string} [snapshot.creationData.sourceUri] If creationOption is
 * Import, this is the URI of a blob to be imported into a managed disk.
 *
 * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
 * Copy, this is the ARM id of the source snapshot or disk.
 *
 * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
 * this field is mandatory and it indicates the size of the VHD to create. If
 * this field is present for updates or creation with other options, it
 * indicates a resize. Resizes are only allowed if the disk is not attached to
 * a running VM, and can only increase the disk's size.
 *
 * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
 * or snapshot
 *
 * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
 * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
 * encryption. Set this flag to false and remove DiskEncryptionKey and
 * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
 * request object, the existing settings remain unchanged.
 *
 * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
 * Secret Url and vault id of the disk encryption key
 *
 * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
 * Url and vault id of the key encryption key
 *
 * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string}
 * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
 *
 * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {string} snapshot.location Resource location
 *
 * @param {object} [snapshot.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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, 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['Snapshot']().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 (patches) a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} snapshot Snapshot object supplied in the body of the Patch
 * snapshot operation.
 *
 * @param {string} [snapshot.osType] the Operating System type. Possible values
 * include: 'Windows', 'Linux'
 *
 * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
 * this field is mandatory and it indicates the size of the VHD to create. If
 * this field is present for updates or creation with other options, it
 * indicates a resize. Resizes are only allowed if the disk is not attached to
 * a running VM, and can only increase the disk's size.
 *
 * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
 * or snapshot
 *
 * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
 * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
 * encryption. Set this flag to false and remove DiskEncryptionKey and
 * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
 * request object, the existing settings remain unchanged.
 *
 * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
 * Secret Url and vault id of the disk encryption key
 *
 * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
 * Url and vault id of the key encryption key
 *
 * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string}
 * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
 *
 * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.tags] Resource tags
 *
 * @param {object} [snapshot.sku]
 *
 * @param {string} [snapshot.sku.name] The sku name. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, 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['Snapshot']().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 information about a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link Snapshot} 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, snapshotName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  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['Snapshot']().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 snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link OperationStatusResponse} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _deleteMethod(resourceGroupName, snapshotName, 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, snapshotName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['OperationStatusResponse']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }

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

/**
 * Lists snapshots under a resource group.
 *
 * @param {string} resourceGroupName The name of the 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link SnapshotList} 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 apiVersion = '2017-03-30';
  // Validate
  try {
    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 (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 (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  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['SnapshotList']().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);
  });
}

/**
 * Lists snapshots under a subscription.
 *
 * @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 SnapshotList} 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 apiVersion = '2017-03-30';
  // Validate
  try {
    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}/providers/Microsoft.Compute/snapshots';
  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['SnapshotList']().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);
  });
}

/**
 * Grants access to a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} grantAccessData Access data object supplied in the body of
 * the get snapshot access operation.
 *
 * @param {string} grantAccessData.access Possible values include: 'None',
 * 'Read'
 *
 * @param {number} grantAccessData.durationInSeconds Time duration in seconds
 * until the SAS access expires.
 *
 * @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 AccessUri} 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 _grantAccess(resourceGroupName, snapshotName, grantAccessData, 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.beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, 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['AccessUri']().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);
    });
  });
}

/**
 * Revokes access to a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link OperationStatusResponse} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _revokeAccess(resourceGroupName, snapshotName, 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.beginRevokeAccess(resourceGroupName, snapshotName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

    let initialResult = new msRest.HttpOperationResponse();
    initialResult.request = httpRequest;
    initialResult.response = response;
    initialResult.body = response.body;
    client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);

      // Create Result
      let result = null;

      httpRequest = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['OperationStatusResponse']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }

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

/**
 * Creates or updates a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} snapshot Snapshot object supplied in the body of the Put
 * disk operation.
 *
 * @param {object} [snapshot.sku]
 *
 * @param {string} [snapshot.sku.name] The sku name. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @param {string} [snapshot.osType] The Operating System type. Possible values
 * include: 'Windows', 'Linux'
 *
 * @param {object} snapshot.creationData Disk source information. CreationData
 * information cannot be changed after the disk has been created.
 *
 * @param {string} snapshot.creationData.createOption This enumerates the
 * possible sources of a disk's creation. Possible values include: 'Empty',
 * 'Attach', 'FromImage', 'Import', 'Copy'
 *
 * @param {string} [snapshot.creationData.storageAccountId] If createOption is
 * Import, the Azure Resource Manager identifier of the storage account
 * containing the blob to import as a disk. Required only if the blob is in a
 * different subscription
 *
 * @param {object} [snapshot.creationData.imageReference] Disk source
 * information.
 *
 * @param {string} snapshot.creationData.imageReference.id A relative uri
 * containing either a Platform Imgage Repository or user image reference.
 *
 * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
 * created from an image's data disk, this is an index that indicates which of
 * the data disks in the image to use. For OS disks, this field is null.
 *
 * @param {string} [snapshot.creationData.sourceUri] If creationOption is
 * Import, this is the URI of a blob to be imported into a managed disk.
 *
 * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
 * Copy, this is the ARM id of the source snapshot or disk.
 *
 * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
 * this field is mandatory and it indicates the size of the VHD to create. If
 * this field is present for updates or creation with other options, it
 * indicates a resize. Resizes are only allowed if the disk is not attached to
 * a running VM, and can only increase the disk's size.
 *
 * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
 * or snapshot
 *
 * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
 * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
 * encryption. Set this flag to false and remove DiskEncryptionKey and
 * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
 * request object, the existing settings remain unchanged.
 *
 * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
 * Secret Url and vault id of the disk encryption key
 *
 * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
 * Url and vault id of the key encryption key
 *
 * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string}
 * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
 *
 * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {string} snapshot.location Resource location
 *
 * @param {object} [snapshot.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 Snapshot} 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, snapshotName, snapshot, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (snapshot === null || snapshot === undefined) {
      throw new Error('snapshot 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  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 (snapshot !== null && snapshot !== undefined) {
      let requestModelMapper = new client.models['Snapshot']().mapper();
      requestModel = client.serialize(requestModelMapper, snapshot, 'snapshot');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(snapshot, 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['Snapshot']().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 === 202) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['Snapshot']().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 (patches) a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} snapshot Snapshot object supplied in the body of the Patch
 * snapshot operation.
 *
 * @param {string} [snapshot.osType] the Operating System type. Possible values
 * include: 'Windows', 'Linux'
 *
 * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
 * this field is mandatory and it indicates the size of the VHD to create. If
 * this field is present for updates or creation with other options, it
 * indicates a resize. Resizes are only allowed if the disk is not attached to
 * a running VM, and can only increase the disk's size.
 *
 * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
 * or snapshot
 *
 * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
 * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
 * encryption. Set this flag to false and remove DiskEncryptionKey and
 * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
 * request object, the existing settings remain unchanged.
 *
 * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
 * Secret Url and vault id of the disk encryption key
 *
 * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
 * Url and vault id of the key encryption key
 *
 * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
 * Resource id of the KeyVault containing the key or secret
 *
 * @param {string}
 * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
 *
 * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
 * pointing to a key or secret in KeyVault
 *
 * @param {object} [snapshot.tags] Resource tags
 *
 * @param {object} [snapshot.sku]
 *
 * @param {string} [snapshot.sku.name] The sku name. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @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 Snapshot} 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, snapshotName, snapshot, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (snapshot === null || snapshot === undefined) {
      throw new Error('snapshot 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  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 (snapshot !== null && snapshot !== undefined) {
      let requestModelMapper = new client.models['SnapshotUpdate']().mapper();
      requestModel = client.serialize(requestModelMapper, snapshot, 'snapshot');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(snapshot, 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['Snapshot']().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 === 202) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['Snapshot']().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);
  });
}

/**
 * Deletes a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link OperationStatusResponse} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(resourceGroupName, snapshotName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  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;
    // 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['OperationStatusResponse']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Grants access to a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and resource group.
 *
 * @param {object} grantAccessData Access data object supplied in the body of
 * the get snapshot access operation.
 *
 * @param {string} grantAccessData.access Possible values include: 'None',
 * 'Read'
 *
 * @param {number} grantAccessData.durationInSeconds Time duration in seconds
 * until the SAS access expires.
 *
 * @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 AccessUri} 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 _beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (grantAccessData === null || grantAccessData === undefined) {
      throw new Error('grantAccessData 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('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (grantAccessData !== null && grantAccessData !== undefined) {
      let requestModelMapper = new client.models['GrantAccessData']().mapper();
      requestModel = client.serialize(requestModelMapper, grantAccessData, 'grantAccessData');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(grantAccessData, 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['AccessUri']().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);
  });
}

/**
 * Revokes access to a snapshot.
 *
 * @param {string} resourceGroupName The name of the resource group.
 *
 * @param {string} snapshotName The name of the snapshot within the given
 * subscription and 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.
 *
 *                      {object} [result]   - The deserialized result object if an error did not occur.
 *                      See {@link OperationStatusResponse} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginRevokeAccess(resourceGroupName, snapshotName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let apiVersion = '2017-03-30';
  // Validate
  try {
    if (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 (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 (snapshotName === null || snapshotName === undefined || typeof snapshotName.valueOf() !== 'string') {
      throw new Error('snapshotName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{snapshotName}', encodeURIComponent(snapshotName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  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) {
      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['OperationStatusResponse']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Lists snapshots under 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 SnapshotList} 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['SnapshotList']().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);
  });
}

/**
 * Lists snapshots under 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 SnapshotList} 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['SnapshotList']().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 Snapshots. */
class Snapshots {
  /**
   * Create a Snapshots.
   * @param {ComputeManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._createOrUpdate = _createOrUpdate;
    this._update = _update;
    this._get = _get;
    this._deleteMethod = _deleteMethod;
    this._listByResourceGroup = _listByResourceGroup;
    this._list = _list;
    this._grantAccess = _grantAccess;
    this._revokeAccess = _revokeAccess;
    this._beginCreateOrUpdate = _beginCreateOrUpdate;
    this._beginUpdate = _beginUpdate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._beginGrantAccess = _beginGrantAccess;
    this._beginRevokeAccess = _beginRevokeAccess;
    this._listByResourceGroupNext = _listByResourceGroupNext;
    this._listNext = _listNext;
  }

  /**
   * Creates or updates a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Put
   * disk operation.
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {string} [snapshot.osType] The Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {object} snapshot.creationData Disk source information. CreationData
   * information cannot be changed after the disk has been created.
   *
   * @param {string} snapshot.creationData.createOption This enumerates the
   * possible sources of a disk's creation. Possible values include: 'Empty',
   * 'Attach', 'FromImage', 'Import', 'Copy'
   *
   * @param {string} [snapshot.creationData.storageAccountId] If createOption is
   * Import, the Azure Resource Manager identifier of the storage account
   * containing the blob to import as a disk. Required only if the blob is in a
   * different subscription
   *
   * @param {object} [snapshot.creationData.imageReference] Disk source
   * information.
   *
   * @param {string} snapshot.creationData.imageReference.id A relative uri
   * containing either a Platform Imgage Repository or user image reference.
   *
   * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
   * created from an image's data disk, this is an index that indicates which of
   * the data disks in the image to use. For OS disks, this field is null.
   *
   * @param {string} [snapshot.creationData.sourceUri] If creationOption is
   * Import, this is the URI of a blob to be imported into a managed disk.
   *
   * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
   * Copy, this is the ARM id of the source snapshot or disk.
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {string} snapshot.location Resource location
   *
   * @param {object} [snapshot.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<Snapshot>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateWithHttpOperationResponse(resourceGroupName, snapshotName, snapshot, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdate(resourceGroupName, snapshotName, snapshot, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Put
   * disk operation.
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {string} [snapshot.osType] The Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {object} snapshot.creationData Disk source information. CreationData
   * information cannot be changed after the disk has been created.
   *
   * @param {string} snapshot.creationData.createOption This enumerates the
   * possible sources of a disk's creation. Possible values include: 'Empty',
   * 'Attach', 'FromImage', 'Import', 'Copy'
   *
   * @param {string} [snapshot.creationData.storageAccountId] If createOption is
   * Import, the Azure Resource Manager identifier of the storage account
   * containing the blob to import as a disk. Required only if the blob is in a
   * different subscription
   *
   * @param {object} [snapshot.creationData.imageReference] Disk source
   * information.
   *
   * @param {string} snapshot.creationData.imageReference.id A relative uri
   * containing either a Platform Imgage Repository or user image reference.
   *
   * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
   * created from an image's data disk, this is an index that indicates which of
   * the data disks in the image to use. For OS disks, this field is null.
   *
   * @param {string} [snapshot.creationData.sourceUri] If creationOption is
   * Import, this is the URI of a blob to be imported into a managed disk.
   *
   * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
   * Copy, this is the ARM id of the source snapshot or disk.
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {string} snapshot.location Resource location
   *
   * @param {object} [snapshot.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 {Snapshot} - 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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdate(resourceGroupName, snapshotName, snapshot, options, optionalCallback);
    }
  }

  /**
   * Updates (patches) a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Patch
   * snapshot operation.
   *
   * @param {string} [snapshot.osType] the Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.tags] Resource tags
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @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<Snapshot>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateWithHttpOperationResponse(resourceGroupName, snapshotName, snapshot, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._update(resourceGroupName, snapshotName, snapshot, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates (patches) a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Patch
   * snapshot operation.
   *
   * @param {string} [snapshot.osType] the Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.tags] Resource tags
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @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 {Snapshot} - 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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._update(resourceGroupName, snapshotName, snapshot, options, optionalCallback);
    }
  }

  /**
   * Gets information about a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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<Snapshot>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, snapshotName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, snapshotName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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 {Snapshot} - 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 Snapshot} 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, snapshotName, 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, snapshotName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, snapshotName, options, optionalCallback);
    }
  }

  /**
   * Deletes a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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<OperationStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(resourceGroupName, snapshotName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, snapshotName, 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 snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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 {OperationStatusResponse} - 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 OperationStatusResponse} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(resourceGroupName, snapshotName, 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, snapshotName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, snapshotName, options, optionalCallback);
    }
  }

  /**
   * Lists snapshots under a resource group.
   *
   * @param {string} resourceGroupName The name of the 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<SnapshotList>} - 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;
      });
    });
  }

  /**
   * Lists snapshots under a resource group.
   *
   * @param {string} resourceGroupName The name of the 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 {SnapshotList} - 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 SnapshotList} 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);
    }
  }

  /**
   * Lists snapshots under a subscription.
   *
   * @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<SnapshotList>} - 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;
      });
    });
  }

  /**
   * Lists snapshots under a subscription.
   *
   * @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 {SnapshotList} - 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 SnapshotList} 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);
    }
  }

  /**
   * Grants access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} grantAccessData Access data object supplied in the body of
   * the get snapshot access operation.
   *
   * @param {string} grantAccessData.access Possible values include: 'None',
   * 'Read'
   *
   * @param {number} grantAccessData.durationInSeconds Time duration in seconds
   * until the SAS access expires.
   *
   * @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<AccessUri>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  grantAccessWithHttpOperationResponse(resourceGroupName, snapshotName, grantAccessData, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._grantAccess(resourceGroupName, snapshotName, grantAccessData, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Grants access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} grantAccessData Access data object supplied in the body of
   * the get snapshot access operation.
   *
   * @param {string} grantAccessData.access Possible values include: 'None',
   * 'Read'
   *
   * @param {number} grantAccessData.durationInSeconds Time duration in seconds
   * until the SAS access expires.
   *
   * @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 {AccessUri} - 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 AccessUri} 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.
   */
  grantAccess(resourceGroupName, snapshotName, grantAccessData, 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._grantAccess(resourceGroupName, snapshotName, grantAccessData, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._grantAccess(resourceGroupName, snapshotName, grantAccessData, options, optionalCallback);
    }
  }

  /**
   * Revokes access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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<OperationStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  revokeAccessWithHttpOperationResponse(resourceGroupName, snapshotName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._revokeAccess(resourceGroupName, snapshotName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Revokes access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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 {OperationStatusResponse} - 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 OperationStatusResponse} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  revokeAccess(resourceGroupName, snapshotName, 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._revokeAccess(resourceGroupName, snapshotName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._revokeAccess(resourceGroupName, snapshotName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Put
   * disk operation.
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {string} [snapshot.osType] The Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {object} snapshot.creationData Disk source information. CreationData
   * information cannot be changed after the disk has been created.
   *
   * @param {string} snapshot.creationData.createOption This enumerates the
   * possible sources of a disk's creation. Possible values include: 'Empty',
   * 'Attach', 'FromImage', 'Import', 'Copy'
   *
   * @param {string} [snapshot.creationData.storageAccountId] If createOption is
   * Import, the Azure Resource Manager identifier of the storage account
   * containing the blob to import as a disk. Required only if the blob is in a
   * different subscription
   *
   * @param {object} [snapshot.creationData.imageReference] Disk source
   * information.
   *
   * @param {string} snapshot.creationData.imageReference.id A relative uri
   * containing either a Platform Imgage Repository or user image reference.
   *
   * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
   * created from an image's data disk, this is an index that indicates which of
   * the data disks in the image to use. For OS disks, this field is null.
   *
   * @param {string} [snapshot.creationData.sourceUri] If creationOption is
   * Import, this is the URI of a blob to be imported into a managed disk.
   *
   * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
   * Copy, this is the ARM id of the source snapshot or disk.
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {string} snapshot.location Resource location
   *
   * @param {object} [snapshot.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<Snapshot>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, snapshotName, snapshot, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdate(resourceGroupName, snapshotName, snapshot, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Put
   * disk operation.
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {string} [snapshot.osType] The Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {object} snapshot.creationData Disk source information. CreationData
   * information cannot be changed after the disk has been created.
   *
   * @param {string} snapshot.creationData.createOption This enumerates the
   * possible sources of a disk's creation. Possible values include: 'Empty',
   * 'Attach', 'FromImage', 'Import', 'Copy'
   *
   * @param {string} [snapshot.creationData.storageAccountId] If createOption is
   * Import, the Azure Resource Manager identifier of the storage account
   * containing the blob to import as a disk. Required only if the blob is in a
   * different subscription
   *
   * @param {object} [snapshot.creationData.imageReference] Disk source
   * information.
   *
   * @param {string} snapshot.creationData.imageReference.id A relative uri
   * containing either a Platform Imgage Repository or user image reference.
   *
   * @param {number} [snapshot.creationData.imageReference.lun] If the disk is
   * created from an image's data disk, this is an index that indicates which of
   * the data disks in the image to use. For OS disks, this field is null.
   *
   * @param {string} [snapshot.creationData.sourceUri] If creationOption is
   * Import, this is the URI of a blob to be imported into a managed disk.
   *
   * @param {string} [snapshot.creationData.sourceResourceId] If createOption is
   * Copy, this is the ARM id of the source snapshot or disk.
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {string} snapshot.location Resource location
   *
   * @param {object} [snapshot.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 {Snapshot} - 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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdate(resourceGroupName, snapshotName, snapshot, options, optionalCallback);
    }
  }

  /**
   * Updates (patches) a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Patch
   * snapshot operation.
   *
   * @param {string} [snapshot.osType] the Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.tags] Resource tags
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @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<Snapshot>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateWithHttpOperationResponse(resourceGroupName, snapshotName, snapshot, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdate(resourceGroupName, snapshotName, snapshot, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates (patches) a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} snapshot Snapshot object supplied in the body of the Patch
   * snapshot operation.
   *
   * @param {string} [snapshot.osType] the Operating System type. Possible values
   * include: 'Windows', 'Linux'
   *
   * @param {number} [snapshot.diskSizeGB] If creationData.createOption is Empty,
   * this field is mandatory and it indicates the size of the VHD to create. If
   * this field is present for updates or creation with other options, it
   * indicates a resize. Resizes are only allowed if the disk is not attached to
   * a running VM, and can only increase the disk's size.
   *
   * @param {object} [snapshot.encryptionSettings] Encryption settings for disk
   * or snapshot
   *
   * @param {boolean} [snapshot.encryptionSettings.enabled] Set this flag to true
   * and provide DiskEncryptionKey and optional KeyEncryptionKey to enable
   * encryption. Set this flag to false and remove DiskEncryptionKey and
   * KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the
   * request object, the existing settings remain unchanged.
   *
   * @param {object} [snapshot.encryptionSettings.diskEncryptionKey] Key Vault
   * Secret Url and vault id of the disk encryption key
   *
   * @param {object} snapshot.encryptionSettings.diskEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string} snapshot.encryptionSettings.diskEncryptionKey.secretUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.encryptionSettings.keyEncryptionKey] Key Vault Key
   * Url and vault id of the key encryption key
   *
   * @param {object} snapshot.encryptionSettings.keyEncryptionKey.sourceVault
   * Resource id of the KeyVault containing the key or secret
   *
   * @param {string}
   * [snapshot.encryptionSettings.keyEncryptionKey.sourceVault.id] Resource Id
   *
   * @param {string} snapshot.encryptionSettings.keyEncryptionKey.keyUrl Url
   * pointing to a key or secret in KeyVault
   *
   * @param {object} [snapshot.tags] Resource tags
   *
   * @param {object} [snapshot.sku]
   *
   * @param {string} [snapshot.sku.name] The sku name. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @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 {Snapshot} - 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 Snapshot} 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, snapshotName, snapshot, 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, snapshotName, snapshot, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdate(resourceGroupName, snapshotName, snapshot, options, optionalCallback);
    }
  }

  /**
   * Deletes a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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<OperationStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, snapshotName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, snapshotName, 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 snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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 {OperationStatusResponse} - 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 OperationStatusResponse} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, snapshotName, 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, snapshotName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, snapshotName, options, optionalCallback);
    }
  }

  /**
   * Grants access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} grantAccessData Access data object supplied in the body of
   * the get snapshot access operation.
   *
   * @param {string} grantAccessData.access Possible values include: 'None',
   * 'Read'
   *
   * @param {number} grantAccessData.durationInSeconds Time duration in seconds
   * until the SAS access expires.
   *
   * @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<AccessUri>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginGrantAccessWithHttpOperationResponse(resourceGroupName, snapshotName, grantAccessData, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Grants access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and resource group.
   *
   * @param {object} grantAccessData Access data object supplied in the body of
   * the get snapshot access operation.
   *
   * @param {string} grantAccessData.access Possible values include: 'None',
   * 'Read'
   *
   * @param {number} grantAccessData.durationInSeconds Time duration in seconds
   * until the SAS access expires.
   *
   * @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 {AccessUri} - 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 AccessUri} 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.
   */
  beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, 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._beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginGrantAccess(resourceGroupName, snapshotName, grantAccessData, options, optionalCallback);
    }
  }

  /**
   * Revokes access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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<OperationStatusResponse>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginRevokeAccessWithHttpOperationResponse(resourceGroupName, snapshotName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginRevokeAccess(resourceGroupName, snapshotName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Revokes access to a snapshot.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} snapshotName The name of the snapshot within the given
   * subscription and 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 {OperationStatusResponse} - 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 OperationStatusResponse} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginRevokeAccess(resourceGroupName, snapshotName, 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._beginRevokeAccess(resourceGroupName, snapshotName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginRevokeAccess(resourceGroupName, snapshotName, options, optionalCallback);
    }
  }

  /**
   * Lists snapshots under 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<SnapshotList>} - 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;
      });
    });
  }

  /**
   * Lists snapshots under 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 {SnapshotList} - 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 SnapshotList} 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);
    }
  }

  /**
   * Lists snapshots under 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<SnapshotList>} - 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;
      });
    });
  }

  /**
   * Lists snapshots under 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 {SnapshotList} - 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 SnapshotList} 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 = Snapshots;