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

/**
 * Create a new software update configuration with the name given in the URI.
 *
 * @param {string} resourceGroupName Name of an Azure Resource group.
 *
 * @param {string} automationAccountName The name of the automation account.
 *
 * @param {string} softwareUpdateConfigurationName The name of the software
 * update configuration to be created.
 *
 * @param {object} parameters Request body.
 *
 * @param {object} parameters.updateConfiguration update specific properties
 * for the Software update configuration
 *
 * @param {string} parameters.updateConfiguration.operatingSystem operating
 * system of target machines. Possible values include: 'Windows', 'Linux'
 *
 * @param {object} [parameters.updateConfiguration.windows] Windows specific
 * update configuration.
 *
 * @param {string}
 * [parameters.updateConfiguration.windows.includedUpdateClassifications]
 * Update classification included in the software update configuration. A comma
 * separated string with required values. Possible values include:
 * 'Unclassified', 'Critical', 'Security', 'UpdateRollup', 'FeaturePack',
 * 'ServicePack', 'Definition', 'Tools', 'Updates'
 *
 * @param {array} [parameters.updateConfiguration.windows.excludedKbNumbers] KB
 * numbers excluded from the software update configuration.
 *
 * @param {array} [parameters.updateConfiguration.windows.includedKbNumbers] KB
 * numbers included from the software update configuration.
 *
 * @param {string} [parameters.updateConfiguration.windows.rebootSetting]
 * Reboot setting for the software update configuration.
 *
 * @param {object} [parameters.updateConfiguration.linux] Linux specific update
 * configuration.
 *
 * @param {string}
 * [parameters.updateConfiguration.linux.includedPackageClassifications] Update
 * classifications included in the software update configuration. Possible
 * values include: 'Unclassified', 'Critical', 'Security', 'Other'
 *
 * @param {array}
 * [parameters.updateConfiguration.linux.excludedPackageNameMasks] packages
 * excluded from the software update configuration.
 *
 * @param {array}
 * [parameters.updateConfiguration.linux.includedPackageNameMasks] packages
 * included from the software update configuration.
 *
 * @param {string} [parameters.updateConfiguration.linux.rebootSetting] Reboot
 * setting for the software update configuration.
 *
 * @param {moment.duration} [parameters.updateConfiguration.duration] Maximum
 * time allowed for the software update configuration run. Duration needs to be
 * specified using the format PT[n]H[n]M[n]S as per ISO8601
 *
 * @param {array} [parameters.updateConfiguration.azureVirtualMachines] List of
 * azure resource Ids for azure virtual machines targeted by the software
 * update configuration.
 *
 * @param {array} [parameters.updateConfiguration.nonAzureComputerNames] List
 * of names of non-azure machines targeted by the software update
 * configuration.
 *
 * @param {object} [parameters.updateConfiguration.targets] Group targets for
 * the software update configuration.
 *
 * @param {array} [parameters.updateConfiguration.targets.azureQueries] List of
 * Azure queries in the software update configuration.
 *
 * @param {object} parameters.scheduleInfo Schedule information for the
 * Software update configuration
 *
 * @param {date} [parameters.scheduleInfo.startTime] Gets or sets the start
 * time of the schedule.
 *
 * @param {date} [parameters.scheduleInfo.expiryTime] Gets or sets the end time
 * of the schedule.
 *
 * @param {number} [parameters.scheduleInfo.expiryTimeOffsetMinutes] Gets or
 * sets the expiry time's offset in minutes.
 *
 * @param {boolean} [parameters.scheduleInfo.isEnabled] Gets or sets a value
 * indicating whether this schedule is enabled.
 *
 * @param {date} [parameters.scheduleInfo.nextRun] Gets or sets the next run
 * time of the schedule.
 *
 * @param {number} [parameters.scheduleInfo.nextRunOffsetMinutes] Gets or sets
 * the next run time's offset in minutes.
 *
 * @param {number} [parameters.scheduleInfo.interval] Gets or sets the interval
 * of the schedule.
 *
 * @param {string} [parameters.scheduleInfo.frequency] Gets or sets the
 * frequency of the schedule. Possible values include: 'OneTime', 'Day',
 * 'Hour', 'Week', 'Month'
 *
 * @param {string} [parameters.scheduleInfo.timeZone] Gets or sets the time
 * zone of the schedule.
 *
 * @param {object} [parameters.scheduleInfo.advancedSchedule] Gets or sets the
 * advanced schedule.
 *
 * @param {array} [parameters.scheduleInfo.advancedSchedule.weekDays] Days of
 * the week that the job should execute on.
 *
 * @param {array} [parameters.scheduleInfo.advancedSchedule.monthDays] Days of
 * the month that the job should execute on. Must be between 1 and 31.
 *
 * @param {array} [parameters.scheduleInfo.advancedSchedule.monthlyOccurrences]
 * Occurrences of days within a month.
 *
 * @param {date} [parameters.scheduleInfo.creationTime] Gets or sets the
 * creation time.
 *
 * @param {date} [parameters.scheduleInfo.lastModifiedTime] Gets or sets the
 * last modified time.
 *
 * @param {string} [parameters.scheduleInfo.description] Gets or sets the
 * description.
 *
 * @param {object} [parameters.error] Details of provisioning error
 *
 * @param {string} [parameters.error.code] Error code
 *
 * @param {string} [parameters.error.message] Error message indicating why the
 * operation failed.
 *
 * @param {object} [parameters.tasks] Tasks information for the Software update
 * configuration.
 *
 * @param {object} [parameters.tasks.preTask] Pre task properties.
 *
 * @param {object} [parameters.tasks.postTask] Post task properties.
 *
 * @param {object} [parameters.tasks.postTask.parameters] Gets or sets the
 * parameters of the task.
 *
 * @param {string} [parameters.tasks.postTask.source] Gets or sets the name of
 * the runbook.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.clientRequestId] Identifies this specific client
 * request.
 *
 * @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 SoftwareUpdateConfiguration} for more
 *                      information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _create(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined;
  let apiVersion = '2017-05-15-preview';
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
      throw new Error('automationAccountName cannot be null or undefined and it must be of type string.');
    }
    if (softwareUpdateConfigurationName === null || softwareUpdateConfigurationName === undefined || typeof softwareUpdateConfigurationName.valueOf() !== 'string') {
      throw new Error('softwareUpdateConfigurationName cannot be null or undefined and it must be of type string.');
    }
    if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') {
      throw new Error('clientRequestId must be of type string.');
    }
    if (parameters === null || parameters === undefined) {
      throw new Error('parameters cannot be null or undefined.');
    }
    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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
  requestUrl = requestUrl.replace('{softwareUpdateConfigurationName}', encodeURIComponent(softwareUpdateConfigurationName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(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 (clientRequestId !== undefined && clientRequestId !== null) {
    httpRequest.headers['clientRequestId'] = clientRequestId;
  }
  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['SoftwareUpdateConfiguration']().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 !== 201) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['SoftwareUpdateConfiguration']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError.request = msRest.stripRequest(httpRequest);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
    }
    // Deserialize Response
    if (statusCode === 201) {
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined) {
          let resultMapper = new client.models['SoftwareUpdateConfiguration']().mapper();
          result = client.deserialize(resultMapper, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
        deserializationError1.request = msRest.stripRequest(httpRequest);
        deserializationError1.response = msRest.stripResponse(response);
        return callback(deserializationError1);
      }
    }

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

/**
 * Get a single software update configuration by name.
 *
 * @param {string} resourceGroupName Name of an Azure Resource group.
 *
 * @param {string} automationAccountName The name of the automation account.
 *
 * @param {string} softwareUpdateConfigurationName The name of the software
 * update configuration to be created.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.clientRequestId] Identifies this specific client
 * request.
 *
 * @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 SoftwareUpdateConfiguration} 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 _getByName(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined;
  let apiVersion = '2017-05-15-preview';
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
      throw new Error('automationAccountName cannot be null or undefined and it must be of type string.');
    }
    if (softwareUpdateConfigurationName === null || softwareUpdateConfigurationName === undefined || typeof softwareUpdateConfigurationName.valueOf() !== 'string') {
      throw new Error('softwareUpdateConfigurationName cannot be null or undefined and it must be of type string.');
    }
    if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') {
      throw new Error('clientRequestId 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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
  requestUrl = requestUrl.replace('{softwareUpdateConfigurationName}', encodeURIComponent(softwareUpdateConfigurationName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(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 (clientRequestId !== undefined && clientRequestId !== null) {
    httpRequest.headers['clientRequestId'] = clientRequestId;
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['SoftwareUpdateConfiguration']().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);
  });
}

/**
 * delete a specific software update configuration.
 *
 * @param {string} resourceGroupName Name of an Azure Resource group.
 *
 * @param {string} automationAccountName The name of the automation account.
 *
 * @param {string} softwareUpdateConfigurationName The name of the software
 * update configuration to be created.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.clientRequestId] Identifies this specific client
 * request.
 *
 * @param {object} [options.customHeaders] Headers that will be added to the
 * request
 *
 * @param {function} callback - The callback.
 *
 * @returns {function} callback(err, result, request, response)
 *
 *                      {Error}  err        - The Error object if an error occurred, null otherwise.
 *
 *                      {null} [result]   - The deserialized result object if an error did not occur.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _deleteMethod(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined;
  let apiVersion = '2017-05-15-preview';
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
      throw new Error('automationAccountName cannot be null or undefined and it must be of type string.');
    }
    if (softwareUpdateConfigurationName === null || softwareUpdateConfigurationName === undefined || typeof softwareUpdateConfigurationName.valueOf() !== 'string') {
      throw new Error('softwareUpdateConfigurationName cannot be null or undefined and it must be of type string.');
    }
    if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') {
      throw new Error('clientRequestId 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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations/{softwareUpdateConfigurationName}';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
  requestUrl = requestUrl.replace('{softwareUpdateConfigurationName}', encodeURIComponent(softwareUpdateConfigurationName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (queryParameters.length > 0) {
    requestUrl += '?' + queryParameters.join('&');
  }

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

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

/**
 * Get all software update configurations for the account.
 *
 * @param {string} resourceGroupName Name of an Azure Resource group.
 *
 * @param {string} automationAccountName The name of the automation account.
 *
 * @param {object} [options] Optional Parameters.
 *
 * @param {string} [options.clientRequestId] Identifies this specific client
 * request.
 *
 * @param {string} [options.filter] The filter to apply on the operation.
 *
 * @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 SoftwareUpdateConfigurationListResult} for
 *                      more information.
 *
 *                      {object} [request]  - The HTTP Request object if an error did not occur.
 *
 *                      {stream} [response] - The HTTP Response stream if an error did not occur.
 */
