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

/**
 * Sets or removes the expiration time on the specified file. This operation
 * can only be executed against files. Folders are not supported.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file on which to set or remove the expiration time.
 *
 * @param {string} expiryOption Indicates the type of expiration to use for the
 * file: 1. NeverExpire: ExpireTime is ignored. 2. RelativeToNow: ExpireTime is
 * an integer in milliseconds representing the expiration date relative to when
 * file expiration is updated. 3. RelativeToCreationDate: ExpireTime is an
 * integer in milliseconds representing the expiration date relative to file
 * creation. 4. Absolute: ExpireTime is an integer in milliseconds, as a Unix
 * timestamp relative to 1/1/1970 00:00:00. Possible values include:
 * 'NeverExpire', 'RelativeToNow', 'RelativeToCreationDate', 'Absolute'
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.expireTime] The time that the file will expire,
 * corresponding to the ExpiryOption that was set.
 *
 * @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 _setFileExpiry(accountName, path, expiryOption, 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 expireTime = (options && options.expireTime !== undefined) ? options.expireTime : undefined;
  let op = 'SETEXPIRY';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (expiryOption) {
      let allowedValues = [ 'NeverExpire', 'RelativeToNow', 'RelativeToCreationDate', 'Absolute' ];
      if (!allowedValues.some( function(item) { return item === expiryOption; })) {
        throw new Error(expiryOption + ' is not a valid value. The valid values are: ' + allowedValues);
      }
    } else {
      throw new Error('expiryOption cannot be null or undefined.');
    }
    if (expireTime !== null && expireTime !== undefined && typeof expireTime !== 'number') {
      throw new Error('expireTime must be of type number.');
    }
    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('/') ? '' : '/') + 'WebHdfsExt/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('expiryOption=' + encodeURIComponent(expiryOption));
  if (expireTime !== null && expireTime !== undefined) {
    queryParameters.push('expireTime=' + encodeURIComponent(expireTime.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Appends to the specified file, optionally first creating the file if it does
 * not yet exist. This method supports multiple concurrent appends to the file.
 * NOTE: The target must not contain data added by Create or normal (serial)
 * Append. ConcurrentAppend and Append cannot be used interchangeably; once a
 * target file has been modified using either of these append options, the
 * other append option cannot be used on the target file. ConcurrentAppend does
 * not guarantee order and can result in duplicated data landing in the target
 * file.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file to which to append using concurrent append.
 *
 * @param {object} streamContents The file contents to include when appending
 * to the file.  The maximum content size is 4MB.  For content larger than 4MB
 * you must append the content in 4MB chunks.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.appendMode] Indicates the concurrent append call
 * should create the file if it doesn't exist or just open the existing file
 * for append. Possible values include: 'autocreate'
 *
 * @param {string} [options.syncFlag] Optionally indicates what to do after
 * completion of the concurrent append. DATA indicates that more data will be
 * sent immediately by the client, the file handle should remain open/locked,
 * and file metadata (including file length, last modified time) should NOT get
 * updated. METADATA indicates that more data will be sent immediately by the
 * client, the file handle should remain open/locked, and file metadata should
 * get updated. CLOSE indicates that the client is done sending data, the file
 * handle should be closed/unlocked, and file metadata should get updated.
 * Possible values include: 'DATA', 'METADATA', 'CLOSE'
 *
 * @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 _concurrentAppend(accountName, path, streamContents, 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 appendMode = (options && options.appendMode !== undefined) ? options.appendMode : undefined;
  let syncFlag = (options && options.syncFlag !== undefined) ? options.syncFlag : 'DATA';
  let op = 'CONCURRENTAPPEND';
  let transferEncoding = 'chunked';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (streamContents === null || streamContents === undefined) {
      throw new Error('streamContents cannot be null or undefined and it must be of type object.');
    }
    if (appendMode) {
      let allowedValues = [ 'autocreate' ];
      if (!allowedValues.some( function(item) { return item === appendMode; })) {
        throw new Error(appendMode + ' is not a valid value. The valid values are: ' + allowedValues);
      }
    }
    if (syncFlag) {
      let allowedValues1 = [ 'DATA', 'METADATA', 'CLOSE' ];
      if (!allowedValues1.some( function(item) { return item === syncFlag; })) {
        throw new Error(syncFlag + ' is not a valid value. The valid values are: ' + allowedValues1);
      }
    }
    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('/') ? '' : '/') + 'WebHdfsExt/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (appendMode !== null && appendMode !== undefined) {
    queryParameters.push('appendMode=' + encodeURIComponent(appendMode));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  if (syncFlag !== null && syncFlag !== undefined) {
    queryParameters.push('syncFlag=' + encodeURIComponent(syncFlag));
  }
  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 = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/octet-stream';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (transferEncoding !== undefined && transferEncoding !== null) {
    httpRequest.headers['Transfer-Encoding'] = transferEncoding;
  }
  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 = streamContents;
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Checks if the specified access is available at the given path.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory for which to check access.
 *
 * @param {string} fsaction File system operation read/write/execute in string
 * form, matching regex pattern '[rwx-]{3}'
 *
 * @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 _checkAccess(accountName, path, fsaction, 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 op = 'CHECKACCESS';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (fsaction === null || fsaction === undefined || typeof fsaction.valueOf() !== 'string') {
      throw new Error('fsaction 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('fsaction=' + encodeURIComponent(fsaction));
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Creates a directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * directory to create.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.permission] Optional octal permission with which
 * the directory should be created.
 *
 * @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 FileOperationResult} 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 _mkdirs(accountName, path, 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 permission = (options && options.permission !== undefined) ? options.permission : undefined;
  let op = 'MKDIRS';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (permission !== null && permission !== undefined && typeof permission !== 'number') {
      throw new Error('permission must be of type number.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (permission !== null && permission !== undefined) {
    queryParameters.push('permission=' + encodeURIComponent(permission.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['FileOperationResult']().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);
  });
}

/**
 * Concatenates the list of source files into the destination file, removing
 * all source files upon success.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * destination file resulting from the concatenation.
 *
 * @param {array} sources A list of comma separated Data Lake Store paths
 * (starting with '/') of the files to concatenate, in the order in which they
 * should be concatenated.
 *
 * @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 _concat(accountName, path, sources, 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 op = 'CONCAT';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (!Array.isArray(sources)) {
      throw new Error('sources cannot be null or undefined and it must be of type array.');
    }
    for (let i = 0; i < sources.length; i++) {
      if (sources[i] !== null && sources[i] !== undefined && typeof sources[i].valueOf() !== 'string') {
        throw new Error('sources[i] 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('sources=' + encodeURIComponent(sources.join(',')));
  queryParameters.push('op=' + encodeURIComponent(op));
  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 = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
  if (this.client.generateClientRequestId) {
      httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Concatenates the list of source files into the destination file, deleting
 * all source files upon success. This method accepts more source file paths
 * than the Concat method. This method and the parameters it accepts are
 * subject to change for usability in an upcoming version.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * destination file resulting from the concatenation.
 *
 * @param {object} streamContents A list of Data Lake Store paths (starting
 * with '/') of the source files. Must be a comma-separated path list in the
 * format: sources=/file/path/1.txt,/file/path/2.txt,/file/path/lastfile.csv
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {boolean} [options.deleteSourceDirectory] Indicates that as an
 * optimization instead of deleting each individual source stream, delete the
 * source stream folder if all streams are in the same folder instead. This
 * results in a substantial performance improvement when the only streams in
 * the folder are part of the concatenation operation. WARNING: This includes
 * the deletion of any other files that are not source files. Only set this to
 * true when source files are the only files in the source directory.
 *
 * @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 _msConcat(accountName, path, streamContents, 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 deleteSourceDirectory = (options && options.deleteSourceDirectory !== undefined) ? options.deleteSourceDirectory : undefined;
  let op = 'MSCONCAT';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (deleteSourceDirectory !== null && deleteSourceDirectory !== undefined && typeof deleteSourceDirectory !== 'boolean') {
      throw new Error('deleteSourceDirectory must be of type boolean.');
    }
    if (streamContents === null || streamContents === undefined) {
      throw new Error('streamContents cannot be null or undefined and it must be of type object.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (deleteSourceDirectory !== null && deleteSourceDirectory !== undefined) {
    queryParameters.push('deleteSourceDirectory=' + encodeURIComponent(deleteSourceDirectory.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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 = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/octet-stream';
  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 = streamContents;
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Get the list of file status objects specified by the file path, with
 * optional pagination parameters
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * directory to list.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.listSize] Gets or sets the number of items to
 * return. Optional.
 *
 * @param {string} [options.listAfter] Gets or sets the item or lexographical
 * index after which to begin returning results. For example, a file list of
 * 'a','b','d' and listAfter='b' will return 'd', and a listAfter='c' will also
 * return 'd'. Optional.
 *
 * @param {string} [options.listBefore] Gets or sets the item or lexographical
 * index before which to begin returning results. For example, a file list of
 * 'a','b','d' and listBefore='d' will return 'a','b', and a listBefore='c'
 * will also return 'a','b'. Optional.
 *
 * @param {boolean} [options.tooId] An optional switch to return friendly names
 * in place of owner and group. tooid=false returns friendly names instead of
 * the AAD Object ID. Default value is true, returning AAD object IDs.
 *
 * @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 FileStatusesResult} 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 _listFileStatus(accountName, path, 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 listSize = (options && options.listSize !== undefined) ? options.listSize : undefined;
  let listAfter = (options && options.listAfter !== undefined) ? options.listAfter : undefined;
  let listBefore = (options && options.listBefore !== undefined) ? options.listBefore : undefined;
  let tooId = (options && options.tooId !== undefined) ? options.tooId : undefined;
  let op = 'LISTSTATUS';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (listSize !== null && listSize !== undefined && typeof listSize !== 'number') {
      throw new Error('listSize must be of type number.');
    }
    if (listAfter !== null && listAfter !== undefined && typeof listAfter.valueOf() !== 'string') {
      throw new Error('listAfter must be of type string.');
    }
    if (listBefore !== null && listBefore !== undefined && typeof listBefore.valueOf() !== 'string') {
      throw new Error('listBefore must be of type string.');
    }
    if (tooId !== null && tooId !== undefined && typeof tooId !== 'boolean') {
      throw new Error('tooId must be of type boolean.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (listSize !== null && listSize !== undefined) {
    queryParameters.push('listSize=' + encodeURIComponent(listSize.toString()));
  }
  if (listAfter !== null && listAfter !== undefined) {
    queryParameters.push('listAfter=' + encodeURIComponent(listAfter));
  }
  if (listBefore !== null && listBefore !== undefined) {
    queryParameters.push('listBefore=' + encodeURIComponent(listBefore));
  }
  if (tooId !== null && tooId !== undefined) {
    queryParameters.push('tooId=' + encodeURIComponent(tooId.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['FileStatusesResult']().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 the file content summary object specified by the file path.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file for which to retrieve the summary.
 *
 * @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 ContentSummaryResult} 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 _getContentSummary(accountName, path, 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 op = 'GETCONTENTSUMMARY';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['ContentSummaryResult']().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 the file status object specified by the file path.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory for which to retrieve the status.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {boolean} [options.tooId] An optional switch to return friendly names
 * in place of owner and group. tooid=false returns friendly names instead of
 * the AAD Object ID. Default value is true, returning AAD object IDs.
 *
 * @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 FileStatusResult} 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 _getFileStatus(accountName, path, 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 tooId = (options && options.tooId !== undefined) ? options.tooId : undefined;
  let op = 'GETFILESTATUS';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (tooId !== null && tooId !== undefined && typeof tooId !== 'boolean') {
      throw new Error('tooId must be of type boolean.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (tooId !== null && tooId !== undefined) {
    queryParameters.push('tooId=' + encodeURIComponent(tooId.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['FileStatusResult']().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);
  });
}

/**
 * Opens and reads from the specified file.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file to open.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.length] The number of bytes that the server will
 * attempt to retrieve. It will retrieve <= length bytes.
 *
 * @param {number} [options.offset] The byte offset to start reading data from.
 *
 * @param {uuid} [options.fileSessionId] Optional unique GUID per file
 * indicating all the reads with the same fileSessionId are from the same
 * client and same session. This will give a performance benefit.
 *
 * @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.
 *
 *                      {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 _open(accountName, path, 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 length = (options && options.length !== undefined) ? options.length : undefined;
  let offset = (options && options.offset !== undefined) ? options.offset : undefined;
  let fileSessionId = (options && options.fileSessionId !== undefined) ? options.fileSessionId : undefined;
  let read = 'true';
  let op = 'OPEN';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (length !== null && length !== undefined && typeof length !== 'number') {
      throw new Error('length must be of type number.');
    }
    if (offset !== null && offset !== undefined && typeof offset !== 'number') {
      throw new Error('offset must be of type number.');
    }
    if (fileSessionId !== null && fileSessionId !== undefined && !(typeof fileSessionId.valueOf() === 'string' && msRest.isValidUuid(fileSessionId))) {
      throw new Error('fileSessionId must be of type string and must be a valid uuid.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (length !== null && length !== undefined) {
    queryParameters.push('length=' + encodeURIComponent(length.toString()));
  }
  if (offset !== null && offset !== undefined) {
    queryParameters.push('offset=' + encodeURIComponent(offset.toString()));
  }
  if (fileSessionId !== null && fileSessionId !== undefined) {
    queryParameters.push('fileSessionId=' + encodeURIComponent(fileSessionId.toString()));
  }
  queryParameters.push('read=' + encodeURIComponent(read));
  queryParameters.push('op=' + encodeURIComponent(op));
  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
  httpRequest.streamedResponse = true;
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }

    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(`Unexpected status code: ${statusCode}`);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        if (responseBody !== undefined) 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 = response;
    return callback(null, result, httpRequest, response);
  });
}

/**
 * Used for serial appends to the specified file. NOTE: The target must not
 * contain data added by ConcurrentAppend. ConcurrentAppend and Append cannot
 * be used interchangeably; once a target file has been modified using either
 * of these append options, the other append option cannot be used on the
 * target file.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file to which to append.
 *
 * @param {object} streamContents The file contents to include when appending
 * to the file.  The maximum content size is 4MB.  For content larger than 4MB
 * you must append the content in 4MB chunks.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {number} [options.offset] The optional offset in the stream to begin
 * the append operation. Default is to append at the end of the stream.
 *
 * @param {string} [options.syncFlag] Optionally indicates what to do after
 * completion of the concurrent append. DATA indicates that more data will be
 * sent immediately by the client, the file handle should remain open/locked,
 * and file metadata (including file length, last modified time) should NOT get
 * updated. METADATA indicates that more data will be sent immediately by the
 * client, the file handle should remain open/locked, and file metadata should
 * get updated. CLOSE indicates that the client is done sending data, the file
 * handle should be closed/unlocked, and file metadata should get updated.
 * Possible values include: 'DATA', 'METADATA', 'CLOSE'
 *
 * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
 * single writer semantics, meaning that only clients that append to the file
 * with the same leaseId will be allowed to do so.
 *
 * @param {uuid} [options.fileSessionId] Optional unique GUID per file
 * indicating all the appends with the same fileSessionId are from the same
 * client and same session. This will give a performance benefit when syncFlag
 * is DATA or METADATA.
 *
 * @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 _append(accountName, path, streamContents, 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 offset = (options && options.offset !== undefined) ? options.offset : undefined;
  let syncFlag = (options && options.syncFlag !== undefined) ? options.syncFlag : 'CLOSE';
  let leaseId = (options && options.leaseId !== undefined) ? options.leaseId : undefined;
  let fileSessionId = (options && options.fileSessionId !== undefined) ? options.fileSessionId : undefined;
  let appendParameter = 'true';
  let op = 'APPEND';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (streamContents === null || streamContents === undefined) {
      throw new Error('streamContents cannot be null or undefined and it must be of type object.');
    }
    if (offset !== null && offset !== undefined && typeof offset !== 'number') {
      throw new Error('offset must be of type number.');
    }
    if (syncFlag) {
      let allowedValues = [ 'DATA', 'METADATA', 'CLOSE' ];
      if (!allowedValues.some( function(item) { return item === syncFlag; })) {
        throw new Error(syncFlag + ' is not a valid value. The valid values are: ' + allowedValues);
      }
    }
    if (leaseId !== null && leaseId !== undefined && !(typeof leaseId.valueOf() === 'string' && msRest.isValidUuid(leaseId))) {
      throw new Error('leaseId must be of type string and must be a valid uuid.');
    }
    if (fileSessionId !== null && fileSessionId !== undefined && !(typeof fileSessionId.valueOf() === 'string' && msRest.isValidUuid(fileSessionId))) {
      throw new Error('fileSessionId must be of type string and must be a valid uuid.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (offset !== null && offset !== undefined) {
    queryParameters.push('offset=' + encodeURIComponent(offset.toString()));
  }
  if (syncFlag !== null && syncFlag !== undefined) {
    queryParameters.push('syncFlag=' + encodeURIComponent(syncFlag));
  }
  if (leaseId !== null && leaseId !== undefined) {
    queryParameters.push('leaseId=' + encodeURIComponent(leaseId.toString()));
  }
  if (fileSessionId !== null && fileSessionId !== undefined) {
    queryParameters.push('fileSessionId=' + encodeURIComponent(fileSessionId.toString()));
  }
  queryParameters.push('append=' + encodeURIComponent(appendParameter));
  queryParameters.push('op=' + encodeURIComponent(op));
  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 = 'POST';
  httpRequest.url = requestUrl;
  httpRequest.headers = {};
  // Set Headers
  httpRequest.headers['Content-Type'] = 'application/octet-stream';
  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 = streamContents;
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Creates a file with optionally specified content. NOTE: If content is
 * provided, the resulting file cannot be modified using ConcurrentAppend.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file to create.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {object} [options.streamContents] The file contents to include when
 * creating the file. This parameter is optional, resulting in an empty file if
 * not specified.  The maximum content size is 4MB.  For content larger than
 * 4MB you must append the content in 4MB chunks.
 *
 * @param {boolean} [options.overwrite] The indication of if the file should be
 * overwritten.
 *
 * @param {string} [options.syncFlag] Optionally indicates what to do after
 * completion of the create. DATA indicates that more data will be sent
 * immediately by the client, the file handle should remain open/locked, and
 * file metadata (including file length, last modified time) should NOT get
 * updated. METADATA indicates that more data will be sent immediately by the
 * client, the file handle should remain open/locked, and file metadata should
 * get updated. CLOSE indicates that the client is done sending data, the file
 * handle should be closed/unlocked, and file metadata should get updated.
 * Possible values include: 'DATA', 'METADATA', 'CLOSE'
 *
 * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
 * single writer semantics, meaning that only clients that append to the file
 * with the same leaseId will be allowed to do so.
 *
 * @param {number} [options.permission] The octal representation of the unnamed
 * user, mask and other permissions that should be set for the file when
 * created. If not specified, it inherits these from the container.
 *
 * @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 _create(accountName, path, 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 streamContents = (options && options.streamContents !== undefined) ? options.streamContents : undefined;
  let overwrite = (options && options.overwrite !== undefined) ? options.overwrite : undefined;
  let syncFlag = (options && options.syncFlag !== undefined) ? options.syncFlag : 'CLOSE';
  let leaseId = (options && options.leaseId !== undefined) ? options.leaseId : undefined;
  let permission = (options && options.permission !== undefined) ? options.permission : undefined;
  let write = 'true';
  let op = 'CREATE';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (streamContents !== null && streamContents !== undefined && typeof streamContents.valueOf() !== 'object') {
      throw new Error('streamContents must be of type object.');
    }
    if (overwrite !== null && overwrite !== undefined && typeof overwrite !== 'boolean') {
      throw new Error('overwrite must be of type boolean.');
    }
    if (syncFlag) {
      let allowedValues = [ 'DATA', 'METADATA', 'CLOSE' ];
      if (!allowedValues.some( function(item) { return item === syncFlag; })) {
        throw new Error(syncFlag + ' is not a valid value. The valid values are: ' + allowedValues);
      }
    }
    if (leaseId !== null && leaseId !== undefined && !(typeof leaseId.valueOf() === 'string' && msRest.isValidUuid(leaseId))) {
      throw new Error('leaseId must be of type string and must be a valid uuid.');
    }
    if (permission !== null && permission !== undefined && typeof permission !== 'number') {
      throw new Error('permission must be of type number.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (overwrite !== null && overwrite !== undefined) {
    queryParameters.push('overwrite=' + encodeURIComponent(overwrite.toString()));
  }
  if (syncFlag !== null && syncFlag !== undefined) {
    queryParameters.push('syncFlag=' + encodeURIComponent(syncFlag));
  }
  if (leaseId !== null && leaseId !== undefined) {
    queryParameters.push('leaseId=' + encodeURIComponent(leaseId.toString()));
  }
  if (permission !== null && permission !== undefined) {
    queryParameters.push('permission=' + encodeURIComponent(permission.toString()));
  }
  queryParameters.push('write=' + encodeURIComponent(write));
  queryParameters.push('op=' + encodeURIComponent(op));
  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/octet-stream';
  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 = streamContents;
  httpRequest.body = requestContent;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Sets the Access Control List (ACL) for a file or folder.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory on which to set the ACL.
 *
 * @param {string} aclspec The ACL spec included in ACL creation operations in
 * the format '[default:]user|group|other::r|-w|-x|-'
 *
 * @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 _setAcl(accountName, path, aclspec, 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 op = 'SETACL';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (aclspec === null || aclspec === undefined || typeof aclspec.valueOf() !== 'string') {
      throw new Error('aclspec 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('aclspec=' + encodeURIComponent(aclspec));
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Modifies existing Access Control List (ACL) entries on a file or folder.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory with the ACL being modified.
 *
 * @param {string} aclspec The ACL specification included in ACL modification
 * operations in the format '[default:]user|group|other::r|-w|-x|-'
 *
 * @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 _modifyAclEntries(accountName, path, aclspec, 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 op = 'MODIFYACLENTRIES';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (aclspec === null || aclspec === undefined || typeof aclspec.valueOf() !== 'string') {
      throw new Error('aclspec 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('aclspec=' + encodeURIComponent(aclspec));
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Removes existing Access Control List (ACL) entries for a file or folder.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory with the ACL being removed.
 *
 * @param {string} aclspec The ACL spec included in ACL removal operations in
 * the format '[default:]user|group|other'
 *
 * @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 _removeAclEntries(accountName, path, aclspec, 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 op = 'REMOVEACLENTRIES';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (aclspec === null || aclspec === undefined || typeof aclspec.valueOf() !== 'string') {
      throw new Error('aclspec 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('aclspec=' + encodeURIComponent(aclspec));
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Removes the existing Default Access Control List (ACL) of the specified
 * directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * directory with the default ACL being removed.
 *
 * @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 _removeDefaultAcl(accountName, path, 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 op = 'REMOVEDEFAULTACL';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Removes the existing Access Control List (ACL) of the specified file or
 * directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory with the ACL being removed.
 *
 * @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 _removeAcl(accountName, path, 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 op = 'REMOVEACL';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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 Access Control List (ACL) entries for the specified file or directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory for which to get the ACL.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {boolean} [options.tooId] An optional switch to return friendly names
 * in place of object ID for ACL entries. tooid=false returns friendly names
 * instead of the AAD Object ID. Default value is true, returning AAD object
 * IDs.
 *
 * @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 AclStatusResult} 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 _getAclStatus(accountName, path, 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 tooId = (options && options.tooId !== undefined) ? options.tooId : undefined;
  let op = 'GETACLSTATUS';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (tooId !== null && tooId !== undefined && typeof tooId !== 'boolean') {
      throw new Error('tooId must be of type boolean.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (tooId !== null && tooId !== undefined) {
    queryParameters.push('tooId=' + encodeURIComponent(tooId.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['AclStatusResult']().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 the requested file or directory, optionally recursively.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory to delete.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {boolean} [options.recursive] The optional switch indicating if the
 * delete should be recursive
 *
 * @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 FileOperationResult} for more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _deleteMethod(accountName, path, 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 recursive = (options && options.recursive !== undefined) ? options.recursive : undefined;
  let op = 'DELETE';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (recursive !== null && recursive !== undefined && typeof recursive !== 'boolean') {
      throw new Error('recursive must be of type boolean.');
    }
    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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (recursive !== null && recursive !== undefined) {
    queryParameters.push('recursive=' + encodeURIComponent(recursive.toString()));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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) {
      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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['FileOperationResult']().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);
  });
}

/**
 * Rename a file or directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory to move/rename.
 *
 * @param {string} destination The path to move/rename the file or folder to
 *
 * @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 FileOperationResult} 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 _rename(accountName, path, destination, 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 op = 'RENAME';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (destination === null || destination === undefined || typeof destination.valueOf() !== 'string') {
      throw new Error('destination 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  queryParameters.push('destination=' + encodeURIComponent(destination));
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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['FileOperationResult']().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);
  });
}

/**
 * Sets the owner of a file or directory.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory for which to set the owner.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.owner] The AAD Object ID of the user owner of the
 * file or directory. If empty, the property will remain unchanged.
 *
 * @param {string} [options.group] The AAD Object ID of the group owner of the
 * file or directory. If empty, the property will remain unchanged.
 *
 * @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 _setOwner(accountName, path, 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 owner = (options && options.owner !== undefined) ? options.owner : undefined;
  let group = (options && options.group !== undefined) ? options.group : undefined;
  let op = 'SETOWNER';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (owner !== null && owner !== undefined && typeof owner.valueOf() !== 'string') {
      throw new Error('owner must be of type string.');
    }
    if (group !== null && group !== undefined && typeof group.valueOf() !== 'string') {
      throw new Error('group 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (owner !== null && owner !== undefined) {
    queryParameters.push('owner=' + encodeURIComponent(owner));
  }
  if (group !== null && group !== undefined) {
    queryParameters.push('group=' + encodeURIComponent(group));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().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);
  });
}

/**
 * Sets the permission of the file or folder.
 *
 * @param {string} accountName The Azure Data Lake Store account to execute
 * filesystem operations on.
 *
 * @param {string} path The Data Lake Store path (starting with '/') of the
 * file or directory for which to set the permission.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.permission] A string representation of the
 * permission (i.e 'rwx'). If empty, this property remains unchanged.
 *
 * @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 _setPermission(accountName, path, 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 permission = (options && options.permission !== undefined) ? options.permission : undefined;
  let op = 'SETPERMISSION';
  // Validate
  try {
    if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') {
      throw new Error('accountName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.adlsFileSystemDnsSuffix === null || this.client.adlsFileSystemDnsSuffix === undefined || typeof this.client.adlsFileSystemDnsSuffix.valueOf() !== 'string') {
      throw new Error('this.client.adlsFileSystemDnsSuffix cannot be null or undefined and it must be of type string.');
    }
    if (path === null || path === undefined || typeof path.valueOf() !== 'string') {
      throw new Error('path cannot be null or undefined and it must be of type string.');
    }
    if (permission !== null && permission !== undefined && typeof permission.valueOf() !== 'string') {
      throw new Error('permission 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('/') ? '' : '/') + 'webhdfs/v1/{path}';
  requestUrl = requestUrl.replace('{accountName}', accountName);
  requestUrl = requestUrl.replace('{adlsFileSystemDnsSuffix}', this.client.adlsFileSystemDnsSuffix);
  requestUrl = requestUrl.replace('{path}', encodeURIComponent(path));
  let queryParameters = [];
  if (permission !== null && permission !== undefined) {
    queryParameters.push('permission=' + encodeURIComponent(permission));
  }
  queryParameters.push('op=' + encodeURIComponent(op));
  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];
      }
    }
  }
  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) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['AdlsError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/** Class representing a FileSystem. */
