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;
  
  /**
   * List policies in a given policy set.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} policySetName The name of the policy set.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=description)'
   *
   * @param {string} [options.filter] The filter to apply to the operation.
   *
   * @param {number} [options.top] The maximum number of resources to return from
   * the operation.
   *
   * @param {string} [options.orderby] The ordering expression for the results,
   * using OData notation.
   *
   * @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 ResponseWithContinuationPolicy} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _list(resourceGroupName, labName, policySetName, 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 expand = (options && options.expand !== undefined) ? options.expand : undefined;
    let filter = (options && options.filter !== undefined) ? options.filter : undefined;
    let top = (options && options.top !== undefined) ? options.top : undefined;
    let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined;
    // 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 (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
        throw new Error('labName cannot be null or undefined and it must be of type string.');
      }
      if (policySetName === null || policySetName === undefined || typeof policySetName.valueOf() !== 'string') {
        throw new Error('policySetName cannot be null or undefined and it must be of type string.');
      }
      if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
        throw new Error('expand must be of type string.');
      }
      if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
        throw new Error('filter must be of type string.');
      }
      if (top !== null && top !== undefined && typeof top !== 'number') {
        throw new Error('top must be of type number.');
      }
      if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') {
        throw new Error('orderby 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.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.DevTestLab/labs/{labName}/policysets/{policySetName}/policies';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
    requestUrl = requestUrl.replace('{policySetName}', encodeURIComponent(policySetName));
    let queryParameters = [];
    if (expand !== null && expand !== undefined) {
      queryParameters.push('$expand=' + encodeURIComponent(expand));
    }
    if (filter !== null && filter !== undefined) {
      queryParameters.push('$filter=' + encodeURIComponent(filter));
    }
    if (top !== null && top !== undefined) {
      queryParameters.push('$top=' + encodeURIComponent(top.toString()));
    }
    if (orderby !== null && orderby !== undefined) {
      queryParameters.push('$orderby=' + encodeURIComponent(orderby));
    }
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['ResponseWithContinuationPolicy']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /**
   * Get policy.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} policySetName The name of the policy set.
   *
   * @param {string} name The name of the policy.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.expand] Specify the $expand query. Example:
   * 'properties($select=description)'
   *
   * @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 Policy} 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, labName, policySetName, name, 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 expand = (options && options.expand !== undefined) ? options.expand : undefined;
    // 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 (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
        throw new Error('labName cannot be null or undefined and it must be of type string.');
      }
      if (policySetName === null || policySetName === undefined || typeof policySetName.valueOf() !== 'string') {
        throw new Error('policySetName cannot be null or undefined and it must be of type string.');
      }
      if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
        throw new Error('name cannot be null or undefined and it must be of type string.');
      }
      if (expand !== null && expand !== undefined && typeof expand.valueOf() !== 'string') {
        throw new Error('expand 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.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.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
    requestUrl = requestUrl.replace('{policySetName}', encodeURIComponent(policySetName));
    requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
    let queryParameters = [];
    if (expand !== null && expand !== undefined) {
      queryParameters.push('$expand=' + encodeURIComponent(expand));
    }
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['Policy']().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 replace an existing policy.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} policySetName The name of the policy set.
   *
   * @param {string} name The name of the policy.
   *
   * @param {object} policy A Policy.
   *
   * @param {string} [policy.description] The description of the policy.
   *
   * @param {string} [policy.status] The status of the policy. Possible values
   * include: 'Enabled', 'Disabled'
   *
   * @param {string} [policy.factName] The fact name of the policy (e.g.
   * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
   * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
   * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
   * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
   *
   * @param {string} [policy.factData] The fact data of the policy.
   *
   * @param {string} [policy.threshold] The threshold of the policy (i.e. a
   * number for MaxValuePolicy, and a JSON array of values for
   * AllowedValuesPolicy).
   *
   * @param {string} [policy.evaluatorType] The evaluator type of the policy
   * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
   * 'AllowedValuesPolicy', 'MaxValuePolicy'
   *
   * @param {string} [policy.provisioningState] The provisioning status of the
   * resource.
   *
   * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
   * a resource (Guid).
   *
   * @param {string} [policy.location] The location of the resource.
   *
   * @param {object} [policy.tags] The tags of the resource.
   *
   * @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 Policy} 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, labName, policySetName, name, policy, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (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 (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
        throw new Error('labName cannot be null or undefined and it must be of type string.');
      }
      if (policySetName === null || policySetName === undefined || typeof policySetName.valueOf() !== 'string') {
        throw new Error('policySetName cannot be null or undefined and it must be of type string.');
      }
      if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
        throw new Error('name cannot be null or undefined and it must be of type string.');
      }
      if (policy === null || policy === undefined) {
        throw new Error('policy cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.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.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
    requestUrl = requestUrl.replace('{policySetName}', encodeURIComponent(policySetName));
    requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = '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 (policy !== null && policy !== undefined) {
        let requestModelMapper = new client.models['Policy']().mapper();
        requestModel = client.serialize(requestModelMapper, policy, 'policy');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(policy, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 201) {
        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['Policy']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
      // Deserialize Response
      if (statusCode === 201) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['Policy']().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 policy.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} policySetName The name of the policy set.
   *
   * @param {string} name The name of the policy.
   *
   * @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, labName, policySetName, name, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (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 (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
        throw new Error('labName cannot be null or undefined and it must be of type string.');
      }
      if (policySetName === null || policySetName === undefined || typeof policySetName.valueOf() !== 'string') {
        throw new Error('policySetName cannot be null or undefined and it must be of type string.');
      }
      if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
        throw new Error('name 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.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.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
    requestUrl = requestUrl.replace('{policySetName}', encodeURIComponent(policySetName));
    requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'DELETE';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200 && statusCode !== 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);
    });
  }
  
  /**
   * Modify properties of policies.
   *
   * @param {string} resourceGroupName The name of the resource group.
   *
   * @param {string} labName The name of the lab.
   *
   * @param {string} policySetName The name of the policy set.
   *
   * @param {string} name The name of the policy.
   *
   * @param {object} policy A Policy.
   *
   * @param {string} [policy.description] The description of the policy.
   *
   * @param {string} [policy.status] The status of the policy. Possible values
   * include: 'Enabled', 'Disabled'
   *
   * @param {string} [policy.factName] The fact name of the policy (e.g.
   * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
   * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
   * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
   * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
   *
   * @param {string} [policy.factData] The fact data of the policy.
   *
   * @param {string} [policy.threshold] The threshold of the policy (i.e. a
   * number for MaxValuePolicy, and a JSON array of values for
   * AllowedValuesPolicy).
   *
   * @param {string} [policy.evaluatorType] The evaluator type of the policy
   * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
   * 'AllowedValuesPolicy', 'MaxValuePolicy'
   *
   * @param {string} [policy.provisioningState] The provisioning status of the
   * resource.
   *
   * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
   * a resource (Guid).
   *
   * @param {string} [policy.location] The location of the resource.
   *
   * @param {object} [policy.tags] The tags of the resource.
   *
   * @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 Policy} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _update(resourceGroupName, labName, policySetName, name, policy, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (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 (labName === null || labName === undefined || typeof labName.valueOf() !== 'string') {
        throw new Error('labName cannot be null or undefined and it must be of type string.');
      }
      if (policySetName === null || policySetName === undefined || typeof policySetName.valueOf() !== 'string') {
        throw new Error('policySetName cannot be null or undefined and it must be of type string.');
      }
      if (name === null || name === undefined || typeof name.valueOf() !== 'string') {
        throw new Error('name cannot be null or undefined and it must be of type string.');
      }
      if (policy === null || policy === undefined) {
        throw new Error('policy cannot be null or undefined.');
      }
      if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
        throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
      }
      if (this.client.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.DevTestLab/labs/{labName}/policysets/{policySetName}/policies/{name}';
    requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
    requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
    requestUrl = requestUrl.replace('{labName}', encodeURIComponent(labName));
    requestUrl = requestUrl.replace('{policySetName}', encodeURIComponent(policySetName));
    requestUrl = requestUrl.replace('{name}', encodeURIComponent(name));
    let queryParameters = [];
    queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
    if (queryParameters.length > 0) {
      requestUrl += '?' + queryParameters.join('&');
    }
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'PATCH';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    // Serialize Request
    let requestContent = null;
    let requestModel = null;
    try {
      if (policy !== null && policy !== undefined) {
        let requestModelMapper = new client.models['PolicyFragment']().mapper();
        requestModel = client.serialize(requestModelMapper, policy, 'policy');
        requestContent = JSON.stringify(requestModel);
      }
    } catch (error) {
      let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
          `payload - ${JSON.stringify(policy, null, 2)}.`);
      return callback(serializationError);
    }
    httpRequest.body = requestContent;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        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['Policy']().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);
    });
  }
  
  /**
   * List policies in a given policy set.
   *
   * @param {string} nextPageLink The NextLink from the previous successful call
   * to List operation.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} callback - The callback.
   *
   * @returns {function} callback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {object} [result]   - The deserialized result object if an error did not occur.
   *                      See {@link ResponseWithContinuationPolicy} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  function _listNext(nextPageLink, options, callback) {
     /* jshint validthis: true */
    let client = this.client;
    if(!callback && typeof options === 'function') {
      callback = options;
      options = null;
    }
    if (!callback) {
      throw new Error('callback cannot be null.');
    }
    // Validate
    try {
      if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') {
        throw new Error('nextPageLink cannot be null or undefined and it must be of type string.');
      }
      if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
        throw new Error('this.client.acceptLanguage must be of type string.');
      }
    } catch (error) {
      return callback(error);
    }
  
    // Construct URL
    let requestUrl = '{nextLink}';
    requestUrl = requestUrl.replace('{nextLink}', nextPageLink);
  
    // Create HTTP transport objects
    let httpRequest = new WebResource();
    httpRequest.method = 'GET';
    httpRequest.url = requestUrl;
    httpRequest.headers = {};
    // Set Headers
    httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
    if (this.client.generateClientRequestId) {
        httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
    }
    if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
      httpRequest.headers['accept-language'] = this.client.acceptLanguage;
    }
    if(options) {
      for(let headerName in options['customHeaders']) {
        if (options['customHeaders'].hasOwnProperty(headerName)) {
          httpRequest.headers[headerName] = options['customHeaders'][headerName];
        }
      }
    }
    httpRequest.body = null;
    // Send Request
    return client.pipeline(httpRequest, (err, response, responseBody) => {
      if (err) {
        return callback(err);
      }
      let statusCode = response.statusCode;
      if (statusCode !== 200) {
        let error = new Error(responseBody);
        error.statusCode = response.statusCode;
        error.request = msRest.stripRequest(httpRequest);
        error.response = msRest.stripResponse(response);
        if (responseBody === '') responseBody = null;
        let parsedErrorResponse;
        try {
          parsedErrorResponse = JSON.parse(responseBody);
          if (parsedErrorResponse) {
            if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
            if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
            if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
          }
          if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
            let resultMapper = new client.models['CloudError']().mapper();
            error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
          }
        } catch (defaultError) {
          error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                           `- "${responseBody}" for the default response.`;
          return callback(error);
        }
        return callback(error);
      }
      // Create Result
      let result = null;
      if (responseBody === '') responseBody = null;
      // Deserialize Response
      if (statusCode === 200) {
        let parsedResponse = null;
        try {
          parsedResponse = JSON.parse(responseBody);
          result = JSON.parse(responseBody);
          if (parsedResponse !== null && parsedResponse !== undefined) {
            let resultMapper = new client.models['ResponseWithContinuationPolicy']().mapper();
            result = client.deserialize(resultMapper, parsedResponse, 'result');
          }
        } catch (error) {
          let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
          deserializationError.request = msRest.stripRequest(httpRequest);
          deserializationError.response = msRest.stripResponse(response);
          return callback(deserializationError);
        }
      }
  
      return callback(null, result, httpRequest, response);
    });
  }
  
  /** Class representing a Policies. */
  class Policies {
    /**
     * Create a Policies.
     * @param {DevTestLabsClient} client Reference to the service client.
     */
    constructor(client) {
      this.client = client;
      this._list = _list;
      this._get = _get;
      this._createOrUpdate = _createOrUpdate;
      this._deleteMethod = _deleteMethod;
      this._update = _update;
      this._listNext = _listNext;
    }
  
    /**
     * List policies in a given policy set.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.expand] Specify the $expand query. Example:
     * 'properties($select=description)'
     *
     * @param {string} [options.filter] The filter to apply to the operation.
     *
     * @param {number} [options.top] The maximum number of resources to return from
     * the operation.
     *
     * @param {string} [options.orderby] The ordering expression for the results,
     * using OData notation.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<ResponseWithContinuationPolicy>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listWithHttpOperationResponse(resourceGroupName, labName, policySetName, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._list(resourceGroupName, labName, policySetName, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * List policies in a given policy set.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.expand] Specify the $expand query. Example:
     * 'properties($select=description)'
     *
     * @param {string} [options.filter] The filter to apply to the operation.
     *
     * @param {number} [options.top] The maximum number of resources to return from
     * the operation.
     *
     * @param {string} [options.orderby] The ordering expression for the results,
     * using OData notation.
     *
     * @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 {ResponseWithContinuationPolicy} - 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 ResponseWithContinuationPolicy} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    list(resourceGroupName, labName, policySetName, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._list(resourceGroupName, labName, policySetName, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._list(resourceGroupName, labName, policySetName, options, optionalCallback);
      }
    }
  
    /**
     * Get policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.expand] Specify the $expand query. Example:
     * 'properties($select=description)'
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<Policy>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    getWithHttpOperationResponse(resourceGroupName, labName, policySetName, name, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._get(resourceGroupName, labName, policySetName, name, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Get policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {string} [options.expand] Specify the $expand query. Example:
     * 'properties($select=description)'
     *
     * @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 {Policy} - 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 Policy} 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, labName, policySetName, name, 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, labName, policySetName, name, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._get(resourceGroupName, labName, policySetName, name, options, optionalCallback);
      }
    }
  
    /**
     * Create or replace an existing policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} policy A Policy.
     *
     * @param {string} [policy.description] The description of the policy.
     *
     * @param {string} [policy.status] The status of the policy. Possible values
     * include: 'Enabled', 'Disabled'
     *
     * @param {string} [policy.factName] The fact name of the policy (e.g.
     * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
     * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
     * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
     * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
     *
     * @param {string} [policy.factData] The fact data of the policy.
     *
     * @param {string} [policy.threshold] The threshold of the policy (i.e. a
     * number for MaxValuePolicy, and a JSON array of values for
     * AllowedValuesPolicy).
     *
     * @param {string} [policy.evaluatorType] The evaluator type of the policy
     * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
     * 'AllowedValuesPolicy', 'MaxValuePolicy'
     *
     * @param {string} [policy.provisioningState] The provisioning status of the
     * resource.
     *
     * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
     * a resource (Guid).
     *
     * @param {string} [policy.location] The location of the resource.
     *
     * @param {object} [policy.tags] The tags of the resource.
     *
     * @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<Policy>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    createOrUpdateWithHttpOperationResponse(resourceGroupName, labName, policySetName, name, policy, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._createOrUpdate(resourceGroupName, labName, policySetName, name, policy, 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 replace an existing policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} policy A Policy.
     *
     * @param {string} [policy.description] The description of the policy.
     *
     * @param {string} [policy.status] The status of the policy. Possible values
     * include: 'Enabled', 'Disabled'
     *
     * @param {string} [policy.factName] The fact name of the policy (e.g.
     * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
     * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
     * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
     * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
     *
     * @param {string} [policy.factData] The fact data of the policy.
     *
     * @param {string} [policy.threshold] The threshold of the policy (i.e. a
     * number for MaxValuePolicy, and a JSON array of values for
     * AllowedValuesPolicy).
     *
     * @param {string} [policy.evaluatorType] The evaluator type of the policy
     * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
     * 'AllowedValuesPolicy', 'MaxValuePolicy'
     *
     * @param {string} [policy.provisioningState] The provisioning status of the
     * resource.
     *
     * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
     * a resource (Guid).
     *
     * @param {string} [policy.location] The location of the resource.
     *
     * @param {object} [policy.tags] The tags of the resource.
     *
     * @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 {Policy} - 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 Policy} 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, labName, policySetName, name, policy, 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, labName, policySetName, name, policy, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._createOrUpdate(resourceGroupName, labName, policySetName, name, policy, options, optionalCallback);
      }
    }
  
    /**
     * Delete policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @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, labName, policySetName, name, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, labName, policySetName, name, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Delete policy.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @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, labName, policySetName, name, 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, labName, policySetName, name, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._deleteMethod(resourceGroupName, labName, policySetName, name, options, optionalCallback);
      }
    }
  
    /**
     * Modify properties of policies.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} policy A Policy.
     *
     * @param {string} [policy.description] The description of the policy.
     *
     * @param {string} [policy.status] The status of the policy. Possible values
     * include: 'Enabled', 'Disabled'
     *
     * @param {string} [policy.factName] The fact name of the policy (e.g.
     * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
     * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
     * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
     * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
     *
     * @param {string} [policy.factData] The fact data of the policy.
     *
     * @param {string} [policy.threshold] The threshold of the policy (i.e. a
     * number for MaxValuePolicy, and a JSON array of values for
     * AllowedValuesPolicy).
     *
     * @param {string} [policy.evaluatorType] The evaluator type of the policy
     * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
     * 'AllowedValuesPolicy', 'MaxValuePolicy'
     *
     * @param {string} [policy.provisioningState] The provisioning status of the
     * resource.
     *
     * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
     * a resource (Guid).
     *
     * @param {string} [policy.location] The location of the resource.
     *
     * @param {object} [policy.tags] The tags of the resource.
     *
     * @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<Policy>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    updateWithHttpOperationResponse(resourceGroupName, labName, policySetName, name, policy, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._update(resourceGroupName, labName, policySetName, name, policy, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * Modify properties of policies.
     *
     * @param {string} resourceGroupName The name of the resource group.
     *
     * @param {string} labName The name of the lab.
     *
     * @param {string} policySetName The name of the policy set.
     *
     * @param {string} name The name of the policy.
     *
     * @param {object} policy A Policy.
     *
     * @param {string} [policy.description] The description of the policy.
     *
     * @param {string} [policy.status] The status of the policy. Possible values
     * include: 'Enabled', 'Disabled'
     *
     * @param {string} [policy.factName] The fact name of the policy (e.g.
     * LabVmCount, LabVmSize, MaxVmsAllowedPerLab, etc. Possible values include:
     * 'UserOwnedLabVmCount', 'UserOwnedLabPremiumVmCount', 'LabVmCount',
     * 'LabPremiumVmCount', 'LabVmSize', 'GalleryImage',
     * 'UserOwnedLabVmCountInSubnet', 'LabTargetCost'
     *
     * @param {string} [policy.factData] The fact data of the policy.
     *
     * @param {string} [policy.threshold] The threshold of the policy (i.e. a
     * number for MaxValuePolicy, and a JSON array of values for
     * AllowedValuesPolicy).
     *
     * @param {string} [policy.evaluatorType] The evaluator type of the policy
     * (i.e. AllowedValuesPolicy, MaxValuePolicy). Possible values include:
     * 'AllowedValuesPolicy', 'MaxValuePolicy'
     *
     * @param {string} [policy.provisioningState] The provisioning status of the
     * resource.
     *
     * @param {string} [policy.uniqueIdentifier] The unique immutable identifier of
     * a resource (Guid).
     *
     * @param {string} [policy.location] The location of the resource.
     *
     * @param {object} [policy.tags] The tags of the resource.
     *
     * @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 {Policy} - 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 Policy} for more information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    update(resourceGroupName, labName, policySetName, name, policy, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._update(resourceGroupName, labName, policySetName, name, policy, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._update(resourceGroupName, labName, policySetName, name, policy, options, optionalCallback);
      }
    }
  
    /**
     * List policies in a given policy set.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @returns {Promise} A promise is returned
     *
     * @resolve {HttpOperationResponse<ResponseWithContinuationPolicy>} - The deserialized result object.
     *
     * @reject {Error} - The error object.
     */
    listNextWithHttpOperationResponse(nextPageLink, options) {
      let client = this.client;
      let self = this;
      return new Promise((resolve, reject) => {
        self._listNext(nextPageLink, options, (err, result, request, response) => {
          let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
          httpOperationResponse.body = result;
          if (err) { reject(err); }
          else { resolve(httpOperationResponse); }
          return;
        });
      });
    }
  
    /**
     * List policies in a given policy set.
     *
     * @param {string} nextPageLink The NextLink from the previous successful call
     * to List operation.
     *
     * @param {object} [options] Optional Parameters.
     *
     * @param {object} [options.customHeaders] Headers that will be added to the
     * request
     *
     * @param {function} [optionalCallback] - The optional callback.
     *
     * @returns {function|Promise} If a callback was passed as the last parameter
     * then it returns the callback else returns a Promise.
     *
     * {Promise} A promise is returned
     *
     *                      @resolve {ResponseWithContinuationPolicy} - 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 ResponseWithContinuationPolicy} for more
     *                      information.
     *
     *                      {object} [request]  - The HTTP Request object if an error did not occur.
     *
     *                      {stream} [response] - The HTTP Response stream if an error did not occur.
     */
    listNext(nextPageLink, options, optionalCallback) {
      let client = this.client;
      let self = this;
      if (!optionalCallback && typeof options === 'function') {
        optionalCallback = options;
        options = null;
      }
      if (!optionalCallback) {
        return new Promise((resolve, reject) => {
          self._listNext(nextPageLink, options, (err, result, request, response) => {
            if (err) { reject(err); }
            else { resolve(result); }
            return;
          });
        });
      } else {
        return self._listNext(nextPageLink, options, optionalCallback);
      }
    }
  
  }
  
  module.exports = Policies;
  