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 0.11.0.0
  // Changes may cause incorrect behavior and will be lost if the code is
  // regenerated.
  
  
  'use strict';
  
  var util = require('util');
  var msRest = require('ms-rest');
  var msRestAzure = require('ms-rest-azure');
  var ServiceClient = msRest.ServiceClient;
  var WebResource = msRest.WebResource;
  
  var models = require('../models');
  
  /**
   * @class
   * Tags
   * __NOTE__: An instance of this class is automatically created for an
   * instance of the ResourceManagementClient.
   * Initializes a new instance of the Tags class.
   * @constructor
   *
   * @param {ResourceManagementClient} client Reference to the service client.
   */
  function Tags(client) {
    this.client = client;
  }
  
  /**
   * Delete a subscription resource tag value.
   * @param {String} tagName The name of the tag.
   *
   * @param {String} tagValue The value of the tag.
   *
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.deleteValue = function (tagName, tagValue, options, callback) {
    var client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (tagName === null || tagName === undefined || typeof tagName.valueOf() !== 'string') {
        throw new Error('tagName cannot be null or undefined and it must be of type string.');
      }
      if (tagValue === null || tagValue === undefined || typeof tagValue.valueOf() !== 'string') {
        throw new Error('tagValue cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    var requestUrl = this.client.baseUri + 
                     '//subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}';
    requestUrl = requestUrl.replace('{tagName}', encodeURIComponent(tagName));
    requestUrl = requestUrl.replace('{tagValue}', encodeURIComponent(tagValue));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    var queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 204) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
  
      return callback(null, result);
    });
  };
  
  /**
   * Create a subscription resource tag value.
   * @param {String} tagName The name of the tag.
   *
   * @param {String} tagValue The value of the tag.
   *
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.createOrUpdateValue = function (tagName, tagValue, options, callback) {
    var client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (tagName === null || tagName === undefined || typeof tagName.valueOf() !== 'string') {
        throw new Error('tagName cannot be null or undefined and it must be of type string.');
      }
      if (tagValue === null || tagValue === undefined || typeof tagValue.valueOf() !== 'string') {
        throw new Error('tagValue cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    var requestUrl = this.client.baseUri + 
                     '//subscriptions/{subscriptionId}/tagNames/{tagName}/tagValues/{tagValue}';
    requestUrl = requestUrl.replace('{tagName}', encodeURIComponent(tagName));
    requestUrl = requestUrl.replace('{tagValue}', encodeURIComponent(tagValue));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    var queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
          if (error.body !== null && error.body !== undefined) {
            error.body = client._models['CloudError'].deserialize(error.body);
          }
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
      // Deserialize Response
      if (statusCode === 200) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagValue'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError.request = httpRequest;
          deserializationError.response = response;
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagValue'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError1 = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError1.request = httpRequest;
          deserializationError1.response = response;
          return callback(deserializationError1);
        }
      }
  
      return callback(null, result);
    });
  };
  
  /**
   * Create a subscription resource tag.
   * @param {String} tagName The name of the tag.
   *
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.createOrUpdate = function (tagName, options, callback) {
    var client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (tagName === null || tagName === undefined || typeof tagName.valueOf() !== 'string') {
        throw new Error('tagName cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    var requestUrl = this.client.baseUri + 
                     '//subscriptions/{subscriptionId}/tagNames/{tagName}';
    requestUrl = requestUrl.replace('{tagName}', encodeURIComponent(tagName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    var queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'PUT';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
          if (error.body !== null && error.body !== undefined) {
            error.body = client._models['CloudError'].deserialize(error.body);
          }
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
      // Deserialize Response
      if (statusCode === 200) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagDetails'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError.request = httpRequest;
          deserializationError.response = response;
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagDetails'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError1 = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError1.request = httpRequest;
          deserializationError1.response = response;
          return callback(deserializationError1);
        }
      }
  
      return callback(null, result);
    });
  };
  
  /**
   * Delete a subscription resource tag.
   * @param {String} tagName The name of the tag.
   *
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.deleteMethod = function (tagName, options, callback) {
    var client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (tagName === null || tagName === undefined || typeof tagName.valueOf() !== 'string') {
        throw new Error('tagName cannot be null or undefined and it must be of type string.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    var requestUrl = this.client.baseUri + 
                     '//subscriptions/{subscriptionId}/tagNames/{tagName}';
    requestUrl = requestUrl.replace('{tagName}', encodeURIComponent(tagName));
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    var queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 204) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
  
      return callback(null, result);
    });
  };
  
  /**
   * Get a list of subscription resource tags.
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.list = function (options, callback) {
    var client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
        throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    var requestUrl = this.client.baseUri + 
                     '//subscriptions/{subscriptionId}/tagNames';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    var queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
          if (error.body !== null && error.body !== undefined) {
            error.body = client._models['CloudError'].deserialize(error.body);
          }
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
      // Deserialize Response
      if (statusCode === 200) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagsListResult'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError.request = httpRequest;
          deserializationError.response = response;
          return callback(deserializationError);
        }
      }
  
      return callback(null, result);
    });
  };
  
  /**
   * Get a list of subscription resource tags.
   * @param {String} nextPageLink The NextLink from the previous successful call to List operation.
   *
   * @param {object} [options]
   *
   * @param {object} [options.customHeaders] headers that will be added to
   * request
   *
   * @param {function} callback
   *
   * @returns {Stream} The Response stream
   */
  Tags.prototype.listNext = function (nextPageLink, options, callback) {
    var 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
    var requestUrl = '{nextLink}';
    requestUrl = requestUrl.replace('{nextLink}', nextPageLink);
    // trim all duplicate forward slashes in the url
    var regex = /([^:]\/)\/+/gi;
    requestUrl = requestUrl.replace(regex, '$1');
  
    // Create HTTP transport objects
    var httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.headers = {};
    httpRequest.url = requestUrl;
    // Set Headers
    httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    if (this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(var headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    httpRequest.body = null;
    httpRequest.headers['Content-Length'] = 0;
    // Send Request
    return client.pipeline(httpRequest, function (err, response, responseBody) {
      if (err) {
        return callback(err);
      }
      var statusCode = response.statusCode;
      if (statusCode !== 200) {
        var error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = httpRequest;
        error.response = response;
        if (responseBody === '') responseBody = null;
        var parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          error.body = parsedErrorResponse;
          if (error.body !== null && error.body !== undefined) {
            error.body = client._models['CloudError'].deserialize(error.body);
          }
        } catch (defaultError) {
          error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody);
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      var result = new msRest.HttpOperationResponse();
      result.request = httpRequest;
      result.response = response;
      if (responseBody === '') responseBody = null;
      result.requestId = response.headers['x-ms-request-id'];
      // Deserialize Response
      if (statusCode === 200) {
        var parsedResponse;
        try {
          parsedResponse = JSON.parse(responseBody);
          result.body = parsedResponse;
          if (result.body !== null && result.body !== undefined) {
            result.body = client._models['TagsListResult'].deserialize(result.body);
          }
        } catch (error) {
          var deserializationError = new Error(util.format('Error "%s" occurred in deserializing the responseBody - "%s"', error, responseBody));
          deserializationError.request = httpRequest;
          deserializationError.response = response;
          return callback(deserializationError);
        }
      }
  
      return callback(null, result);
    });
  };
  
  
  module.exports = Tags;
  