text: /*
   * Copyright (c) Microsoft Corporation. All rights reserved.
   * Licensed under the MIT License. See License.txt in the project root for
   * license information.
   *
   * Code generated by Microsoft (R) AutoRest Code Generator.
   * Changes may cause incorrect behavior and will be lost if the code is
   * regenerated.
   */
  
  'use strict';
  
  const msRest = require('ms-rest');
  const msRestAzure = require('ms-rest-azure');
  const WebResource = msRest.WebResource;
  
  
  /**
   * Create or update a gallery image.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @param {string} galleryImageName The name of the gallery image.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * gallery image operation.
   *
   * @param {string} [parameters.description] The description of this gallery
   * image resource.
   *
   * @param {string} [parameters.eula] The Eula agreement for the gallery image.
   *
   * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
   *
   * @param {string} [parameters.releaseNoteUri] The release note uri.
   *
   * @param {string} [parameters.osType] This property allows you to specify the
   * type of the OS that is included in the disk if creating a VM from user-image
   * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
   * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
   *
   * @param {string} [parameters.osState] The OS State. Possible values include:
   * 'Generalized', 'Specialized'
   *
   * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
   * image.
   *
   * @param {object} [parameters.identifier]
   *
   * @param {string} [parameters.identifier.publisher] The gallery image
   * publisher name.
   *
   * @param {string} [parameters.identifier.offer] The gallery image offer name.
   *
   * @param {string} [parameters.identifier.sku] The gallery image sku name.
   *
   * @param {object} [parameters.recommended]
   *
   * @param {object} [parameters.recommended.vCPUs]
   *
   * @param {object} [parameters.recommended.memory]
   *
   * @param {number} [parameters.recommended.memory.min] The minimum number of
   * the resource.
   *
   * @param {number} [parameters.recommended.memory.max] The maximum number of
   * the resource.
   *
   * @param {object} [parameters.disallowed]
   *
   * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
   *
   * @param {object} [parameters.purchasePlan]
   *
   * @param {string} [parameters.purchasePlan.name] The plan ID.
   *
   * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
   *
   * @param {string} [parameters.purchasePlan.product] The product ID.
   *
   * @param {string} parameters.location Resource location
   *
   * @param {object} [parameters.tags] Resource tags
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link GalleryImage} 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, galleryName, galleryImageName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
  
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
  
    // Send request
    this.beginCreateOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, (err, parsedResult, httpRequest, response) => {
      if (err) return callback(err);
  
      let initialResult = new msRest.HttpOperationResponse();
      initialResult.request = httpRequest;
      initialResult.response = response;
      initialResult.body = response.body;
      client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
        if (err) return callback(err);
  
        // Create Result
        let result = null;
  
        httpRequest = pollingResult.request;
        response = pollingResult.response;
        let responseBody = pollingResult.body;
        if (responseBody === '') responseBody = null;
  
        // Deserialize Response
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['GalleryImage']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  /**
   * Retrieves information about a gallery image.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @param {string} galleryImageName The name of the gallery image.
   *
   * @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 GalleryImage} 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, galleryName, galleryImageName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2018-06-01';
    // 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 (galleryName === null || galleryName === undefined || typeof galleryName.valueOf() !== 'string') {
        throw new Error('galleryName cannot be null or undefined and it must be of type string.');
      }
      if (galleryImageName === null || galleryImageName === undefined || typeof galleryImageName.valueOf() !== 'string') {
        throw new Error('galleryImageName 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/galleries/{galleryName}/images/{galleryImageName}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{galleryName}', encodeURIComponent(galleryName));
    requestUrl = requestUrl.replace('{galleryImageName}', encodeURIComponent(galleryImageName));
    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['GalleryImage']().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);
    });
  }
  
  
  /**
   * Delete a gallery image.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @param {string} galleryImageName The name of the gallery image.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _deleteMethod(resourceGroupName, galleryName, galleryImageName, 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, galleryName, galleryImageName, options, (err, parsedResult, httpRequest, response) => {
      if (err) return callback(err);
  
      let initialResult = new msRest.HttpOperationResponse();
      initialResult.request = httpRequest;
      initialResult.response = response;
      initialResult.body = response.body;
      client.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
        if (err) return callback(err);
  
        // Create Result
        let result = null;
  
        httpRequest = pollingResult.request;
        response = pollingResult.response;
        let responseBody = pollingResult.body;
        if (responseBody === '') responseBody = null;
  
        // Deserialize Response
  
        return callback(null, result, httpRequest, response);
      });
    });
  }
  
  /**
   * List gallery images under a gallery.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @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 GalleryImageList} 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 _listGalleryImagesInGallery(resourceGroupName, galleryName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2018-06-01';
    // 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 (galleryName === null || galleryName === undefined || typeof galleryName.valueOf() !== 'string') {
        throw new Error('galleryName 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/galleries/{galleryName}/images';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{galleryName}', encodeURIComponent(galleryName));
    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['GalleryImageList']().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);
    });
  }
  
  /**
   * Create or update a gallery image.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @param {string} galleryImageName The name of the gallery image.
   *
   * @param {object} parameters Parameters supplied to the create or update
   * gallery image operation.
   *
   * @param {string} [parameters.description] The description of this gallery
   * image resource.
   *
   * @param {string} [parameters.eula] The Eula agreement for the gallery image.
   *
   * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
   *
   * @param {string} [parameters.releaseNoteUri] The release note uri.
   *
   * @param {string} [parameters.osType] This property allows you to specify the
   * type of the OS that is included in the disk if creating a VM from user-image
   * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
   * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
   *
   * @param {string} [parameters.osState] The OS State. Possible values include:
   * 'Generalized', 'Specialized'
   *
   * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
   * image.
   *
   * @param {object} [parameters.identifier]
   *
   * @param {string} [parameters.identifier.publisher] The gallery image
   * publisher name.
   *
   * @param {string} [parameters.identifier.offer] The gallery image offer name.
   *
   * @param {string} [parameters.identifier.sku] The gallery image sku name.
   *
   * @param {object} [parameters.recommended]
   *
   * @param {object} [parameters.recommended.vCPUs]
   *
   * @param {object} [parameters.recommended.memory]
   *
   * @param {number} [parameters.recommended.memory.min] The minimum number of
   * the resource.
   *
   * @param {number} [parameters.recommended.memory.max] The maximum number of
   * the resource.
   *
   * @param {object} [parameters.disallowed]
   *
   * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
   *
   * @param {object} [parameters.purchasePlan]
   *
   * @param {string} [parameters.purchasePlan.name] The plan ID.
   *
   * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
   *
   * @param {string} [parameters.purchasePlan.product] The product ID.
   *
   * @param {string} parameters.location Resource location
   *
   * @param {object} [parameters.tags] Resource tags
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link GalleryImage} 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, galleryName, galleryImageName, parameters, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2018-06-01';
    // 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 (galleryName === null || galleryName === undefined || typeof galleryName.valueOf() !== 'string') {
        throw new Error('galleryName cannot be null or undefined and it must be of type string.');
      }
      if (galleryImageName === null || galleryImageName === undefined || typeof galleryImageName.valueOf() !== 'string') {
        throw new Error('galleryImageName cannot be null or undefined and it must be of type string.');
      }
      if (parameters === null || parameters === undefined) {
        throw new Error('parameters cannot be null or undefined.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let baseUrl = this.client.baseUri;
    let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{galleryName}', encodeURIComponent(galleryName));
    requestUrl = requestUrl.replace('{galleryImageName}', encodeURIComponent(galleryImageName));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (parameters !== null && parameters !== undefined) {
        let requestModelMapper = new client.models['GalleryImage']().mapper();
        requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(parameters, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 201 && statusCode !== 202) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 201) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['GalleryImage']().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['GalleryImage']().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);
    });
  }
  
  /**
   * Delete a gallery image.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} galleryName The name of the gallery.
   *
   * @param {string} galleryImageName The name of the gallery image.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _beginDeleteMethod(resourceGroupName, galleryName, galleryImageName, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    let apiVersion = '2018-06-01';
    // 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 (galleryName === null || galleryName === undefined || typeof galleryName.valueOf() !== 'string') {
        throw new Error('galleryName cannot be null or undefined and it must be of type string.');
      }
      if (galleryImageName === null || galleryImageName === undefined || typeof galleryImageName.valueOf() !== 'string') {
        throw new Error('galleryImageName 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/galleries/{galleryName}/images/{galleryImageName}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{galleryName}', encodeURIComponent(galleryName));
    requestUrl = requestUrl.replace('{galleryImageName}', encodeURIComponent(galleryImageName));
    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 !== 202 && statusCode !== 204) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /** Class representing a GalleryImageOperations. */
  class GalleryImageOperations {
    /**
     * Create a GalleryImageOperations.
     * @param {ComputeManagementClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._createOrUpdate = _createOrUpdate;
      this._get = _get;
      this._deleteMethod = _deleteMethod;
      this._listGalleryImagesInGallery = _listGalleryImagesInGallery;
      this._beginCreateOrUpdate = _beginCreateOrUpdate;
      this._beginDeleteMethod = _beginDeleteMethod;
    }
  
    /**
     * Create or update a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} parameters Parameters supplied to the create or update
     * gallery image operation.
     *
     * @param {string} [parameters.description] The description of this gallery
     * image resource.
     *
     * @param {string} [parameters.eula] The Eula agreement for the gallery image.
     *
     * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
     *
     * @param {string} [parameters.releaseNoteUri] The release note uri.
     *
     * @param {string} [parameters.osType] This property allows you to specify the
     * type of the OS that is included in the disk if creating a VM from user-image
     * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
     * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
     *
     * @param {string} [parameters.osState] The OS State. Possible values include:
     * 'Generalized', 'Specialized'
     *
     * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
     * image.
     *
     * @param {object} [parameters.identifier]
     *
     * @param {string} [parameters.identifier.publisher] The gallery image
     * publisher name.
     *
     * @param {string} [parameters.identifier.offer] The gallery image offer name.
     *
     * @param {string} [parameters.identifier.sku] The gallery image sku name.
     *
     * @param {object} [parameters.recommended]
     *
     * @param {object} [parameters.recommended.vCPUs]
     *
     * @param {object} [parameters.recommended.memory]
     *
     * @param {number} [parameters.recommended.memory.min] The minimum number of
     * the resource.
     *
     * @param {number} [parameters.recommended.memory.max] The maximum number of
     * the resource.
     *
     * @param {object} [parameters.disallowed]
     *
     * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
     *
     * @param {object} [parameters.purchasePlan]
     *
     * @param {string} [parameters.purchasePlan.name] The plan ID.
     *
     * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
     *
     * @param {string} [parameters.purchasePlan.product] The product ID.
     *
     * @param {string} parameters.location Resource location
     *
     * @param {object} [parameters.tags] Resource tags
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<GalleryImage>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    createOrUpdateWithHttpOperationResponse(resourceGroupName, galleryName, galleryImageName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Create or update a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} parameters Parameters supplied to the create or update
     * gallery image operation.
     *
     * @param {string} [parameters.description] The description of this gallery
     * image resource.
     *
     * @param {string} [parameters.eula] The Eula agreement for the gallery image.
     *
     * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
     *
     * @param {string} [parameters.releaseNoteUri] The release note uri.
     *
     * @param {string} [parameters.osType] This property allows you to specify the
     * type of the OS that is included in the disk if creating a VM from user-image
     * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
     * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
     *
     * @param {string} [parameters.osState] The OS State. Possible values include:
     * 'Generalized', 'Specialized'
     *
     * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
     * image.
     *
     * @param {object} [parameters.identifier]
     *
     * @param {string} [parameters.identifier.publisher] The gallery image
     * publisher name.
     *
     * @param {string} [parameters.identifier.offer] The gallery image offer name.
     *
     * @param {string} [parameters.identifier.sku] The gallery image sku name.
     *
     * @param {object} [parameters.recommended]
     *
     * @param {object} [parameters.recommended.vCPUs]
     *
     * @param {object} [parameters.recommended.memory]
     *
     * @param {number} [parameters.recommended.memory.min] The minimum number of
     * the resource.
     *
     * @param {number} [parameters.recommended.memory.max] The maximum number of
     * the resource.
     *
     * @param {object} [parameters.disallowed]
     *
     * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
     *
     * @param {object} [parameters.purchasePlan]
     *
     * @param {string} [parameters.purchasePlan.name] The plan ID.
     *
     * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
     *
     * @param {string} [parameters.purchasePlan.product] The product ID.
     *
     * @param {string} parameters.location Resource location
     *
     * @param {object} [parameters.tags] Resource tags
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {GalleryImage} - 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 GalleryImage} 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, galleryName, galleryImageName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._createOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._createOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Retrieves information about a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @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<GalleryImage>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(resourceGroupName, galleryName, galleryImageName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, galleryName, galleryImageName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Retrieves information about a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @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 {GalleryImage} - 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 GalleryImage} 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, galleryName, galleryImageName, 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, galleryName, galleryImageName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(resourceGroupName, galleryName, galleryImageName, options, optionalCallback);
      }
    }
  
    /**
     * Delete a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<null>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    deleteMethodWithHttpOperationResponse(resourceGroupName, galleryName, galleryImageName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, galleryName, galleryImageName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Delete a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {null} - The deserialized result object.
     *
     *                      @reject {Error} - The error object.
     *
     * {function} optionalCallback(err, result, request, response)
     *
     *                      {Error}  err        - The Error object if an error occurred, null otherwise.
     *
     *                      {null} [result]   - The deserialized result object if an error did not occur.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    deleteMethod(resourceGroupName, galleryName, galleryImageName, 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, galleryName, galleryImageName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(resourceGroupName, galleryName, galleryImageName, options, optionalCallback);
      }
    }
  
    /**
     * List gallery images under a gallery.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @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<GalleryImageList>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listGalleryImagesInGalleryWithHttpOperationResponse(resourceGroupName, galleryName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listGalleryImagesInGallery(resourceGroupName, galleryName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * List gallery images under a gallery.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @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 {GalleryImageList} - 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 GalleryImageList} 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.
     */
    listGalleryImagesInGallery(resourceGroupName, galleryName, 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._listGalleryImagesInGallery(resourceGroupName, galleryName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listGalleryImagesInGallery(resourceGroupName, galleryName, options, optionalCallback);
      }
    }
  
    /**
     * Create or update a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} parameters Parameters supplied to the create or update
     * gallery image operation.
     *
     * @param {string} [parameters.description] The description of this gallery
     * image resource.
     *
     * @param {string} [parameters.eula] The Eula agreement for the gallery image.
     *
     * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
     *
     * @param {string} [parameters.releaseNoteUri] The release note uri.
     *
     * @param {string} [parameters.osType] This property allows you to specify the
     * type of the OS that is included in the disk if creating a VM from user-image
     * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
     * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
     *
     * @param {string} [parameters.osState] The OS State. Possible values include:
     * 'Generalized', 'Specialized'
     *
     * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
     * image.
     *
     * @param {object} [parameters.identifier]
     *
     * @param {string} [parameters.identifier.publisher] The gallery image
     * publisher name.
     *
     * @param {string} [parameters.identifier.offer] The gallery image offer name.
     *
     * @param {string} [parameters.identifier.sku] The gallery image sku name.
     *
     * @param {object} [parameters.recommended]
     *
     * @param {object} [parameters.recommended.vCPUs]
     *
     * @param {object} [parameters.recommended.memory]
     *
     * @param {number} [parameters.recommended.memory.min] The minimum number of
     * the resource.
     *
     * @param {number} [parameters.recommended.memory.max] The maximum number of
     * the resource.
     *
     * @param {object} [parameters.disallowed]
     *
     * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
     *
     * @param {object} [parameters.purchasePlan]
     *
     * @param {string} [parameters.purchasePlan.name] The plan ID.
     *
     * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
     *
     * @param {string} [parameters.purchasePlan.product] The product ID.
     *
     * @param {string} parameters.location Resource location
     *
     * @param {object} [parameters.tags] Resource tags
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<GalleryImage>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginCreateOrUpdateWithHttpOperationResponse(resourceGroupName, galleryName, galleryImageName, parameters, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginCreateOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Create or update a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} parameters Parameters supplied to the create or update
     * gallery image operation.
     *
     * @param {string} [parameters.description] The description of this gallery
     * image resource.
     *
     * @param {string} [parameters.eula] The Eula agreement for the gallery image.
     *
     * @param {string} [parameters.privacyStatementUri] The privacy statement uri.
     *
     * @param {string} [parameters.releaseNoteUri] The release note uri.
     *
     * @param {string} [parameters.osType] This property allows you to specify the
     * type of the OS that is included in the disk if creating a VM from user-image
     * or a specialized VHD. <br><br> Possible values are: <br><br> **Windows**
     * <br><br> **Linux**. Possible values include: 'Windows', 'Linux'
     *
     * @param {string} [parameters.osState] The OS State. Possible values include:
     * 'Generalized', 'Specialized'
     *
     * @param {date} [parameters.endOfLifeDate] The end of life of this gallery
     * image.
     *
     * @param {object} [parameters.identifier]
     *
     * @param {string} [parameters.identifier.publisher] The gallery image
     * publisher name.
     *
     * @param {string} [parameters.identifier.offer] The gallery image offer name.
     *
     * @param {string} [parameters.identifier.sku] The gallery image sku name.
     *
     * @param {object} [parameters.recommended]
     *
     * @param {object} [parameters.recommended.vCPUs]
     *
     * @param {object} [parameters.recommended.memory]
     *
     * @param {number} [parameters.recommended.memory.min] The minimum number of
     * the resource.
     *
     * @param {number} [parameters.recommended.memory.max] The maximum number of
     * the resource.
     *
     * @param {object} [parameters.disallowed]
     *
     * @param {array} [parameters.disallowed.diskTypes] A list of disk types.
     *
     * @param {object} [parameters.purchasePlan]
     *
     * @param {string} [parameters.purchasePlan.name] The plan ID.
     *
     * @param {string} [parameters.purchasePlan.publisher] The publisher ID.
     *
     * @param {string} [parameters.purchasePlan.product] The product ID.
     *
     * @param {string} parameters.location Resource location
     *
     * @param {object} [parameters.tags] Resource tags
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {GalleryImage} - 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 GalleryImage} 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, galleryName, galleryImageName, parameters, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._beginCreateOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginCreateOrUpdate(resourceGroupName, galleryName, galleryImageName, parameters, options, optionalCallback);
      }
    }
  
    /**
     * Delete a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<null>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    beginDeleteMethodWithHttpOperationResponse(resourceGroupName, galleryName, galleryImageName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, galleryName, galleryImageName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Delete a gallery image.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} galleryName The name of the gallery.
     *
     * @param {string} galleryImageName The name of the gallery image.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {null} - The deserialized result object.
     *
     *                      @reject {Error} - The error object.
     *
     * {function} optionalCallback(err, result, request, response)
     *
     *                      {Error}  err        - The Error object if an error occurred, null otherwise.
     *
     *                      {null} [result]   - The deserialized result object if an error did not occur.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    beginDeleteMethod(resourceGroupName, galleryName, galleryImageName, 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, galleryName, galleryImageName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._beginDeleteMethod(resourceGroupName, galleryName, galleryImageName, options, optionalCallback);
      }
    }
  
  }
  
  module.exports = GalleryImageOperations;
  