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


/**
 * Creates a File Server in the given workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} fileServerName The name of the file server within the
 * specified resource group. File server names can only contain a combination
 * of alphanumeric characters along with dash (-) and underscore (_). The name
 * must be from 1 through 64 characters long.
 *
 * @param {object} parameters The parameters to provide for File Server
 * creation.
 *
 * @param {string} parameters.vmSize VM size. The size of the virtual machine
 * for the File Server. For information about available VM sizes from the
 * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
 *
 * @param {object} parameters.sshConfiguration SSH configuration. SSH
 * configuration for the File Server node.
 *
 * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
 * IPs. List of source IP ranges to allow SSH connection from. The default
 * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
 * can be specified is 400.
 *
 * @param {object} parameters.sshConfiguration.userAccountSettings User account
 * settings. Settings for administrator user account to be created on a node.
 * The account can be used to establish SSH connection to the node.
 *
 * @param {string}
 * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
 * Name of the administrator user account which can be used to SSH to nodes.
 *
 * @param {string}
 * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
 * public key. SSH public key of the administrator user account.
 *
 * @param {string}
 * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
 * Password. Password of the administrator user account.
 *
 * @param {object} parameters.dataDisks Data disks. Settings for the data disks
 * which will be created for the File Server.
 *
 * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
 * in GB for the blank data disks.
 *
 * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
 * type for the disks. Available values are none (default), readonly,
 * readwrite. Caching type can be set only for VM sizes supporting premium
 * storage. Possible values include: 'none', 'readonly', 'readwrite'
 *
 * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
 * of data disks attached to the File Server. If multiple disks attached, they
 * will be configured in RAID level 0.
 *
 * @param {string} parameters.dataDisks.storageAccountType Storage account
 * type. Type of storage account to be used on the disk. Possible values are:
 * Standard_LRS or Premium_LRS. Premium storage account type can only be used
 * with VM sizes supporting premium storage. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
 * existing virtual network subnet to put the File Server in. If not provided,
 * a new virtual network and subnet will be created.
 *
 * @param {string} parameters.subnet.id The ID 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 FileServer} 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 _create(resourceGroupName, workspaceName, fileServerName, parameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

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

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


/**
 * Deletes a File Server.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} fileServerName The name of the file server within the
 * specified resource group. File server names can only contain a combination
 * of alphanumeric characters along with dash (-) and underscore (_). The name
 * must be from 1 through 64 characters long.
 *
 * @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, workspaceName, fileServerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

  if (!callback) {
    throw new Error('callback cannot be null.');
  }

  // Send request
  this.beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Gets information about a File Server.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} fileServerName The name of the file server within the
 * specified resource group. File server names can only contain a combination
 * of alphanumeric characters along with dash (-) and underscore (_). The name
 * must be from 1 through 64 characters long.
 *
 * @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 FileServer} 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, workspaceName, fileServerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (fileServerName === null || fileServerName === undefined || typeof fileServerName.valueOf() !== 'string') {
      throw new Error('fileServerName cannot be null or undefined and it must be of type string.');
    }
    if (fileServerName !== null && fileServerName !== undefined) {
      if (fileServerName.length > 64)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MaxLength": 64');
      }
      if (fileServerName.length < 1)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MinLength": 1');
      }
      if (fileServerName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = '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['FileServer']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Gets a list of File Servers associated with the specified workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.fileServersListByWorkspaceOptions] Additional
 * parameters for the operation
 *
 * @param {number} [options.fileServersListByWorkspaceOptions.maxResults] The
 * maximum number of items to return in the response. A maximum of 1000 files
 * can be returned.
 *
 * @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 FileServerListResult} 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 _listByWorkspace(resourceGroupName, workspaceName, 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 fileServersListByWorkspaceOptions = (options && options.fileServersListByWorkspaceOptions !== undefined) ? options.fileServersListByWorkspaceOptions : undefined;
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    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);
  }
  let maxResults;
  try {
    if (fileServersListByWorkspaceOptions !== null && fileServersListByWorkspaceOptions !== undefined)
    {
      maxResults = fileServersListByWorkspaceOptions.maxResults;
      if (maxResults !== null && maxResults !== undefined && typeof maxResults !== 'number') {
        throw new Error('maxResults must be of type number.');
      }
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BatchAI/workspaces/{workspaceName}/fileServers';
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{workspaceName}', encodeURIComponent(workspaceName));
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
  if (maxResults !== null && maxResults !== undefined) {
    queryParameters.push('maxresults=' + encodeURIComponent(maxResults.toString()));
  }
  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['FileServerListResult']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Creates a File Server in the given workspace.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} fileServerName The name of the file server within the
 * specified resource group. File server names can only contain a combination
 * of alphanumeric characters along with dash (-) and underscore (_). The name
 * must be from 1 through 64 characters long.
 *
 * @param {object} parameters The parameters to provide for File Server
 * creation.
 *
 * @param {string} parameters.vmSize VM size. The size of the virtual machine
 * for the File Server. For information about available VM sizes from the
 * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
 *
 * @param {object} parameters.sshConfiguration SSH configuration. SSH
 * configuration for the File Server node.
 *
 * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
 * IPs. List of source IP ranges to allow SSH connection from. The default
 * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
 * can be specified is 400.
 *
 * @param {object} parameters.sshConfiguration.userAccountSettings User account
 * settings. Settings for administrator user account to be created on a node.
 * The account can be used to establish SSH connection to the node.
 *
 * @param {string}
 * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
 * Name of the administrator user account which can be used to SSH to nodes.
 *
 * @param {string}
 * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
 * public key. SSH public key of the administrator user account.
 *
 * @param {string}
 * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
 * Password. Password of the administrator user account.
 *
 * @param {object} parameters.dataDisks Data disks. Settings for the data disks
 * which will be created for the File Server.
 *
 * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
 * in GB for the blank data disks.
 *
 * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
 * type for the disks. Available values are none (default), readonly,
 * readwrite. Caching type can be set only for VM sizes supporting premium
 * storage. Possible values include: 'none', 'readonly', 'readwrite'
 *
 * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
 * of data disks attached to the File Server. If multiple disks attached, they
 * will be configured in RAID level 0.
 *
 * @param {string} parameters.dataDisks.storageAccountType Storage account
 * type. Type of storage account to be used on the disk. Possible values are:
 * Standard_LRS or Premium_LRS. Premium storage account type can only be used
 * with VM sizes supporting premium storage. Possible values include:
 * 'Standard_LRS', 'Premium_LRS'
 *
 * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
 * existing virtual network subnet to put the File Server in. If not provided,
 * a new virtual network and subnet will be created.
 *
 * @param {string} parameters.subnet.id The ID 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 FileServer} 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 _beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (fileServerName === null || fileServerName === undefined || typeof fileServerName.valueOf() !== 'string') {
      throw new Error('fileServerName cannot be null or undefined and it must be of type string.');
    }
    if (fileServerName !== null && fileServerName !== undefined) {
      if (fileServerName.length > 64)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MaxLength": 64');
      }
      if (fileServerName.length < 1)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MinLength": 1');
      }
      if (fileServerName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'PUT';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  // Serialize Request
  let requestContent = null;
  let requestModel = null;
  try {
    if (parameters !== null && parameters !== undefined) {
      let requestModelMapper = new client.models['FileServerCreateParameters']().mapper();
      requestModel = client.serialize(requestModelMapper, parameters, 'parameters');
      requestContent = JSON.stringify(requestModel);
    }
  } catch (error) {
    let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
        `payload - ${JSON.stringify(parameters, null, 2)}.`);
    return callback(serializationError);
  }
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;
    // Deserialize Response
    if (statusCode === 200) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['FileServer']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }

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

/**
 * Deletes a File Server.
 *
 * @param {string} resourceGroupName Name of the resource group to which the
 * resource belongs.
 *
 * @param {string} workspaceName The name of the workspace. Workspace names can
 * only contain a combination of alphanumeric characters along with dash (-)
 * and underscore (_). The name must be from 1 through 64 characters long.
 *
 * @param {string} fileServerName The name of the file server within the
 * specified resource group. File server names can only contain a combination
 * of alphanumeric characters along with dash (-) and underscore (_). The name
 * must be from 1 through 64 characters long.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (workspaceName === null || workspaceName === undefined || typeof workspaceName.valueOf() !== 'string') {
      throw new Error('workspaceName cannot be null or undefined and it must be of type string.');
    }
    if (workspaceName !== null && workspaceName !== undefined) {
      if (workspaceName.length > 64)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MaxLength": 64');
      }
      if (workspaceName.length < 1)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "MinLength": 1');
      }
      if (workspaceName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"workspaceName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (fileServerName === null || fileServerName === undefined || typeof fileServerName.valueOf() !== 'string') {
      throw new Error('fileServerName cannot be null or undefined and it must be of type string.');
    }
    if (fileServerName !== null && fileServerName !== undefined) {
      if (fileServerName.length > 64)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MaxLength": 64');
      }
      if (fileServerName.length < 1)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "MinLength": 1');
      }
      if (fileServerName.match(/^[-\w_]+$/) === null)
      {
        throw new Error('"fileServerName" should satisfy the constraint - "Pattern": /^[-\w_]+$/');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

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

  // Create HTTP transport objects
  let httpRequest = new WebResource();
  httpRequest.method = 'DELETE';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200 && statusCode !== 202 && statusCode !== 204) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/**
 * Gets a list of File Servers associated with the specified workspace.
 *
 * @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 FileServerListResult} 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 _listByWorkspaceNext(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['FileServerListResult']().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 FileServers. */