function _list(resourceGroupName, automationAccountName, options, callback) {
   /* jshint validthis: true */
  let client = this.client;
  if(!callback && typeof options === 'function') {
    callback = options;
    options = null;
  }
  if (!callback) {
    throw new Error('callback cannot be null.');
  }
  let clientRequestId = (options && options.clientRequestId !== undefined) ? options.clientRequestId : undefined;
  let filter = (options && options.filter !== undefined) ? options.filter : undefined;
  let apiVersion = '2017-05-15-preview';
  // Validate
  try {
    if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
      throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
      throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
    }
    if (resourceGroupName !== null && resourceGroupName !== undefined) {
      if (resourceGroupName.length > 90)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MaxLength": 90');
      }
      if (resourceGroupName.length < 1)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "MinLength": 1');
      }
      if (resourceGroupName.match(/^[-\w\._]+$/) === null)
      {
        throw new Error('"resourceGroupName" should satisfy the constraint - "Pattern": /^[-\w\._]+$/');
      }
    }
    if (automationAccountName === null || automationAccountName === undefined || typeof automationAccountName.valueOf() !== 'string') {
      throw new Error('automationAccountName cannot be null or undefined and it must be of type string.');
    }
    if (clientRequestId !== null && clientRequestId !== undefined && typeof clientRequestId.valueOf() !== 'string') {
      throw new Error('clientRequestId must be of type string.');
    }
    if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') {
      throw new Error('filter 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.Automation/automationAccounts/{automationAccountName}/softwareUpdateConfigurations';
  requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
  requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
  requestUrl = requestUrl.replace('{automationAccountName}', encodeURIComponent(automationAccountName));
  let queryParameters = [];
  queryParameters.push('api-version=' + encodeURIComponent(apiVersion));
  if (filter !== null && filter !== undefined) {
    queryParameters.push('$filter=' + encodeURIComponent(filter));
  }
  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 (clientRequestId !== undefined && clientRequestId !== null) {
    httpRequest.headers['clientRequestId'] = clientRequestId;
  }
  if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
    httpRequest.headers['accept-language'] = this.client.acceptLanguage;
  }
  if(options) {
    for(let headerName in options['customHeaders']) {
      if (options['customHeaders'].hasOwnProperty(headerName)) {
        httpRequest.headers[headerName] = options['customHeaders'][headerName];
      }
    }
  }
  httpRequest.body = null;
  // Send Request
  return client.pipeline(httpRequest, (err, response, responseBody) => {
    if (err) {
      return callback(err);
    }
    let statusCode = response.statusCode;
    if (statusCode !== 200) {
      let error = new Error(responseBody);
      error.statusCode = response.statusCode;
      error.request = msRest.stripRequest(httpRequest);
      error.response = msRest.stripResponse(response);
      if (responseBody === '') responseBody = null;
      let parsedErrorResponse;
      try {
        parsedErrorResponse = JSON.parse(responseBody);
        if (parsedErrorResponse) {
          let internalError = null;
          if (parsedErrorResponse.error) internalError = parsedErrorResponse.error;
          error.code = internalError ? internalError.code : parsedErrorResponse.code;
          error.message = internalError ? internalError.message : parsedErrorResponse.message;
        }
        if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
          let resultMapper = new client.models['ErrorResponse']().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['SoftwareUpdateConfigurationListResult']().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 SoftwareUpdateConfigurations. */
class SoftwareUpdateConfigurations {
  /**
   * Create a SoftwareUpdateConfigurations.
   * @param {AutomationClient} client Reference to the service client.
   */
  constructor(client) {
    this.client = client;
    this._create = _create;
    this._getByName = _getByName;
    this._deleteMethod = _deleteMethod;
    this._list = _list;
  }

  /**
   * Create a new software update configuration with the name given in the URI.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} parameters Request body.
   *
   * @param {object} parameters.updateConfiguration update specific properties
   * for the Software update configuration
   *
   * @param {string} parameters.updateConfiguration.operatingSystem operating
   * system of target machines. Possible values include: 'Windows', 'Linux'
   *
   * @param {object} [parameters.updateConfiguration.windows] Windows specific
   * update configuration.
   *
   * @param {string}
   * [parameters.updateConfiguration.windows.includedUpdateClassifications]
   * Update classification included in the software update configuration. A comma
   * separated string with required values. Possible values include:
   * 'Unclassified', 'Critical', 'Security', 'UpdateRollup', 'FeaturePack',
   * 'ServicePack', 'Definition', 'Tools', 'Updates'
   *
   * @param {array} [parameters.updateConfiguration.windows.excludedKbNumbers] KB
   * numbers excluded from the software update configuration.
   *
   * @param {array} [parameters.updateConfiguration.windows.includedKbNumbers] KB
   * numbers included from the software update configuration.
   *
   * @param {string} [parameters.updateConfiguration.windows.rebootSetting]
   * Reboot setting for the software update configuration.
   *
   * @param {object} [parameters.updateConfiguration.linux] Linux specific update
   * configuration.
   *
   * @param {string}
   * [parameters.updateConfiguration.linux.includedPackageClassifications] Update
   * classifications included in the software update configuration. Possible
   * values include: 'Unclassified', 'Critical', 'Security', 'Other'
   *
   * @param {array}
   * [parameters.updateConfiguration.linux.excludedPackageNameMasks] packages
   * excluded from the software update configuration.
   *
   * @param {array}
   * [parameters.updateConfiguration.linux.includedPackageNameMasks] packages
   * included from the software update configuration.
   *
   * @param {string} [parameters.updateConfiguration.linux.rebootSetting] Reboot
   * setting for the software update configuration.
   *
   * @param {moment.duration} [parameters.updateConfiguration.duration] Maximum
   * time allowed for the software update configuration run. Duration needs to be
   * specified using the format PT[n]H[n]M[n]S as per ISO8601
   *
   * @param {array} [parameters.updateConfiguration.azureVirtualMachines] List of
   * azure resource Ids for azure virtual machines targeted by the software
   * update configuration.
   *
   * @param {array} [parameters.updateConfiguration.nonAzureComputerNames] List
   * of names of non-azure machines targeted by the software update
   * configuration.
   *
   * @param {object} [parameters.updateConfiguration.targets] Group targets for
   * the software update configuration.
   *
   * @param {array} [parameters.updateConfiguration.targets.azureQueries] List of
   * Azure queries in the software update configuration.
   *
   * @param {object} parameters.scheduleInfo Schedule information for the
   * Software update configuration
   *
   * @param {date} [parameters.scheduleInfo.startTime] Gets or sets the start
   * time of the schedule.
   *
   * @param {date} [parameters.scheduleInfo.expiryTime] Gets or sets the end time
   * of the schedule.
   *
   * @param {number} [parameters.scheduleInfo.expiryTimeOffsetMinutes] Gets or
   * sets the expiry time's offset in minutes.
   *
   * @param {boolean} [parameters.scheduleInfo.isEnabled] Gets or sets a value
   * indicating whether this schedule is enabled.
   *
   * @param {date} [parameters.scheduleInfo.nextRun] Gets or sets the next run
   * time of the schedule.
   *
   * @param {number} [parameters.scheduleInfo.nextRunOffsetMinutes] Gets or sets
   * the next run time's offset in minutes.
   *
   * @param {number} [parameters.scheduleInfo.interval] Gets or sets the interval
   * of the schedule.
   *
   * @param {string} [parameters.scheduleInfo.frequency] Gets or sets the
   * frequency of the schedule. Possible values include: 'OneTime', 'Day',
   * 'Hour', 'Week', 'Month'
   *
   * @param {string} [parameters.scheduleInfo.timeZone] Gets or sets the time
   * zone of the schedule.
   *
   * @param {object} [parameters.scheduleInfo.advancedSchedule] Gets or sets the
   * advanced schedule.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.weekDays] Days of
   * the week that the job should execute on.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.monthDays] Days of
   * the month that the job should execute on. Must be between 1 and 31.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.monthlyOccurrences]
   * Occurrences of days within a month.
   *
   * @param {date} [parameters.scheduleInfo.creationTime] Gets or sets the
   * creation time.
   *
   * @param {date} [parameters.scheduleInfo.lastModifiedTime] Gets or sets the
   * last modified time.
   *
   * @param {string} [parameters.scheduleInfo.description] Gets or sets the
   * description.
   *
   * @param {object} [parameters.error] Details of provisioning error
   *
   * @param {string} [parameters.error.code] Error code
   *
   * @param {string} [parameters.error.message] Error message indicating why the
   * operation failed.
   *
   * @param {object} [parameters.tasks] Tasks information for the Software update
   * configuration.
   *
   * @param {object} [parameters.tasks.preTask] Pre task properties.
   *
   * @param {object} [parameters.tasks.postTask] Post task properties.
   *
   * @param {object} [parameters.tasks.postTask.parameters] Gets or sets the
   * parameters of the task.
   *
   * @param {string} [parameters.tasks.postTask.source] Gets or sets the name of
   * the runbook.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<SoftwareUpdateConfiguration>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  createWithHttpOperationResponse(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._create(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Create a new software update configuration with the name given in the URI.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} parameters Request body.
   *
   * @param {object} parameters.updateConfiguration update specific properties
   * for the Software update configuration
   *
   * @param {string} parameters.updateConfiguration.operatingSystem operating
   * system of target machines. Possible values include: 'Windows', 'Linux'
   *
   * @param {object} [parameters.updateConfiguration.windows] Windows specific
   * update configuration.
   *
   * @param {string}
   * [parameters.updateConfiguration.windows.includedUpdateClassifications]
   * Update classification included in the software update configuration. A comma
   * separated string with required values. Possible values include:
   * 'Unclassified', 'Critical', 'Security', 'UpdateRollup', 'FeaturePack',
   * 'ServicePack', 'Definition', 'Tools', 'Updates'
   *
   * @param {array} [parameters.updateConfiguration.windows.excludedKbNumbers] KB
   * numbers excluded from the software update configuration.
   *
   * @param {array} [parameters.updateConfiguration.windows.includedKbNumbers] KB
   * numbers included from the software update configuration.
   *
   * @param {string} [parameters.updateConfiguration.windows.rebootSetting]
   * Reboot setting for the software update configuration.
   *
   * @param {object} [parameters.updateConfiguration.linux] Linux specific update
   * configuration.
   *
   * @param {string}
   * [parameters.updateConfiguration.linux.includedPackageClassifications] Update
   * classifications included in the software update configuration. Possible
   * values include: 'Unclassified', 'Critical', 'Security', 'Other'
   *
   * @param {array}
   * [parameters.updateConfiguration.linux.excludedPackageNameMasks] packages
   * excluded from the software update configuration.
   *
   * @param {array}
   * [parameters.updateConfiguration.linux.includedPackageNameMasks] packages
   * included from the software update configuration.
   *
   * @param {string} [parameters.updateConfiguration.linux.rebootSetting] Reboot
   * setting for the software update configuration.
   *
   * @param {moment.duration} [parameters.updateConfiguration.duration] Maximum
   * time allowed for the software update configuration run. Duration needs to be
   * specified using the format PT[n]H[n]M[n]S as per ISO8601
   *
   * @param {array} [parameters.updateConfiguration.azureVirtualMachines] List of
   * azure resource Ids for azure virtual machines targeted by the software
   * update configuration.
   *
   * @param {array} [parameters.updateConfiguration.nonAzureComputerNames] List
   * of names of non-azure machines targeted by the software update
   * configuration.
   *
   * @param {object} [parameters.updateConfiguration.targets] Group targets for
   * the software update configuration.
   *
   * @param {array} [parameters.updateConfiguration.targets.azureQueries] List of
   * Azure queries in the software update configuration.
   *
   * @param {object} parameters.scheduleInfo Schedule information for the
   * Software update configuration
   *
   * @param {date} [parameters.scheduleInfo.startTime] Gets or sets the start
   * time of the schedule.
   *
   * @param {date} [parameters.scheduleInfo.expiryTime] Gets or sets the end time
   * of the schedule.
   *
   * @param {number} [parameters.scheduleInfo.expiryTimeOffsetMinutes] Gets or
   * sets the expiry time's offset in minutes.
   *
   * @param {boolean} [parameters.scheduleInfo.isEnabled] Gets or sets a value
   * indicating whether this schedule is enabled.
   *
   * @param {date} [parameters.scheduleInfo.nextRun] Gets or sets the next run
   * time of the schedule.
   *
   * @param {number} [parameters.scheduleInfo.nextRunOffsetMinutes] Gets or sets
   * the next run time's offset in minutes.
   *
   * @param {number} [parameters.scheduleInfo.interval] Gets or sets the interval
   * of the schedule.
   *
   * @param {string} [parameters.scheduleInfo.frequency] Gets or sets the
   * frequency of the schedule. Possible values include: 'OneTime', 'Day',
   * 'Hour', 'Week', 'Month'
   *
   * @param {string} [parameters.scheduleInfo.timeZone] Gets or sets the time
   * zone of the schedule.
   *
   * @param {object} [parameters.scheduleInfo.advancedSchedule] Gets or sets the
   * advanced schedule.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.weekDays] Days of
   * the week that the job should execute on.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.monthDays] Days of
   * the month that the job should execute on. Must be between 1 and 31.
   *
   * @param {array} [parameters.scheduleInfo.advancedSchedule.monthlyOccurrences]
   * Occurrences of days within a month.
   *
   * @param {date} [parameters.scheduleInfo.creationTime] Gets or sets the
   * creation time.
   *
   * @param {date} [parameters.scheduleInfo.lastModifiedTime] Gets or sets the
   * last modified time.
   *
   * @param {string} [parameters.scheduleInfo.description] Gets or sets the
   * description.
   *
   * @param {object} [parameters.error] Details of provisioning error
   *
   * @param {string} [parameters.error.code] Error code
   *
   * @param {string} [parameters.error.message] Error message indicating why the
   * operation failed.
   *
   * @param {object} [parameters.tasks] Tasks information for the Software update
   * configuration.
   *
   * @param {object} [parameters.tasks.preTask] Pre task properties.
   *
   * @param {object} [parameters.tasks.postTask] Post task properties.
   *
   * @param {object} [parameters.tasks.postTask.parameters] Gets or sets the
   * parameters of the task.
   *
   * @param {string} [parameters.tasks.postTask.source] Gets or sets the name of
   * the runbook.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @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 {SoftwareUpdateConfiguration} - 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 SoftwareUpdateConfiguration} for more
   *                      information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  create(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._create(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._create(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, parameters, options, optionalCallback);
    }
  }

  /**
   * Get a single software update configuration by name.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<SoftwareUpdateConfiguration>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  getByNameWithHttpOperationResponse(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._getByName(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get a single software update configuration by name.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @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 {SoftwareUpdateConfiguration} - 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 SoftwareUpdateConfiguration} 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.
   */
  getByName(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, 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._getByName(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._getByName(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, optionalCallback);
    }
  }

  /**
   * delete a specific software update configuration.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<null>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  deleteMethodWithHttpOperationResponse(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._deleteMethod(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * delete a specific software update configuration.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {string} softwareUpdateConfigurationName The name of the software
   * update configuration to be created.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @param {function} [optionalCallback] - The optional callback.
   *
   * @returns {function|Promise} If a callback was passed as the last parameter
   * then it returns the callback else returns a Promise.
   *
   * {Promise} A promise is returned
   *
   *                      @resolve {null} - The deserialized result object.
   *
   *                      @reject {Error} - The error object.
   *
   * {function} optionalCallback(err, result, request, response)
   *
   *                      {Error}  err        - The Error object if an error occurred, null otherwise.
   *
   *                      {null} [result]   - The deserialized result object if an error did not occur.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  deleteMethod(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._deleteMethod(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._deleteMethod(resourceGroupName, automationAccountName, softwareUpdateConfigurationName, options, optionalCallback);
    }
  }

  /**
   * Get all software update configurations for the account.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {string} [options.filter] The filter to apply on the operation.
   *
   * @param {object} [options.customHeaders] Headers that will be added to the
   * request
   *
   * @returns {Promise} A promise is returned
   *
   * @resolve {HttpOperationResponse<SoftwareUpdateConfigurationListResult>} - The deserialized result object.
   *
   * @reject {Error} - The error object.
   */
  listWithHttpOperationResponse(resourceGroupName, automationAccountName, options) {
    let client = this.client;
    let self = this;
    return new Promise((resolve, reject) => {
      self._list(resourceGroupName, automationAccountName, options, (err, result, request, response) => {
        let httpOperationResponse = new msRest.HttpOperationResponse(request, response);
        httpOperationResponse.body = result;
        if (err) { reject(err); }
        else { resolve(httpOperationResponse); }
        return;
      });
    });
  }

  /**
   * Get all software update configurations for the account.
   *
   * @param {string} resourceGroupName Name of an Azure Resource group.
   *
   * @param {string} automationAccountName The name of the automation account.
   *
   * @param {object} [options] Optional Parameters.
   *
   * @param {string} [options.clientRequestId] Identifies this specific client
   * request.
   *
   * @param {string} [options.filter] The filter to apply on the operation.
   *
   * @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 {SoftwareUpdateConfigurationListResult} - 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 SoftwareUpdateConfigurationListResult} for
   *                      more information.
   *
   *                      {object} [request]  - The HTTP Request object if an error did not occur.
   *
   *                      {stream} [response] - The HTTP Response stream if an error did not occur.
   */
  list(resourceGroupName, automationAccountName, options, optionalCallback) {
    let client = this.client;
    let self = this;
    if (!optionalCallback && typeof options === 'function') {
      optionalCallback = options;
      options = null;
    }
    if (!optionalCallback) {
      return new Promise((resolve, reject) => {
        self._list(resourceGroupName, automationAccountName, options, (err, result, request, response) => {
          if (err) { reject(err); }
          else { resolve(result); }
          return;
        });
      });
    } else {
      return self._list(resourceGroupName, automationAccountName, options, optionalCallback);
    }
  }

}

module.exports = SoftwareUpdateConfigurations;
