azure-arm-scheduler
Version:
Microsoft Azure Scheduler Management Client Library for node
1,200 lines (1,181 loc) • 151 kB
JavaScript
/*
* 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 a job.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} jobCollectionName The job collection name.
*
* @param {string} jobName The job 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 JobDefinition} for more information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _get(resourceGroupName, jobCollectionName, jobName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Validate
try {
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (jobCollectionName === null || jobCollectionName === undefined || typeof jobCollectionName.valueOf() !== 'string') {
throw new Error('jobCollectionName cannot be null or undefined and it must be of type string.');
}
if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
throw new Error('jobName cannot be null or undefined and it must be of type string.');
}
if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
}
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}
// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}';
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{jobCollectionName}', encodeURIComponent(jobCollectionName));
requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'GET';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
httpRequest.body = null;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
parsedErrorResponse = JSON.parse(responseBody);
if (parsedErrorResponse) {
if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
}
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
let resultMapper = new client.models['CloudError']().mapper();
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
}
// Create Result
let result = null;
if (responseBody === '') responseBody = null;
// Deserialize Response
if (statusCode === 200) {
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['JobDefinition']().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);
});
}
/**
* Provisions a new job or updates an existing job.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} jobCollectionName The job collection name.
*
* @param {string} jobName The job name.
*
* @param {object} job The job definition.
*
* @param {object} [job.properties] Gets or sets the job properties.
*
* @param {date} [job.properties.startTime] Gets or sets the job start time.
*
* @param {object} [job.properties.action] Gets or sets the job action.
*
* @param {string} [job.properties.action.type] Gets or sets the job action
* type. Possible values include: 'Http', 'Https', 'StorageQueue',
* 'ServiceBusQueue', 'ServiceBusTopic'
*
* @param {object} [job.properties.action.request] Gets or sets the http
* requests.
*
* @param {object} [job.properties.action.queueMessage] Gets or sets the
* storage queue message.
*
* @param {object} [job.properties.action.serviceBusQueueMessage] Gets or sets
* the service bus queue message.
*
* @param {object} [job.properties.action.serviceBusTopicMessage] Gets or sets
* the service bus topic message.
*
* @param {object} [job.properties.action.retryPolicy] Gets or sets the retry
* policy.
*
* @param {object} [job.properties.action.errorAction] Gets or sets the error
* action.
*
* @param {string} [job.properties.action.errorAction.type] Gets or sets the
* job error action type. Possible values include: 'Http', 'Https',
* 'StorageQueue', 'ServiceBusQueue', 'ServiceBusTopic'
*
* @param {object} [job.properties.action.errorAction.request] Gets or sets the
* http requests.
*
* @param {object} [job.properties.action.errorAction.request.authentication]
* Gets or sets the authentication method of the request.
*
* @param {string}
* job.properties.action.errorAction.request.authentication.type Polymorphic
* Discriminator
*
* @param {string} [job.properties.action.errorAction.request.uri] Gets or sets
* the URI of the request.
*
* @param {string} [job.properties.action.errorAction.request.method] Gets or
* sets the method of the request.
*
* @param {string} [job.properties.action.errorAction.request.body] Gets or
* sets the request body.
*
* @param {object} [job.properties.action.errorAction.request.headers] Gets or
* sets the headers.
*
* @param {object} [job.properties.action.errorAction.queueMessage] Gets or
* sets the storage queue message.
*
* @param {string}
* [job.properties.action.errorAction.queueMessage.storageAccount] Gets or sets
* the storage account name.
*
* @param {string} [job.properties.action.errorAction.queueMessage.queueName]
* Gets or sets the queue name.
*
* @param {string} [job.properties.action.errorAction.queueMessage.sasToken]
* Gets or sets the SAS key.
*
* @param {string} [job.properties.action.errorAction.queueMessage.message]
* Gets or sets the message.
*
* @param {object} [job.properties.action.errorAction.serviceBusQueueMessage]
* Gets or sets the service bus queue message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.queueName] Gets or
* sets the queue name.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.authentication]
* Gets or sets the Service Bus authentication.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.brokeredMessageProperties]
* Gets or sets the brokered message properties.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.customMessageProperties]
* Gets or sets the custom message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.message] Gets or
* sets the message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.namespace] Gets or
* sets the namespace.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.transportType]
* Gets or sets the transport type. Possible values include: 'NotSpecified',
* 'NetMessaging', 'AMQP'
*
* @param {object} [job.properties.action.errorAction.serviceBusTopicMessage]
* Gets or sets the service bus topic message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.topicPath] Gets or
* sets the topic path.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication]
* Gets or sets the Service Bus authentication.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.sasKey]
* Gets or sets the SAS key.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.sasKeyName]
* Gets or sets the SAS key name.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.type]
* Gets or sets the authentication type. Possible values include:
* 'NotSpecified', 'SharedAccessKey'
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties]
* Gets or sets the brokered message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.contentType]
* Gets or sets the content type.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.correlationId]
* Gets or sets the correlation ID.
*
* @param {boolean}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.forcePersistence]
* Gets or sets the force persistence.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.label]
* Gets or sets the label.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.messageId]
* Gets or sets the message ID.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.partitionKey]
* Gets or sets the partition key.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.replyTo]
* Gets or sets the reply to.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.replyToSessionId]
* Gets or sets the reply to session ID.
*
* @param {date}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.scheduledEnqueueTimeUtc]
* Gets or sets the scheduled enqueue time UTC.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.sessionId]
* Gets or sets the session ID.
*
* @param {moment.duration}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.timeToLive]
* Gets or sets the time to live.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.to]
* Gets or sets the to.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.viaPartitionKey]
* Gets or sets the via partition key.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.customMessageProperties]
* Gets or sets the custom message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.message] Gets or
* sets the message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.namespace] Gets or
* sets the namespace.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.transportType]
* Gets or sets the transport type. Possible values include: 'NotSpecified',
* 'NetMessaging', 'AMQP'
*
* @param {object} [job.properties.action.errorAction.retryPolicy] Gets or sets
* the retry policy.
*
* @param {string} [job.properties.action.errorAction.retryPolicy.retryType]
* Gets or sets the retry strategy to be used. Possible values include: 'None',
* 'Fixed'
*
* @param {moment.duration}
* [job.properties.action.errorAction.retryPolicy.retryInterval] Gets or sets
* the retry interval between retries, specify duration in ISO 8601 format.
*
* @param {number} [job.properties.action.errorAction.retryPolicy.retryCount]
* Gets or sets the number of times a retry should be attempted.
*
* @param {object} [job.properties.recurrence] Gets or sets the job recurrence.
*
* @param {string} [job.properties.recurrence.frequency] Gets or sets the
* frequency of recurrence (second, minute, hour, day, week, month). Possible
* values include: 'Minute', 'Hour', 'Day', 'Week', 'Month'
*
* @param {number} [job.properties.recurrence.interval] Gets or sets the
* interval between retries.
*
* @param {number} [job.properties.recurrence.count] Gets or sets the maximum
* number of times that the job should run.
*
* @param {date} [job.properties.recurrence.endTime] Gets or sets the time at
* which the job will complete.
*
* @param {object} [job.properties.recurrence.schedule]
*
* @param {array} [job.properties.recurrence.schedule.weekDays] Gets or sets
* the days of the week that the job should execute on.
*
* @param {array} [job.properties.recurrence.schedule.hours] Gets or sets the
* hours of the day that the job should execute at.
*
* @param {array} [job.properties.recurrence.schedule.minutes] Gets or sets the
* minutes of the hour that the job should execute at.
*
* @param {array} [job.properties.recurrence.schedule.monthDays] Gets or sets
* the days of the month that the job should execute on. Must be between 1 and
* 31.
*
* @param {array} [job.properties.recurrence.schedule.monthlyOccurrences] Gets
* or sets the occurrences of days within a month.
*
* @param {string} [job.properties.state] Gets or set the job state. Possible
* values include: 'Enabled', 'Disabled', 'Faulted', 'Completed'
*
* @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 JobDefinition} for more information.
*
* {object} [request] - The HTTP Request object if an error did not occur.
*
* {stream} [response] - The HTTP Response stream if an error did not occur.
*/
function _createOrUpdate(resourceGroupName, jobCollectionName, jobName, job, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Validate
try {
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (jobCollectionName === null || jobCollectionName === undefined || typeof jobCollectionName.valueOf() !== 'string') {
throw new Error('jobCollectionName cannot be null or undefined and it must be of type string.');
}
if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
throw new Error('jobName cannot be null or undefined and it must be of type string.');
}
if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
}
if (job === null || job === undefined) {
throw new Error('job 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.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}';
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{jobCollectionName}', encodeURIComponent(jobCollectionName));
requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'PUT';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
// Serialize Request
let requestContent = null;
let requestModel = null;
try {
if (job !== null && job !== undefined) {
let requestModelMapper = new client.models['JobDefinition']().mapper();
requestModel = client.serialize(requestModelMapper, job, 'job');
requestContent = JSON.stringify(requestModel);
}
} catch (error) {
let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
`payload - ${JSON.stringify(job, null, 2)}.`);
return callback(serializationError);
}
httpRequest.body = requestContent;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200 && statusCode !== 201) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
parsedErrorResponse = JSON.parse(responseBody);
if (parsedErrorResponse) {
if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
}
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
let resultMapper = new client.models['CloudError']().mapper();
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
}
// Create Result
let result = null;
if (responseBody === '') responseBody = null;
// Deserialize Response
if (statusCode === 200) {
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['JobDefinition']().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['JobDefinition']().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);
});
}
/**
* Patches an existing job.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} jobCollectionName The job collection name.
*
* @param {string} jobName The job name.
*
* @param {object} job The job definition.
*
* @param {object} [job.properties] Gets or sets the job properties.
*
* @param {date} [job.properties.startTime] Gets or sets the job start time.
*
* @param {object} [job.properties.action] Gets or sets the job action.
*
* @param {string} [job.properties.action.type] Gets or sets the job action
* type. Possible values include: 'Http', 'Https', 'StorageQueue',
* 'ServiceBusQueue', 'ServiceBusTopic'
*
* @param {object} [job.properties.action.request] Gets or sets the http
* requests.
*
* @param {object} [job.properties.action.queueMessage] Gets or sets the
* storage queue message.
*
* @param {object} [job.properties.action.serviceBusQueueMessage] Gets or sets
* the service bus queue message.
*
* @param {object} [job.properties.action.serviceBusTopicMessage] Gets or sets
* the service bus topic message.
*
* @param {object} [job.properties.action.retryPolicy] Gets or sets the retry
* policy.
*
* @param {object} [job.properties.action.errorAction] Gets or sets the error
* action.
*
* @param {string} [job.properties.action.errorAction.type] Gets or sets the
* job error action type. Possible values include: 'Http', 'Https',
* 'StorageQueue', 'ServiceBusQueue', 'ServiceBusTopic'
*
* @param {object} [job.properties.action.errorAction.request] Gets or sets the
* http requests.
*
* @param {object} [job.properties.action.errorAction.request.authentication]
* Gets or sets the authentication method of the request.
*
* @param {string}
* job.properties.action.errorAction.request.authentication.type Polymorphic
* Discriminator
*
* @param {string} [job.properties.action.errorAction.request.uri] Gets or sets
* the URI of the request.
*
* @param {string} [job.properties.action.errorAction.request.method] Gets or
* sets the method of the request.
*
* @param {string} [job.properties.action.errorAction.request.body] Gets or
* sets the request body.
*
* @param {object} [job.properties.action.errorAction.request.headers] Gets or
* sets the headers.
*
* @param {object} [job.properties.action.errorAction.queueMessage] Gets or
* sets the storage queue message.
*
* @param {string}
* [job.properties.action.errorAction.queueMessage.storageAccount] Gets or sets
* the storage account name.
*
* @param {string} [job.properties.action.errorAction.queueMessage.queueName]
* Gets or sets the queue name.
*
* @param {string} [job.properties.action.errorAction.queueMessage.sasToken]
* Gets or sets the SAS key.
*
* @param {string} [job.properties.action.errorAction.queueMessage.message]
* Gets or sets the message.
*
* @param {object} [job.properties.action.errorAction.serviceBusQueueMessage]
* Gets or sets the service bus queue message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.queueName] Gets or
* sets the queue name.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.authentication]
* Gets or sets the Service Bus authentication.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.brokeredMessageProperties]
* Gets or sets the brokered message properties.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusQueueMessage.customMessageProperties]
* Gets or sets the custom message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.message] Gets or
* sets the message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.namespace] Gets or
* sets the namespace.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusQueueMessage.transportType]
* Gets or sets the transport type. Possible values include: 'NotSpecified',
* 'NetMessaging', 'AMQP'
*
* @param {object} [job.properties.action.errorAction.serviceBusTopicMessage]
* Gets or sets the service bus topic message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.topicPath] Gets or
* sets the topic path.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication]
* Gets or sets the Service Bus authentication.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.sasKey]
* Gets or sets the SAS key.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.sasKeyName]
* Gets or sets the SAS key name.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.authentication.type]
* Gets or sets the authentication type. Possible values include:
* 'NotSpecified', 'SharedAccessKey'
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties]
* Gets or sets the brokered message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.contentType]
* Gets or sets the content type.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.correlationId]
* Gets or sets the correlation ID.
*
* @param {boolean}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.forcePersistence]
* Gets or sets the force persistence.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.label]
* Gets or sets the label.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.messageId]
* Gets or sets the message ID.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.partitionKey]
* Gets or sets the partition key.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.replyTo]
* Gets or sets the reply to.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.replyToSessionId]
* Gets or sets the reply to session ID.
*
* @param {date}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.scheduledEnqueueTimeUtc]
* Gets or sets the scheduled enqueue time UTC.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.sessionId]
* Gets or sets the session ID.
*
* @param {moment.duration}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.timeToLive]
* Gets or sets the time to live.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.to]
* Gets or sets the to.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.brokeredMessageProperties.viaPartitionKey]
* Gets or sets the via partition key.
*
* @param {object}
* [job.properties.action.errorAction.serviceBusTopicMessage.customMessageProperties]
* Gets or sets the custom message properties.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.message] Gets or
* sets the message.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.namespace] Gets or
* sets the namespace.
*
* @param {string}
* [job.properties.action.errorAction.serviceBusTopicMessage.transportType]
* Gets or sets the transport type. Possible values include: 'NotSpecified',
* 'NetMessaging', 'AMQP'
*
* @param {object} [job.properties.action.errorAction.retryPolicy] Gets or sets
* the retry policy.
*
* @param {string} [job.properties.action.errorAction.retryPolicy.retryType]
* Gets or sets the retry strategy to be used. Possible values include: 'None',
* 'Fixed'
*
* @param {moment.duration}
* [job.properties.action.errorAction.retryPolicy.retryInterval] Gets or sets
* the retry interval between retries, specify duration in ISO 8601 format.
*
* @param {number} [job.properties.action.errorAction.retryPolicy.retryCount]
* Gets or sets the number of times a retry should be attempted.
*
* @param {object} [job.properties.recurrence] Gets or sets the job recurrence.
*
* @param {string} [job.properties.recurrence.frequency] Gets or sets the
* frequency of recurrence (second, minute, hour, day, week, month). Possible
* values include: 'Minute', 'Hour', 'Day', 'Week', 'Month'
*
* @param {number} [job.properties.recurrence.interval] Gets or sets the
* interval between retries.
*
* @param {number} [job.properties.recurrence.count] Gets or sets the maximum
* number of times that the job should run.
*
* @param {date} [job.properties.recurrence.endTime] Gets or sets the time at
* which the job will complete.
*
* @param {object} [job.properties.recurrence.schedule]
*
* @param {array} [job.properties.recurrence.schedule.weekDays] Gets or sets
* the days of the week that the job should execute on.
*
* @param {array} [job.properties.recurrence.schedule.hours] Gets or sets the
* hours of the day that the job should execute at.
*
* @param {array} [job.properties.recurrence.schedule.minutes] Gets or sets the
* minutes of the hour that the job should execute at.
*
* @param {array} [job.properties.recurrence.schedule.monthDays] Gets or sets
* the days of the month that the job should execute on. Must be between 1 and
* 31.
*
* @param {array} [job.properties.recurrence.schedule.monthlyOccurrences] Gets
* or sets the occurrences of days within a month.
*
* @param {string} [job.properties.state] Gets or set the job state. Possible
* values include: 'Enabled', 'Disabled', 'Faulted', 'Completed'
*
* @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 JobDefinition} 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 _patch(resourceGroupName, jobCollectionName, jobName, job, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Validate
try {
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (jobCollectionName === null || jobCollectionName === undefined || typeof jobCollectionName.valueOf() !== 'string') {
throw new Error('jobCollectionName cannot be null or undefined and it must be of type string.');
}
if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
throw new Error('jobName cannot be null or undefined and it must be of type string.');
}
if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
}
if (job === null || job === undefined) {
throw new Error('job 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.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}';
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{jobCollectionName}', encodeURIComponent(jobCollectionName));
requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'PATCH';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
// Serialize Request
let requestContent = null;
let requestModel = null;
try {
if (job !== null && job !== undefined) {
let requestModelMapper = new client.models['JobDefinition']().mapper();
requestModel = client.serialize(requestModelMapper, job, 'job');
requestContent = JSON.stringify(requestModel);
}
} catch (error) {
let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` +
`payload - ${JSON.stringify(job, null, 2)}.`);
return callback(serializationError);
}
httpRequest.body = requestContent;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200) {
let error = new Error(responseBody);
error.statusCode = response.statusCode;
error.request = msRest.stripRequest(httpRequest);
error.response = msRest.stripResponse(response);
if (responseBody === '') responseBody = null;
let parsedErrorResponse;
try {
parsedErrorResponse = JSON.parse(responseBody);
if (parsedErrorResponse) {
if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error;
if (parsedErrorResponse.code) error.code = parsedErrorResponse.code;
if (parsedErrorResponse.message) error.message = parsedErrorResponse.message;
}
if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) {
let resultMapper = new client.models['CloudError']().mapper();
error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body');
}
} catch (defaultError) {
error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` +
`- "${responseBody}" for the default response.`;
return callback(error);
}
return callback(error);
}
// Create Result
let result = null;
if (responseBody === '') responseBody = null;
// Deserialize Response
if (statusCode === 200) {
let parsedResponse = null;
try {
parsedResponse = JSON.parse(responseBody);
result = JSON.parse(responseBody);
if (parsedResponse !== null && parsedResponse !== undefined) {
let resultMapper = new client.models['JobDefinition']().mapper();
result = client.deserialize(resultMapper, parsedResponse, 'result');
}
} catch (error) {
let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`);
deserializationError.request = msRest.stripRequest(httpRequest);
deserializationError.response = msRest.stripResponse(response);
return callback(deserializationError);
}
}
return callback(null, result, httpRequest, response);
});
}
/**
* Deletes a job.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} jobCollectionName The job collection name.
*
* @param {string} jobName The job 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 _deleteMethod(resourceGroupName, jobCollectionName, jobName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Validate
try {
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (jobCollectionName === null || jobCollectionName === undefined || typeof jobCollectionName.valueOf() !== 'string') {
throw new Error('jobCollectionName cannot be null or undefined and it must be of type string.');
}
if (jobName === null || jobName === undefined || typeof jobName.valueOf() !== 'string') {
throw new Error('jobName cannot be null or undefined and it must be of type string.');
}
if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') {
throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.');
}
if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') {
throw new Error('this.client.acceptLanguage must be of type string.');
}
} catch (error) {
return callback(error);
}
// Construct URL
let baseUrl = this.client.baseUri;
let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scheduler/jobCollections/{jobCollectionName}/jobs/{jobName}';
requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId));
requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName));
requestUrl = requestUrl.replace('{jobCollectionName}', encodeURIComponent(jobCollectionName));
requestUrl = requestUrl.replace('{jobName}', encodeURIComponent(jobName));
let queryParameters = [];
queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion));
if (queryParameters.length > 0) {
requestUrl += '?' + queryParameters.join('&');
}
// Create HTTP transport objects
let httpRequest = new WebResource();
httpRequest.method = 'DELETE';
httpRequest.url = requestUrl;
httpRequest.headers = {};
// Set Headers
httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8';
if (this.client.generateClientRequestId) {
httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid();
}
if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) {
httpRequest.headers['accept-language'] = this.client.acceptLanguage;
}
if(options) {
for(let headerName in options['customHeaders']) {
if (options['customHeaders'].hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = options['customHeaders'][headerName];
}
}
}
httpRequest.body = null;
// Send Request
return client.pipeline(httpRequest, (err, response, responseBody) => {
if (err) {
return callback(err);
}
let statusCode = response.statusCode;
if (statusCode !== 200) {
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);
});
}
/**
* Runs a job.
*
* @param {string} resourceGroupName The resource group name.
*
* @param {string} jobCollectionName The job collection name.
*
* @param {string} jobName The job 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 _run(resourceGroupName, jobCollectionName, jobName, options, callback) {
/* jshint validthis: true */
let client = this.client;
if(!callback && typeof options === 'function') {
callback = options;
options = null;
}
if (!callback) {
throw new Error('callback cannot be null.');
}
// Validate
try {
if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') {
throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.');
}
if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') {
throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.');
}
if (jobCollectionName === null || jobCollectionName === undefined || typeof jobC