class FileServers {
  /**
   * Create a FileServers.
   * @param {BatchAIManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._create = _create;
    this._deleteMethod = _deleteMethod;
    this._get = _get;
    this._listByWorkspace = _listByWorkspace;
    this._beginCreate = _beginCreate;
    this._beginDeleteMethod = _beginDeleteMethod;
    this._listByWorkspaceNext = _listByWorkspaceNext;
  }

  /**
   * Creates a File Server in the given workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for File Server
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machine
   * for the File Server. For information about available VM sizes from the
   * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
   *
   * @param {object} parameters.sshConfiguration SSH configuration. SSH
   * configuration for the File Server node.
   *
   * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
   * IPs. List of source IP ranges to allow SSH connection from. The default
   * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
   * can be specified is 400.
   *
   * @param {object} parameters.sshConfiguration.userAccountSettings User account
   * settings. Settings for administrator user account to be created on a node.
   * The account can be used to establish SSH connection to the node.
   *
   * @param {string}
   * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
   * Name of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
   * Password. Password of the administrator user account.
   *
   * @param {object} parameters.dataDisks Data disks. Settings for the data disks
   * which will be created for the File Server.
   *
   * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
   * in GB for the blank data disks.
   *
   * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
   * type for the disks. Available values are none (default), readonly,
   * readwrite. Caching type can be set only for VM sizes supporting premium
   * storage. Possible values include: 'none', 'readonly', 'readwrite'
   *
   * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
   * of data disks attached to the File Server. If multiple disks attached, they
   * will be configured in RAID level 0.
   *
   * @param {string} parameters.dataDisks.storageAccountType Storage account
   * type. Type of storage account to be used on the disk. Possible values are:
   * Standard_LRS or Premium_LRS. Premium storage account type can only be used
   * with VM sizes supporting premium storage. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
   * existing virtual network subnet to put the File Server in. If not provided,
   * a new virtual network and subnet will be created.
   *
   * @param {string} parameters.subnet.id The ID 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<FileServer>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, workspaceName, fileServerName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, workspaceName, fileServerName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a File Server in the given workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for File Server
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machine
   * for the File Server. For information about available VM sizes from the
   * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
   *
   * @param {object} parameters.sshConfiguration SSH configuration. SSH
   * configuration for the File Server node.
   *
   * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
   * IPs. List of source IP ranges to allow SSH connection from. The default
   * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
   * can be specified is 400.
   *
   * @param {object} parameters.sshConfiguration.userAccountSettings User account
   * settings. Settings for administrator user account to be created on a node.
   * The account can be used to establish SSH connection to the node.
   *
   * @param {string}
   * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
   * Name of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
   * Password. Password of the administrator user account.
   *
   * @param {object} parameters.dataDisks Data disks. Settings for the data disks
   * which will be created for the File Server.
   *
   * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
   * in GB for the blank data disks.
   *
   * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
   * type for the disks. Available values are none (default), readonly,
   * readwrite. Caching type can be set only for VM sizes supporting premium
   * storage. Possible values include: 'none', 'readonly', 'readwrite'
   *
   * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
   * of data disks attached to the File Server. If multiple disks attached, they
   * will be configured in RAID level 0.
   *
   * @param {string} parameters.dataDisks.storageAccountType Storage account
   * type. Type of storage account to be used on the disk. Possible values are:
   * Standard_LRS or Premium_LRS. Premium storage account type can only be used
   * with VM sizes supporting premium storage. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
   * existing virtual network subnet to put the File Server in. If not provided,
   * a new virtual network and subnet will be created.
   *
   * @param {string} parameters.subnet.id The ID 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 {FileServer} - 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 FileServer} 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.
   */
  create(resourceGroupName, workspaceName, fileServerName, parameters, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._create(resourceGroupName, workspaceName, fileServerName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, workspaceName, fileServerName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @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, workspaceName, fileServerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, workspaceName, fileServerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @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, workspaceName, fileServerName, 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, workspaceName, fileServerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, workspaceName, fileServerName, options, optionalCallback);
    }
  }

  /**
   * Gets information about a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @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<FileServer>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getWithHttpOperationResponse(resourceGroupName, workspaceName, fileServerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._get(resourceGroupName, workspaceName, fileServerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets information about a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @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 {FileServer} - 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 FileServer} 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, workspaceName, fileServerName, 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, workspaceName, fileServerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._get(resourceGroupName, workspaceName, fileServerName, options, optionalCallback);
    }
  }

  /**
   * Gets a list of File Servers associated with the specified workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.fileServersListByWorkspaceOptions] Additional
   * parameters for the operation
   *
   * @param {number} [options.fileServersListByWorkspaceOptions.maxResults] The
   * maximum number of items to return in the response. A maximum of 1000 files
   * can be returned.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileServerListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByWorkspaceWithHttpOperationResponse(resourceGroupName, workspaceName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByWorkspace(resourceGroupName, workspaceName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a list of File Servers associated with the specified workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.fileServersListByWorkspaceOptions] Additional
   * parameters for the operation
   *
   * @param {number} [options.fileServersListByWorkspaceOptions.maxResults] The
   * maximum number of items to return in the response. A maximum of 1000 files
   * can be returned.
   *
   * @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 {FileServerListResult} - 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 FileServerListResult} 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.
   */
  listByWorkspace(resourceGroupName, workspaceName, 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._listByWorkspace(resourceGroupName, workspaceName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByWorkspace(resourceGroupName, workspaceName, options, optionalCallback);
    }
  }

  /**
   * Creates a File Server in the given workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for File Server
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machine
   * for the File Server. For information about available VM sizes from the
   * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
   *
   * @param {object} parameters.sshConfiguration SSH configuration. SSH
   * configuration for the File Server node.
   *
   * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
   * IPs. List of source IP ranges to allow SSH connection from. The default
   * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
   * can be specified is 400.
   *
   * @param {object} parameters.sshConfiguration.userAccountSettings User account
   * settings. Settings for administrator user account to be created on a node.
   * The account can be used to establish SSH connection to the node.
   *
   * @param {string}
   * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
   * Name of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
   * Password. Password of the administrator user account.
   *
   * @param {object} parameters.dataDisks Data disks. Settings for the data disks
   * which will be created for the File Server.
   *
   * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
   * in GB for the blank data disks.
   *
   * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
   * type for the disks. Available values are none (default), readonly,
   * readwrite. Caching type can be set only for VM sizes supporting premium
   * storage. Possible values include: 'none', 'readonly', 'readwrite'
   *
   * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
   * of data disks attached to the File Server. If multiple disks attached, they
   * will be configured in RAID level 0.
   *
   * @param {string} parameters.dataDisks.storageAccountType Storage account
   * type. Type of storage account to be used on the disk. Possible values are:
   * Standard_LRS or Premium_LRS. Premium storage account type can only be used
   * with VM sizes supporting premium storage. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
   * existing virtual network subnet to put the File Server in. If not provided,
   * a new virtual network and subnet will be created.
   *
   * @param {string} parameters.subnet.id The ID 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<FileServer>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateWithHttpOperationResponse(resourceGroupName, workspaceName, fileServerName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates a File Server in the given workspace.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} parameters The parameters to provide for File Server
   * creation.
   *
   * @param {string} parameters.vmSize VM size. The size of the virtual machine
   * for the File Server. For information about available VM sizes from the
   * Virtual Machines Marketplace, see Sizes for Virtual Machines (Linux).
   *
   * @param {object} parameters.sshConfiguration SSH configuration. SSH
   * configuration for the File Server node.
   *
   * @param {array} [parameters.sshConfiguration.publicIPsToAllow] Allowed public
   * IPs. List of source IP ranges to allow SSH connection from. The default
   * value is '*' (all source IPs are allowed). Maximum number of IP ranges that
   * can be specified is 400.
   *
   * @param {object} parameters.sshConfiguration.userAccountSettings User account
   * settings. Settings for administrator user account to be created on a node.
   * The account can be used to establish SSH connection to the node.
   *
   * @param {string}
   * parameters.sshConfiguration.userAccountSettings.adminUserName User name.
   * Name of the administrator user account which can be used to SSH to nodes.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserSshPublicKey] SSH
   * public key. SSH public key of the administrator user account.
   *
   * @param {string}
   * [parameters.sshConfiguration.userAccountSettings.adminUserPassword]
   * Password. Password of the administrator user account.
   *
   * @param {object} parameters.dataDisks Data disks. Settings for the data disks
   * which will be created for the File Server.
   *
   * @param {number} parameters.dataDisks.diskSizeInGB Disk size in GB. Disk size
   * in GB for the blank data disks.
   *
   * @param {string} [parameters.dataDisks.cachingType] Caching type. Caching
   * type for the disks. Available values are none (default), readonly,
   * readwrite. Caching type can be set only for VM sizes supporting premium
   * storage. Possible values include: 'none', 'readonly', 'readwrite'
   *
   * @param {number} parameters.dataDisks.diskCount Number of data disks. Number
   * of data disks attached to the File Server. If multiple disks attached, they
   * will be configured in RAID level 0.
   *
   * @param {string} parameters.dataDisks.storageAccountType Storage account
   * type. Type of storage account to be used on the disk. Possible values are:
   * Standard_LRS or Premium_LRS. Premium storage account type can only be used
   * with VM sizes supporting premium storage. Possible values include:
   * 'Standard_LRS', 'Premium_LRS'
   *
   * @param {object} [parameters.subnet] Subnet identifier. Identifier of an
   * existing virtual network subnet to put the File Server in. If not provided,
   * a new virtual network and subnet will be created.
   *
   * @param {string} parameters.subnet.id The ID 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 {FileServer} - 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 FileServer} 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.
   */
  beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreate(resourceGroupName, workspaceName, fileServerName, parameters, options, optionalCallback);
    }
  }

  /**
   * Deletes a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginDeleteMethodWithHttpOperationResponse(resourceGroupName, workspaceName, fileServerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes a File Server.
   *
   * @param {string} resourceGroupName Name of the resource group to which the
   * resource belongs.
   *
   * @param {string} workspaceName The name of the workspace. Workspace names can
   * only contain a combination of alphanumeric characters along with dash (-)
   * and underscore (_). The name must be from 1 through 64 characters long.
   *
   * @param {string} fileServerName The name of the file server within the
   * specified resource group. File server names can only contain a combination
   * of alphanumeric characters along with dash (-) and underscore (_). The name
   * must be from 1 through 64 characters long.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginDeleteMethod(resourceGroupName, workspaceName, fileServerName, options, optionalCallback);
    }
  }

  /**
   * Gets a list of File Servers associated with the specified workspace.
   *
   * @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<FileServerListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listByWorkspaceNextWithHttpOperationResponse(nextPageLink, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listByWorkspaceNext(nextPageLink, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets a list of File Servers associated with the specified workspace.
   *
   * @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 {FileServerListResult} - 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 FileServerListResult} 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.
   */
  listByWorkspaceNext(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._listByWorkspaceNext(nextPageLink, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listByWorkspaceNext(nextPageLink, options, optionalCallback);
    }
  }

}

module.exports = FileServers;