class FileSystem {
  /**
   * Create a FileSystem.
   * @param {DataLakeStoreFileSystemManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._setFileExpiry = _setFileExpiry;
    this._concurrentAppend = _concurrentAppend;
    this._checkAccess = _checkAccess;
    this._mkdirs = _mkdirs;
    this._concat = _concat;
    this._msConcat = _msConcat;
    this._listFileStatus = _listFileStatus;
    this._getContentSummary = _getContentSummary;
    this._getFileStatus = _getFileStatus;
    this._open = _open;
    this._append = _append;
    this._create = _create;
    this._setAcl = _setAcl;
    this._modifyAclEntries = _modifyAclEntries;
    this._removeAclEntries = _removeAclEntries;
    this._removeDefaultAcl = _removeDefaultAcl;
    this._removeAcl = _removeAcl;
    this._getAclStatus = _getAclStatus;
    this._deleteMethod = _deleteMethod;
    this._rename = _rename;
    this._setOwner = _setOwner;
    this._setPermission = _setPermission;
  }

  /**
   * Sets or removes the expiration time on the specified file. This operation
   * can only be executed against files. Folders are not supported.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file on which to set or remove the expiration time.
   *
   * @param {string} expiryOption Indicates the type of expiration to use for the
   * file: 1. NeverExpire: ExpireTime is ignored. 2. RelativeToNow: ExpireTime is
   * an integer in milliseconds representing the expiration date relative to when
   * file expiration is updated. 3. RelativeToCreationDate: ExpireTime is an
   * integer in milliseconds representing the expiration date relative to file
   * creation. 4. Absolute: ExpireTime is an integer in milliseconds, as a Unix
   * timestamp relative to 1/1/1970 00:00:00. Possible values include:
   * 'NeverExpire', 'RelativeToNow', 'RelativeToCreationDate', 'Absolute'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.expireTime] The time that the file will expire,
   * corresponding to the ExpiryOption that was set.
   *
   * @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.
   */
  setFileExpiryWithHttpOperationResponse(accountName, path, expiryOption, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._setFileExpiry(accountName, path, expiryOption, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Sets or removes the expiration time on the specified file. This operation
   * can only be executed against files. Folders are not supported.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file on which to set or remove the expiration time.
   *
   * @param {string} expiryOption Indicates the type of expiration to use for the
   * file: 1. NeverExpire: ExpireTime is ignored. 2. RelativeToNow: ExpireTime is
   * an integer in milliseconds representing the expiration date relative to when
   * file expiration is updated. 3. RelativeToCreationDate: ExpireTime is an
   * integer in milliseconds representing the expiration date relative to file
   * creation. 4. Absolute: ExpireTime is an integer in milliseconds, as a Unix
   * timestamp relative to 1/1/1970 00:00:00. Possible values include:
   * 'NeverExpire', 'RelativeToNow', 'RelativeToCreationDate', 'Absolute'
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.expireTime] The time that the file will expire,
   * corresponding to the ExpiryOption that was set.
   *
   * @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.
   */
  setFileExpiry(accountName, path, expiryOption, 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._setFileExpiry(accountName, path, expiryOption, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._setFileExpiry(accountName, path, expiryOption, options, optionalCallback);
    }
  }

  /**
   * Appends to the specified file, optionally first creating the file if it does
   * not yet exist. This method supports multiple concurrent appends to the file.
   * NOTE: The target must not contain data added by Create or normal (serial)
   * Append. ConcurrentAppend and Append cannot be used interchangeably; once a
   * target file has been modified using either of these append options, the
   * other append option cannot be used on the target file. ConcurrentAppend does
   * not guarantee order and can result in duplicated data landing in the target
   * file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to which to append using concurrent append.
   *
   * @param {object} streamContents The file contents to include when appending
   * to the file.  The maximum content size is 4MB.  For content larger than 4MB
   * you must append the content in 4MB chunks.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.appendMode] Indicates the concurrent append call
   * should create the file if it doesn't exist or just open the existing file
   * for append. Possible values include: 'autocreate'
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the concurrent append. DATA indicates that more data will be
   * sent immediately by the client, the file handle should remain open/locked,
   * and file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @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.
   */
  concurrentAppendWithHttpOperationResponse(accountName, path, streamContents, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._concurrentAppend(accountName, path, streamContents, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Appends to the specified file, optionally first creating the file if it does
   * not yet exist. This method supports multiple concurrent appends to the file.
   * NOTE: The target must not contain data added by Create or normal (serial)
   * Append. ConcurrentAppend and Append cannot be used interchangeably; once a
   * target file has been modified using either of these append options, the
   * other append option cannot be used on the target file. ConcurrentAppend does
   * not guarantee order and can result in duplicated data landing in the target
   * file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to which to append using concurrent append.
   *
   * @param {object} streamContents The file contents to include when appending
   * to the file.  The maximum content size is 4MB.  For content larger than 4MB
   * you must append the content in 4MB chunks.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.appendMode] Indicates the concurrent append call
   * should create the file if it doesn't exist or just open the existing file
   * for append. Possible values include: 'autocreate'
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the concurrent append. DATA indicates that more data will be
   * sent immediately by the client, the file handle should remain open/locked,
   * and file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @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.
   */
  concurrentAppend(accountName, path, streamContents, 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._concurrentAppend(accountName, path, streamContents, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._concurrentAppend(accountName, path, streamContents, options, optionalCallback);
    }
  }

  /**
   * Checks if the specified access is available at the given path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to check access.
   *
   * @param {string} fsaction File system operation read/write/execute in string
   * form, matching regex pattern '[rwx-]{3}'
   *
   * @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.
   */
  checkAccessWithHttpOperationResponse(accountName, path, fsaction, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._checkAccess(accountName, path, fsaction, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Checks if the specified access is available at the given path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to check access.
   *
   * @param {string} fsaction File system operation read/write/execute in string
   * form, matching regex pattern '[rwx-]{3}'
   *
   * @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.
   */
  checkAccess(accountName, path, fsaction, 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._checkAccess(accountName, path, fsaction, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._checkAccess(accountName, path, fsaction, options, optionalCallback);
    }
  }

  /**
   * Creates a directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory to create.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.permission] Optional octal permission with which
   * the directory should be created.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileOperationResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  mkdirsWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._mkdirs(accountName, path, 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 directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory to create.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.permission] Optional octal permission with which
   * the directory should be created.
   *
   * @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 {FileOperationResult} - 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 FileOperationResult} 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.
   */
  mkdirs(accountName, path, 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._mkdirs(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._mkdirs(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Concatenates the list of source files into the destination file, removing
   * all source files upon success.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * destination file resulting from the concatenation.
   *
   * @param {array} sources A list of comma separated Data Lake Store paths
   * (starting with '/') of the files to concatenate, in the order in which they
   * should be concatenated.
   *
   * @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.
   */
  concatWithHttpOperationResponse(accountName, path, sources, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._concat(accountName, path, sources, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Concatenates the list of source files into the destination file, removing
   * all source files upon success.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * destination file resulting from the concatenation.
   *
   * @param {array} sources A list of comma separated Data Lake Store paths
   * (starting with '/') of the files to concatenate, in the order in which they
   * should be concatenated.
   *
   * @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.
   */
  concat(accountName, path, sources, 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._concat(accountName, path, sources, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._concat(accountName, path, sources, options, optionalCallback);
    }
  }

  /**
   * Concatenates the list of source files into the destination file, deleting
   * all source files upon success. This method accepts more source file paths
   * than the Concat method. This method and the parameters it accepts are
   * subject to change for usability in an upcoming version.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * destination file resulting from the concatenation.
   *
   * @param {object} streamContents A list of Data Lake Store paths (starting
   * with '/') of the source files. Must be a comma-separated path list in the
   * format: sources=/file/path/1.txt,/file/path/2.txt,/file/path/lastfile.csv
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.deleteSourceDirectory] Indicates that as an
   * optimization instead of deleting each individual source stream, delete the
   * source stream folder if all streams are in the same folder instead. This
   * results in a substantial performance improvement when the only streams in
   * the folder are part of the concatenation operation. WARNING: This includes
   * the deletion of any other files that are not source files. Only set this to
   * true when source files are the only files in the source directory.
   *
   * @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.
   */
  msConcatWithHttpOperationResponse(accountName, path, streamContents, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._msConcat(accountName, path, streamContents, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Concatenates the list of source files into the destination file, deleting
   * all source files upon success. This method accepts more source file paths
   * than the Concat method. This method and the parameters it accepts are
   * subject to change for usability in an upcoming version.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * destination file resulting from the concatenation.
   *
   * @param {object} streamContents A list of Data Lake Store paths (starting
   * with '/') of the source files. Must be a comma-separated path list in the
   * format: sources=/file/path/1.txt,/file/path/2.txt,/file/path/lastfile.csv
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.deleteSourceDirectory] Indicates that as an
   * optimization instead of deleting each individual source stream, delete the
   * source stream folder if all streams are in the same folder instead. This
   * results in a substantial performance improvement when the only streams in
   * the folder are part of the concatenation operation. WARNING: This includes
   * the deletion of any other files that are not source files. Only set this to
   * true when source files are the only files in the source directory.
   *
   * @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.
   */
  msConcat(accountName, path, streamContents, 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._msConcat(accountName, path, streamContents, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._msConcat(accountName, path, streamContents, options, optionalCallback);
    }
  }

  /**
   * Get the list of file status objects specified by the file path, with
   * optional pagination parameters
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory to list.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.listSize] Gets or sets the number of items to
   * return. Optional.
   *
   * @param {string} [options.listAfter] Gets or sets the item or lexographical
   * index after which to begin returning results. For example, a file list of
   * 'a','b','d' and listAfter='b' will return 'd', and a listAfter='c' will also
   * return 'd'. Optional.
   *
   * @param {string} [options.listBefore] Gets or sets the item or lexographical
   * index before which to begin returning results. For example, a file list of
   * 'a','b','d' and listBefore='d' will return 'a','b', and a listBefore='c'
   * will also return 'a','b'. Optional.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of owner and group. tooid=false returns friendly names instead of
   * the AAD Object ID. Default value is true, returning AAD object IDs.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileStatusesResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listFileStatusWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._listFileStatus(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get the list of file status objects specified by the file path, with
   * optional pagination parameters
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory to list.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.listSize] Gets or sets the number of items to
   * return. Optional.
   *
   * @param {string} [options.listAfter] Gets or sets the item or lexographical
   * index after which to begin returning results. For example, a file list of
   * 'a','b','d' and listAfter='b' will return 'd', and a listAfter='c' will also
   * return 'd'. Optional.
   *
   * @param {string} [options.listBefore] Gets or sets the item or lexographical
   * index before which to begin returning results. For example, a file list of
   * 'a','b','d' and listBefore='d' will return 'a','b', and a listBefore='c'
   * will also return 'a','b'. Optional.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of owner and group. tooid=false returns friendly names instead of
   * the AAD Object ID. Default value is true, returning AAD object IDs.
   *
   * @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 {FileStatusesResult} - 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 FileStatusesResult} 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.
   */
  listFileStatus(accountName, path, 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._listFileStatus(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._listFileStatus(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Gets the file content summary object specified by the file path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file for which to retrieve the summary.
   *
   * @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<ContentSummaryResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getContentSummaryWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getContentSummary(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets the file content summary object specified by the file path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file for which to retrieve the summary.
   *
   * @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 {ContentSummaryResult} - 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 ContentSummaryResult} 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.
   */
  getContentSummary(accountName, path, 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._getContentSummary(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getContentSummary(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Get the file status object specified by the file path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to retrieve the status.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of owner and group. tooid=false returns friendly names instead of
   * the AAD Object ID. Default value is true, returning AAD object IDs.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileStatusResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getFileStatusWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getFileStatus(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get the file status object specified by the file path.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to retrieve the status.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of owner and group. tooid=false returns friendly names instead of
   * the AAD Object ID. Default value is true, returning AAD object IDs.
   *
   * @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 {FileStatusResult} - 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 FileStatusResult} 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.
   */
  getFileStatus(accountName, path, 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._getFileStatus(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getFileStatus(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Opens and reads from the specified file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to open.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.length] The number of bytes that the server will
   * attempt to retrieve. It will retrieve <= length bytes.
   *
   * @param {number} [options.offset] The byte offset to start reading data from.
   *
   * @param {uuid} [options.fileSessionId] Optional unique GUID per file
   * indicating all the reads with the same fileSessionId are from the same
   * client and same session. This will give a performance benefit.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<Object>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  openWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._open(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Opens and reads from the specified file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to open.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.length] The number of bytes that the server will
   * attempt to retrieve. It will retrieve <= length bytes.
   *
   * @param {number} [options.offset] The byte offset to start reading data from.
   *
   * @param {uuid} [options.fileSessionId] Optional unique GUID per file
   * indicating all the reads with the same fileSessionId are from the same
   * client and same session. This will give a performance benefit.
   *
   * @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 {Object} - 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.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  open(accountName, path, 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._open(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._open(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Used for serial appends to the specified file. NOTE: The target must not
   * contain data added by ConcurrentAppend. ConcurrentAppend and Append cannot
   * be used interchangeably; once a target file has been modified using either
   * of these append options, the other append option cannot be used on the
   * target file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to which to append.
   *
   * @param {object} streamContents The file contents to include when appending
   * to the file.  The maximum content size is 4MB.  For content larger than 4MB
   * you must append the content in 4MB chunks.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.offset] The optional offset in the stream to begin
   * the append operation. Default is to append at the end of the stream.
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the concurrent append. DATA indicates that more data will be
   * sent immediately by the client, the file handle should remain open/locked,
   * and file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
   * single writer semantics, meaning that only clients that append to the file
   * with the same leaseId will be allowed to do so.
   *
   * @param {uuid} [options.fileSessionId] Optional unique GUID per file
   * indicating all the appends with the same fileSessionId are from the same
   * client and same session. This will give a performance benefit when syncFlag
   * is DATA or METADATA.
   *
   * @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.
   */
  appendWithHttpOperationResponse(accountName, path, streamContents, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._append(accountName, path, streamContents, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Used for serial appends to the specified file. NOTE: The target must not
   * contain data added by ConcurrentAppend. ConcurrentAppend and Append cannot
   * be used interchangeably; once a target file has been modified using either
   * of these append options, the other append option cannot be used on the
   * target file.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to which to append.
   *
   * @param {object} streamContents The file contents to include when appending
   * to the file.  The maximum content size is 4MB.  For content larger than 4MB
   * you must append the content in 4MB chunks.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {number} [options.offset] The optional offset in the stream to begin
   * the append operation. Default is to append at the end of the stream.
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the concurrent append. DATA indicates that more data will be
   * sent immediately by the client, the file handle should remain open/locked,
   * and file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
   * single writer semantics, meaning that only clients that append to the file
   * with the same leaseId will be allowed to do so.
   *
   * @param {uuid} [options.fileSessionId] Optional unique GUID per file
   * indicating all the appends with the same fileSessionId are from the same
   * client and same session. This will give a performance benefit when syncFlag
   * is DATA or METADATA.
   *
   * @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.
   */
  append(accountName, path, streamContents, 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._append(accountName, path, streamContents, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._append(accountName, path, streamContents, options, optionalCallback);
    }
  }

  /**
   * Creates a file with optionally specified content. NOTE: If content is
   * provided, the resulting file cannot be modified using ConcurrentAppend.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to create.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.streamContents] The file contents to include when
   * creating the file. This parameter is optional, resulting in an empty file if
   * not specified.  The maximum content size is 4MB.  For content larger than
   * 4MB you must append the content in 4MB chunks.
   *
   * @param {boolean} [options.overwrite] The indication of if the file should be
   * overwritten.
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the create. DATA indicates that more data will be sent
   * immediately by the client, the file handle should remain open/locked, and
   * file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
   * single writer semantics, meaning that only clients that append to the file
   * with the same leaseId will be allowed to do so.
   *
   * @param {number} [options.permission] The octal representation of the unnamed
   * user, mask and other permissions that should be set for the file when
   * created. If not specified, it inherits these from the container.
   *
   * @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.
   */
  createWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(accountName, path, 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 with optionally specified content. NOTE: If content is
   * provided, the resulting file cannot be modified using ConcurrentAppend.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file to create.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {object} [options.streamContents] The file contents to include when
   * creating the file. This parameter is optional, resulting in an empty file if
   * not specified.  The maximum content size is 4MB.  For content larger than
   * 4MB you must append the content in 4MB chunks.
   *
   * @param {boolean} [options.overwrite] The indication of if the file should be
   * overwritten.
   *
   * @param {string} [options.syncFlag] Optionally indicates what to do after
   * completion of the create. DATA indicates that more data will be sent
   * immediately by the client, the file handle should remain open/locked, and
   * file metadata (including file length, last modified time) should NOT get
   * updated. METADATA indicates that more data will be sent immediately by the
   * client, the file handle should remain open/locked, and file metadata should
   * get updated. CLOSE indicates that the client is done sending data, the file
   * handle should be closed/unlocked, and file metadata should get updated.
   * Possible values include: 'DATA', 'METADATA', 'CLOSE'
   *
   * @param {uuid} [options.leaseId] Optional unique GUID per file to ensure
   * single writer semantics, meaning that only clients that append to the file
   * with the same leaseId will be allowed to do so.
   *
   * @param {number} [options.permission] The octal representation of the unnamed
   * user, mask and other permissions that should be set for the file when
   * created. If not specified, it inherits these from the container.
   *
   * @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.
   */
  create(accountName, path, 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(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Sets the Access Control List (ACL) for a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory on which to set the ACL.
   *
   * @param {string} aclspec The ACL spec included in ACL creation operations in
   * the format '[default:]user|group|other::r|-w|-x|-'
   *
   * @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.
   */
  setAclWithHttpOperationResponse(accountName, path, aclspec, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._setAcl(accountName, path, aclspec, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Sets the Access Control List (ACL) for a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory on which to set the ACL.
   *
   * @param {string} aclspec The ACL spec included in ACL creation operations in
   * the format '[default:]user|group|other::r|-w|-x|-'
   *
   * @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.
   */
  setAcl(accountName, path, aclspec, 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._setAcl(accountName, path, aclspec, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._setAcl(accountName, path, aclspec, options, optionalCallback);
    }
  }

  /**
   * Modifies existing Access Control List (ACL) entries on a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being modified.
   *
   * @param {string} aclspec The ACL specification included in ACL modification
   * operations in the format '[default:]user|group|other::r|-w|-x|-'
   *
   * @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.
   */
  modifyAclEntriesWithHttpOperationResponse(accountName, path, aclspec, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._modifyAclEntries(accountName, path, aclspec, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Modifies existing Access Control List (ACL) entries on a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being modified.
   *
   * @param {string} aclspec The ACL specification included in ACL modification
   * operations in the format '[default:]user|group|other::r|-w|-x|-'
   *
   * @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.
   */
  modifyAclEntries(accountName, path, aclspec, 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._modifyAclEntries(accountName, path, aclspec, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._modifyAclEntries(accountName, path, aclspec, options, optionalCallback);
    }
  }

  /**
   * Removes existing Access Control List (ACL) entries for a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being removed.
   *
   * @param {string} aclspec The ACL spec included in ACL removal operations in
   * the format '[default:]user|group|other'
   *
   * @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.
   */
  removeAclEntriesWithHttpOperationResponse(accountName, path, aclspec, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._removeAclEntries(accountName, path, aclspec, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Removes existing Access Control List (ACL) entries for a file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being removed.
   *
   * @param {string} aclspec The ACL spec included in ACL removal operations in
   * the format '[default:]user|group|other'
   *
   * @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.
   */
  removeAclEntries(accountName, path, aclspec, 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._removeAclEntries(accountName, path, aclspec, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._removeAclEntries(accountName, path, aclspec, options, optionalCallback);
    }
  }

  /**
   * Removes the existing Default Access Control List (ACL) of the specified
   * directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory with the default ACL being removed.
   *
   * @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.
   */
  removeDefaultAclWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._removeDefaultAcl(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Removes the existing Default Access Control List (ACL) of the specified
   * directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * directory with the default ACL being removed.
   *
   * @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.
   */
  removeDefaultAcl(accountName, path, 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._removeDefaultAcl(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._removeDefaultAcl(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Removes the existing Access Control List (ACL) of the specified file or
   * directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being removed.
   *
   * @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.
   */
  removeAclWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._removeAcl(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Removes the existing Access Control List (ACL) of the specified file or
   * directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory with the ACL being removed.
   *
   * @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.
   */
  removeAcl(accountName, path, 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._removeAcl(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._removeAcl(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Gets Access Control List (ACL) entries for the specified file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to get the ACL.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of object ID for ACL entries. tooid=false returns friendly names
   * instead of the AAD Object ID. Default value is true, returning AAD object
   * IDs.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<AclStatusResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getAclStatusWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getAclStatus(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Gets Access Control List (ACL) entries for the specified file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to get the ACL.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.tooId] An optional switch to return friendly names
   * in place of object ID for ACL entries. tooid=false returns friendly names
   * instead of the AAD Object ID. Default value is true, returning AAD object
   * IDs.
   *
   * @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 {AclStatusResult} - 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 AclStatusResult} 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.
   */
  getAclStatus(accountName, path, 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._getAclStatus(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getAclStatus(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Deletes the requested file or directory, optionally recursively.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory to delete.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.recursive] The optional switch indicating if the
   * delete should be recursive
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<FileOperationResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Deletes the requested file or directory, optionally recursively.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory to delete.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {boolean} [options.recursive] The optional switch indicating if the
   * delete should be recursive
   *
   * @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 {FileOperationResult} - 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 FileOperationResult} for more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(accountName, path, 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(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Rename a file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory to move/rename.
   *
   * @param {string} destination The path to move/rename the file or folder to
   *
   * @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<FileOperationResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  renameWithHttpOperationResponse(accountName, path, destination, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._rename(accountName, path, destination, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Rename a file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory to move/rename.
   *
   * @param {string} destination The path to move/rename the file or folder to
   *
   * @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 {FileOperationResult} - 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 FileOperationResult} 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.
   */
  rename(accountName, path, destination, 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._rename(accountName, path, destination, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._rename(accountName, path, destination, options, optionalCallback);
    }
  }

  /**
   * Sets the owner of a file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to set the owner.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.owner] The AAD Object ID of the user owner of the
   * file or directory. If empty, the property will remain unchanged.
   *
   * @param {string} [options.group] The AAD Object ID of the group owner of the
   * file or directory. If empty, the property will remain unchanged.
   *
   * @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.
   */
  setOwnerWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._setOwner(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Sets the owner of a file or directory.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to set the owner.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.owner] The AAD Object ID of the user owner of the
   * file or directory. If empty, the property will remain unchanged.
   *
   * @param {string} [options.group] The AAD Object ID of the group owner of the
   * file or directory. If empty, the property will remain unchanged.
   *
   * @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.
   */
  setOwner(accountName, path, 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._setOwner(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._setOwner(accountName, path, options, optionalCallback);
    }
  }

  /**
   * Sets the permission of the file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to set the permission.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.permission] A string representation of the
   * permission (i.e 'rwx'). If empty, this property remains unchanged.
   *
   * @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.
   */
  setPermissionWithHttpOperationResponse(accountName, path, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._setPermission(accountName, path, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Sets the permission of the file or folder.
   *
   * @param {string} accountName The Azure Data Lake Store account to execute
   * filesystem operations on.
   *
   * @param {string} path The Data Lake Store path (starting with '/') of the
   * file or directory for which to set the permission.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.permission] A string representation of the
   * permission (i.e 'rwx'). If empty, this property remains unchanged.
   *
   * @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.
   */
  setPermission(accountName, path, 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._setPermission(accountName, path, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._setPermission(accountName, path, options, optionalCallback);
    }
  }

}

module.exports = FileSystem;
