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

/**
 * Gets the alert settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 AlertSettings} 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 _getAlertSettings(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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


/**
 * Creates or updates the alert settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The alert settings to be added or updated.
 *
 * @param {string} parameters.emailNotification Indicates whether email
 * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {string} [parameters.alertNotificationCulture] The alert notification
 * culture.
 *
 * @param {string} [parameters.notificationToServiceOwners] The value
 * indicating whether alert notification enabled for admin or not. Possible
 * values include: 'Enabled', 'Disabled'
 *
 * @param {array} [parameters.additionalRecipientEmailList] The alert
 * notification email list.
 *
 * @param {string} [parameters.kind] The Kind of the object. Currently only
 * Series8000 is supported. Possible values include: 'Series8000'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 AlertSettings} 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 _createOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['AlertSettings']().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 network settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 NetworkSettings} 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 _getNetworkSettings(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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


/**
 * Updates the network settings on the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The network settings to be updated.
 *
 * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
 * settings of device.
 *
 * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
 * DNS server for the device
 *
 * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
 * IPv6 DNS server for the device
 *
 * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
 * IPv4 DNS server for the device
 *
 * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
 * secondary IPv6 DNS server for the device
 *
 * @param {object} [parameters.networkAdapters] The network adapter list of
 * device.
 *
 * @param {array} parameters.networkAdapters.value The value.
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 NetworkSettings} 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 _updateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['NetworkSettings']().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);
    });
  });
}

/**
 * Returns the Security properties of the specified device name.
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 SecuritySettings} 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 _getSecuritySettings(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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


/**
 * Patch Security properties of the specified device name.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The security settings properties to be patched.
 *
 * @param {object} [parameters.remoteManagementSettings] The remote management
 * settings.
 *
 * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
 * remote management mode. Possible values include: 'Unknown', 'Disabled',
 * 'HttpsEnabled', 'HttpsAndHttpEnabled'
 *
 * @param {object} [parameters.deviceAdminPassword] The device administrator
 * password.
 *
 * @param {object} [parameters.snapshotPassword] The snapshot manager password.
 *
 * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
 * settings.
 *
 * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
 * user.
 *
 * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
 * secret.
 *
 * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
 *
 * @param {object} [parameters.chapSettings.targetSecret] The target secret.
 *
 * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
 * settings.
 *
 * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
 * The service data encryption key (encrypted with DAK).
 *
 * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
 * channel integrity key (encrypted with DAK).
 *
 * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
 * The value of the secret.
 *
 * @param {string}
 * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
 * Thumbprint certificate that was used to encrypt "Value". If the value in
 * unencrypted, it will be null.
 *
 * @param {string}
 * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
 * The algorithm used to encrypt "Value". Possible values include: 'None',
 * 'AES256', 'RSAES_PKCS1_v_1_5'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 SecuritySettings} 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 _updateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['SecuritySettings']().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);
    });
  });
}


/**
 * sync Remote management Certificate between appliance and Service
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 _syncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

      // Deserialize Response

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

/**
 * Gets the time settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 TimeSettings} 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 _getTimeSettings(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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


/**
 * Creates or updates the time settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The time settings to be added or updated.
 *
 * @param {string} parameters.timeZone The timezone of device, like '(UTC
 * -06:00) Central America'
 *
 * @param {string} [parameters.primaryTimeServer] The primary Network Time
 * Protocol (NTP) server name, like 'time.windows.com'.
 *
 * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
 * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
 *
 * @param {string} [parameters.kind] The Kind of the object. Currently only
 * Series8000 is supported. Possible values include: 'Series8000'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 TimeSettings} 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 _createOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }

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

  // Send request
  this.beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, parsedResult, httpRequest, response) => {
    if (err) return callback(err);

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

      // Create Result
      let result = null;

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

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

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

/**
 * Creates or updates the alert settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The alert settings to be added or updated.
 *
 * @param {string} parameters.emailNotification Indicates whether email
 * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
 *
 * @param {string} [parameters.alertNotificationCulture] The alert notification
 * culture.
 *
 * @param {string} [parameters.notificationToServiceOwners] The value
 * indicating whether alert notification enabled for admin or not. Possible
 * values include: 'Enabled', 'Disabled'
 *
 * @param {array} [parameters.additionalRecipientEmailList] The alert
 * notification email list.
 *
 * @param {string} [parameters.kind] The Kind of the object. Currently only
 * Series8000 is supported. Possible values include: 'Series8000'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 AlertSettings} 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 _beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/alertSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * Updates the network settings on the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The network settings to be updated.
 *
 * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
 * settings of device.
 *
 * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
 * DNS server for the device
 *
 * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
 * IPv6 DNS server for the device
 *
 * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
 * IPv4 DNS server for the device
 *
 * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
 * secondary IPv6 DNS server for the device
 *
 * @param {object} [parameters.networkAdapters] The network adapter list of
 * device.
 *
 * @param {array} parameters.networkAdapters.value The value.
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 NetworkSettings} 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 _beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/networkSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * Patch Security properties of the specified device name.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The security settings properties to be patched.
 *
 * @param {object} [parameters.remoteManagementSettings] The remote management
 * settings.
 *
 * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
 * remote management mode. Possible values include: 'Unknown', 'Disabled',
 * 'HttpsEnabled', 'HttpsAndHttpEnabled'
 *
 * @param {object} [parameters.deviceAdminPassword] The device administrator
 * password.
 *
 * @param {object} [parameters.snapshotPassword] The snapshot manager password.
 *
 * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
 * settings.
 *
 * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
 * user.
 *
 * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
 * secret.
 *
 * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
 *
 * @param {object} [parameters.chapSettings.targetSecret] The target secret.
 *
 * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
 * settings.
 *
 * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
 * The service data encryption key (encrypted with DAK).
 *
 * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
 * channel integrity key (encrypted with DAK).
 *
 * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
 * The value of the secret.
 *
 * @param {string}
 * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
 * Thumbprint certificate that was used to encrypt "Value". If the value in
 * unencrypted, it will be null.
 *
 * @param {string}
 * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
 * The algorithm used to encrypt "Value". Possible values include: 'None',
 * 'AES256', 'RSAES_PKCS1_v_1_5'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 SecuritySettings} 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 _beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

/**
 * sync Remote management Certificate between appliance and Service
 *
 * @param {string} deviceName The device name
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 _beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/securitySettings/default/syncRemoteManagementCertificate';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + 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 !== 202 && statusCode !== 204) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
          if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
          if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['CloudError']().mapper();
          error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
        }
      } catch (defaultError) {
        error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
                         `- "${responseBody}" for the default response.`;
        return callback(error);
      }
      return callback(error);
    }
    // Create Result
    let result = null;
    if (responseBody === '') responseBody = null;

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

/**
 * Creates or updates the time settings of the specified device.
 *
 * @param {string} deviceName The device name
 *
 * @param {object} parameters The time settings to be added or updated.
 *
 * @param {string} parameters.timeZone The timezone of device, like '(UTC
 * -06:00) Central America'
 *
 * @param {string} [parameters.primaryTimeServer] The primary Network Time
 * Protocol (NTP) server name, like 'time.windows.com'.
 *
 * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
 * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
 *
 * @param {string} [parameters.kind] The Kind of the object. Currently only
 * Series8000 is supported. Possible values include: 'Series8000'
 *
 * @param {string} resourceGroupName The resource group name
 *
 * @param {string} managerName The manager name
 *
 * @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 TimeSettings} 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 _beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  // Validate
  try {
    if (deviceName === null || deviceName === undefined || typeof deviceName.valueOf() !== 'string') {
      throw new Error('deviceName cannot be null or undefined and it must be of type string.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (managerName === null || managerName === undefined || typeof managerName.valueOf() !== 'string') {
      throw new Error('managerName cannot be null or undefined and it must be of type string.');
    }
    if (managerName !== null && managerName !== undefined) {
      if (managerName.length > 50)
      {
        throw new Error('"managerName" should satisfy the constraint - "MaxLength": 50');
      }
      if (managerName.length < 2)
      {
        throw new Error('"managerName" should satisfy the constraint - "MinLength": 2');
      }
    }
    if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
      throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
    }
    if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
      throw new Error('this.client.acceptLanguage must be of type string.');
    }
  } catch (error) {
    return callback(error);
  }

  // Construct URL
  let baseUrl = this.client.baseUri;
  let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorSimple/managers/{managerName}/devices/{deviceName}/timeSettings/default';
  requestUrl = requestUrl.replace('{deviceName}', deviceName);
  requestUrl = requestUrl.replace('{subscriptionId}', this.client.subscriptionId);
  requestUrl = requestUrl.replace('{resourceGroupName}', resourceGroupName);
  requestUrl = requestUrl.replace('{managerName}', managerName);
  let queryParameters = [];
  queryParameters.push('api-version=' + this.client.apiVersion);
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/** Class representing a DeviceSettings. */
class DeviceSettings {
  /**
   * Create a DeviceSettings.
   * @param {StorSimple8000SeriesManagementClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._getAlertSettings = _getAlertSettings;
    this._createOrUpdateAlertSettings = _createOrUpdateAlertSettings;
    this._getNetworkSettings = _getNetworkSettings;
    this._updateNetworkSettings = _updateNetworkSettings;
    this._getSecuritySettings = _getSecuritySettings;
    this._updateSecuritySettings = _updateSecuritySettings;
    this._syncRemotemanagementCertificate = _syncRemotemanagementCertificate;
    this._getTimeSettings = _getTimeSettings;
    this._createOrUpdateTimeSettings = _createOrUpdateTimeSettings;
    this._beginCreateOrUpdateAlertSettings = _beginCreateOrUpdateAlertSettings;
    this._beginUpdateNetworkSettings = _beginUpdateNetworkSettings;
    this._beginUpdateSecuritySettings = _beginUpdateSecuritySettings;
    this._beginSyncRemotemanagementCertificate = _beginSyncRemotemanagementCertificate;
    this._beginCreateOrUpdateTimeSettings = _beginCreateOrUpdateTimeSettings;
  }

  /**
   * Gets the alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<AlertSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getAlertSettingsWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getAlertSettings(deviceName, resourceGroupName, managerName, 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 alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {AlertSettings} - 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 AlertSettings} 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.
   */
  getAlertSettings(deviceName, resourceGroupName, managerName, 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._getAlertSettings(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getAlertSettings(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates the alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The alert settings to be added or updated.
   *
   * @param {string} parameters.emailNotification Indicates whether email
   * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [parameters.alertNotificationCulture] The alert notification
   * culture.
   *
   * @param {string} [parameters.notificationToServiceOwners] The value
   * indicating whether alert notification enabled for admin or not. Possible
   * values include: 'Enabled', 'Disabled'
   *
   * @param {array} [parameters.additionalRecipientEmailList] The alert
   * notification email list.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<AlertSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateAlertSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates the alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The alert settings to be added or updated.
   *
   * @param {string} parameters.emailNotification Indicates whether email
   * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [parameters.alertNotificationCulture] The alert notification
   * culture.
   *
   * @param {string} [parameters.notificationToServiceOwners] The value
   * indicating whether alert notification enabled for admin or not. Possible
   * values include: 'Enabled', 'Disabled'
   *
   * @param {array} [parameters.additionalRecipientEmailList] The alert
   * notification email list.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {AlertSettings} - 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 AlertSettings} 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.
   */
  createOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, 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._createOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Gets the network settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<NetworkSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getNetworkSettingsWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getNetworkSettings(deviceName, resourceGroupName, managerName, 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 network settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {NetworkSettings} - 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 NetworkSettings} 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.
   */
  getNetworkSettings(deviceName, resourceGroupName, managerName, 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._getNetworkSettings(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getNetworkSettings(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Updates the network settings on the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The network settings to be updated.
   *
   * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
   * settings of device.
   *
   * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
   * DNS server for the device
   *
   * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
   * IPv6 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
   * IPv4 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
   * secondary IPv6 DNS server for the device
   *
   * @param {object} [parameters.networkAdapters] The network adapter list of
   * device.
   *
   * @param {array} parameters.networkAdapters.value The value.
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<NetworkSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateNetworkSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._updateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates the network settings on the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The network settings to be updated.
   *
   * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
   * settings of device.
   *
   * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
   * DNS server for the device
   *
   * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
   * IPv6 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
   * IPv4 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
   * secondary IPv6 DNS server for the device
   *
   * @param {object} [parameters.networkAdapters] The network adapter list of
   * device.
   *
   * @param {array} parameters.networkAdapters.value The value.
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {NetworkSettings} - 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 NetworkSettings} 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.
   */
  updateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, 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._updateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._updateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Returns the Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<SecuritySettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getSecuritySettingsWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getSecuritySettings(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Returns the Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {SecuritySettings} - 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 SecuritySettings} 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.
   */
  getSecuritySettings(deviceName, resourceGroupName, managerName, 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._getSecuritySettings(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getSecuritySettings(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Patch Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The security settings properties to be patched.
   *
   * @param {object} [parameters.remoteManagementSettings] The remote management
   * settings.
   *
   * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
   * remote management mode. Possible values include: 'Unknown', 'Disabled',
   * 'HttpsEnabled', 'HttpsAndHttpEnabled'
   *
   * @param {object} [parameters.deviceAdminPassword] The device administrator
   * password.
   *
   * @param {object} [parameters.snapshotPassword] The snapshot manager password.
   *
   * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
   * settings.
   *
   * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
   * user.
   *
   * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
   * secret.
   *
   * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
   *
   * @param {object} [parameters.chapSettings.targetSecret] The target secret.
   *
   * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
   * settings.
   *
   * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
   * The service data encryption key (encrypted with DAK).
   *
   * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
   * channel integrity key (encrypted with DAK).
   *
   * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
   * The value of the secret.
   *
   * @param {string}
   * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
   * Thumbprint certificate that was used to encrypt "Value". If the value in
   * unencrypted, it will be null.
   *
   * @param {string}
   * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
   * The algorithm used to encrypt "Value". Possible values include: 'None',
   * 'AES256', 'RSAES_PKCS1_v_1_5'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<SecuritySettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  updateSecuritySettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._updateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Patch Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The security settings properties to be patched.
   *
   * @param {object} [parameters.remoteManagementSettings] The remote management
   * settings.
   *
   * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
   * remote management mode. Possible values include: 'Unknown', 'Disabled',
   * 'HttpsEnabled', 'HttpsAndHttpEnabled'
   *
   * @param {object} [parameters.deviceAdminPassword] The device administrator
   * password.
   *
   * @param {object} [parameters.snapshotPassword] The snapshot manager password.
   *
   * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
   * settings.
   *
   * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
   * user.
   *
   * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
   * secret.
   *
   * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
   *
   * @param {object} [parameters.chapSettings.targetSecret] The target secret.
   *
   * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
   * settings.
   *
   * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
   * The service data encryption key (encrypted with DAK).
   *
   * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
   * channel integrity key (encrypted with DAK).
   *
   * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
   * The value of the secret.
   *
   * @param {string}
   * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
   * Thumbprint certificate that was used to encrypt "Value". If the value in
   * unencrypted, it will be null.
   *
   * @param {string}
   * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
   * The algorithm used to encrypt "Value". Possible values include: 'None',
   * 'AES256', 'RSAES_PKCS1_v_1_5'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {SecuritySettings} - 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 SecuritySettings} 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.
   */
  updateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, 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._updateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._updateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * sync Remote management Certificate between appliance and Service
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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.
   */
  syncRemotemanagementCertificateWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._syncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * sync Remote management Certificate between appliance and Service
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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.
   */
  syncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, 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._syncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._syncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Gets the time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<TimeSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getTimeSettingsWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getTimeSettings(deviceName, resourceGroupName, managerName, 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 time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {TimeSettings} - 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 TimeSettings} 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.
   */
  getTimeSettings(deviceName, resourceGroupName, managerName, 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._getTimeSettings(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getTimeSettings(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates the time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The time settings to be added or updated.
   *
   * @param {string} parameters.timeZone The timezone of device, like '(UTC
   * -06:00) Central America'
   *
   * @param {string} [parameters.primaryTimeServer] The primary Network Time
   * Protocol (NTP) server name, like 'time.windows.com'.
   *
   * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
   * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<TimeSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createOrUpdateTimeSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._createOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates the time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The time settings to be added or updated.
   *
   * @param {string} parameters.timeZone The timezone of device, like '(UTC
   * -06:00) Central America'
   *
   * @param {string} [parameters.primaryTimeServer] The primary Network Time
   * Protocol (NTP) server name, like 'time.windows.com'.
   *
   * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
   * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {TimeSettings} - 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 TimeSettings} 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.
   */
  createOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, 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._createOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._createOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates the alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The alert settings to be added or updated.
   *
   * @param {string} parameters.emailNotification Indicates whether email
   * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [parameters.alertNotificationCulture] The alert notification
   * culture.
   *
   * @param {string} [parameters.notificationToServiceOwners] The value
   * indicating whether alert notification enabled for admin or not. Possible
   * values include: 'Enabled', 'Disabled'
   *
   * @param {array} [parameters.additionalRecipientEmailList] The alert
   * notification email list.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<AlertSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateAlertSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates the alert settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The alert settings to be added or updated.
   *
   * @param {string} parameters.emailNotification Indicates whether email
   * notification enabled or not. Possible values include: 'Enabled', 'Disabled'
   *
   * @param {string} [parameters.alertNotificationCulture] The alert notification
   * culture.
   *
   * @param {string} [parameters.notificationToServiceOwners] The value
   * indicating whether alert notification enabled for admin or not. Possible
   * values include: 'Enabled', 'Disabled'
   *
   * @param {array} [parameters.additionalRecipientEmailList] The alert
   * notification email list.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {AlertSettings} - 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 AlertSettings} 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.
   */
  beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, 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._beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdateAlertSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Updates the network settings on the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The network settings to be updated.
   *
   * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
   * settings of device.
   *
   * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
   * DNS server for the device
   *
   * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
   * IPv6 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
   * IPv4 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
   * secondary IPv6 DNS server for the device
   *
   * @param {object} [parameters.networkAdapters] The network adapter list of
   * device.
   *
   * @param {array} parameters.networkAdapters.value The value.
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<NetworkSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateNetworkSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Updates the network settings on the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The network settings to be updated.
   *
   * @param {object} [parameters.dnsSettings] The DNS (Domain Name System)
   * settings of device.
   *
   * @param {string} [parameters.dnsSettings.primaryDnsServer] The primary IPv4
   * DNS server for the device
   *
   * @param {string} [parameters.dnsSettings.primaryIpv6DnsServer] The primary
   * IPv6 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryDnsServers] The secondary
   * IPv4 DNS server for the device
   *
   * @param {array} [parameters.dnsSettings.secondaryIpv6DnsServers] The
   * secondary IPv6 DNS server for the device
   *
   * @param {object} [parameters.networkAdapters] The network adapter list of
   * device.
   *
   * @param {array} parameters.networkAdapters.value The value.
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {NetworkSettings} - 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 NetworkSettings} 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.
   */
  beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, 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._beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdateNetworkSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Patch Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The security settings properties to be patched.
   *
   * @param {object} [parameters.remoteManagementSettings] The remote management
   * settings.
   *
   * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
   * remote management mode. Possible values include: 'Unknown', 'Disabled',
   * 'HttpsEnabled', 'HttpsAndHttpEnabled'
   *
   * @param {object} [parameters.deviceAdminPassword] The device administrator
   * password.
   *
   * @param {object} [parameters.snapshotPassword] The snapshot manager password.
   *
   * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
   * settings.
   *
   * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
   * user.
   *
   * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
   * secret.
   *
   * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
   *
   * @param {object} [parameters.chapSettings.targetSecret] The target secret.
   *
   * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
   * settings.
   *
   * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
   * The service data encryption key (encrypted with DAK).
   *
   * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
   * channel integrity key (encrypted with DAK).
   *
   * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
   * The value of the secret.
   *
   * @param {string}
   * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
   * Thumbprint certificate that was used to encrypt "Value". If the value in
   * unencrypted, it will be null.
   *
   * @param {string}
   * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
   * The algorithm used to encrypt "Value". Possible values include: 'None',
   * 'AES256', 'RSAES_PKCS1_v_1_5'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<SecuritySettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginUpdateSecuritySettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Patch Security properties of the specified device name.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The security settings properties to be patched.
   *
   * @param {object} [parameters.remoteManagementSettings] The remote management
   * settings.
   *
   * @param {string} parameters.remoteManagementSettings.remoteManagementMode The
   * remote management mode. Possible values include: 'Unknown', 'Disabled',
   * 'HttpsEnabled', 'HttpsAndHttpEnabled'
   *
   * @param {object} [parameters.deviceAdminPassword] The device administrator
   * password.
   *
   * @param {object} [parameters.snapshotPassword] The snapshot manager password.
   *
   * @param {object} [parameters.chapSettings] The device CHAP and reverse-CHAP
   * settings.
   *
   * @param {string} [parameters.chapSettings.initiatorUser] The CHAP initiator
   * user.
   *
   * @param {object} [parameters.chapSettings.initiatorSecret] The CHAP initiator
   * secret.
   *
   * @param {string} [parameters.chapSettings.targetUser] The CHAP target user.
   *
   * @param {object} [parameters.chapSettings.targetSecret] The target secret.
   *
   * @param {object} [parameters.cloudApplianceSettings] The cloud appliance
   * settings.
   *
   * @param {object} [parameters.cloudApplianceSettings.serviceDataEncryptionKey]
   * The service data encryption key (encrypted with DAK).
   *
   * @param {object} [parameters.cloudApplianceSettings.channelIntegrityKey] The
   * channel integrity key (encrypted with DAK).
   *
   * @param {string} parameters.cloudApplianceSettings.channelIntegrityKey.value
   * The value of the secret.
   *
   * @param {string}
   * [parameters.cloudApplianceSettings.channelIntegrityKey.encryptionCertThumbprint]
   * Thumbprint certificate that was used to encrypt "Value". If the value in
   * unencrypted, it will be null.
   *
   * @param {string}
   * parameters.cloudApplianceSettings.channelIntegrityKey.encryptionAlgorithm
   * The algorithm used to encrypt "Value". Possible values include: 'None',
   * 'AES256', 'RSAES_PKCS1_v_1_5'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {SecuritySettings} - 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 SecuritySettings} 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.
   */
  beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, 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._beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginUpdateSecuritySettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * sync Remote management Certificate between appliance and Service
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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.
   */
  beginSyncRemotemanagementCertificateWithHttpOperationResponse(deviceName, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * sync Remote management Certificate between appliance and Service
   *
   * @param {string} deviceName The device name
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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.
   */
  beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, 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._beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginSyncRemotemanagementCertificate(deviceName, resourceGroupName, managerName, options, optionalCallback);
    }
  }

  /**
   * Creates or updates the time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The time settings to be added or updated.
   *
   * @param {string} parameters.timeZone The timezone of device, like '(UTC
   * -06:00) Central America'
   *
   * @param {string} [parameters.primaryTimeServer] The primary Network Time
   * Protocol (NTP) server name, like 'time.windows.com'.
   *
   * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
   * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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<TimeSettings>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  beginCreateOrUpdateTimeSettingsWithHttpOperationResponse(deviceName, parameters, resourceGroupName, managerName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Creates or updates the time settings of the specified device.
   *
   * @param {string} deviceName The device name
   *
   * @param {object} parameters The time settings to be added or updated.
   *
   * @param {string} parameters.timeZone The timezone of device, like '(UTC
   * -06:00) Central America'
   *
   * @param {string} [parameters.primaryTimeServer] The primary Network Time
   * Protocol (NTP) server name, like 'time.windows.com'.
   *
   * @param {array} [parameters.secondaryTimeServer] The secondary Network Time
   * Protocol (NTP) server name, like 'time.contoso.com'. It's optional.
   *
   * @param {string} [parameters.kind] The Kind of the object. Currently only
   * Series8000 is supported. Possible values include: 'Series8000'
   *
   * @param {string} resourceGroupName The resource group name
   *
   * @param {string} managerName The manager name
   *
   * @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 {TimeSettings} - 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 TimeSettings} 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.
   */
  beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, 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._beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._beginCreateOrUpdateTimeSettings(deviceName, parameters, resourceGroupName, managerName, options, optionalCallback);
    }
  }

}

module.exports = DeviceSettings;
