UNPKG

azure-arm-datalake-analytics

Version:

Microsoft Azure Data Lake Analytics Management Client Library for node

1,157 lines (1,127 loc) 90.5 kB
/* * 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 statistics of the specified job. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {uuid} jobIdentity Job Information ID. * * @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 JobStatistics} 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 _getStatistics(accountName, jobIdentity, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (jobIdentity === null || jobIdentity === undefined || typeof jobIdentity.valueOf() !== 'string' || !msRest.isValidUuid(jobIdentity)) { throw new Error('jobIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Jobs/{jobIdentity}/GetStatistics'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); requestUrl = requestUrl.replace('{jobIdentity}', encodeURIComponent(jobIdentity.toString())); 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['JobStatistics']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Gets the job debug data information specified by the job ID. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {uuid} jobIdentity Job identifier. Uniquely identifies the job across * all jobs submitted to the service. * * @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 JobDataPath} 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 _getDebugDataPath(accountName, jobIdentity, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (jobIdentity === null || jobIdentity === undefined || typeof jobIdentity.valueOf() !== 'string' || !msRest.isValidUuid(jobIdentity)) { throw new Error('jobIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Jobs/{jobIdentity}/GetDebugDataPath'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); requestUrl = requestUrl.replace('{jobIdentity}', encodeURIComponent(jobIdentity.toString())); 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['JobDataPath']().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); }); } /** * Builds (compiles) the specified job in the specified Data Lake Analytics * account for job correctness and validation. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {object} parameters The parameters to build a job. * * @param {string} [parameters.name] the friendly name of the job to build. * * @param {string} parameters.type the job type of the current job (Hive or * USql). Possible values include: 'USql', 'Hive' * * @param {object} parameters.properties the job specific properties. * * @param {string} [parameters.properties.runtimeVersion] the runtime version * of the Data Lake Analytics engine to use for the specific type of job being * run. * * @param {string} parameters.properties.script the script to run. Please note * that the maximum script size is 3 MB. * * @param {string} parameters.properties.type Polymorphic Discriminator * * @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 JobInformation} 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 _build(accountName, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (parameters === null || parameters === undefined) { throw new Error('parameters cannot be null or undefined.'); } if (this.client.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('/') ? '' : '/') + 'BuildJob'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); 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 = 'POST'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } // Serialize Request let requestContent = null; let requestModel = null; try { if (parameters !== null && parameters !== undefined) { let requestModelMapper = new client.models['BuildJobParameters']().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) { 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['JobInformation']().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); }); } /** * Cancels the running job specified by the job ID. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {uuid} jobIdentity Job identifier. Uniquely identifies the job across * all jobs submitted to the service. * * @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 _cancel(accountName, jobIdentity, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (jobIdentity === null || jobIdentity === undefined || typeof jobIdentity.valueOf() !== 'string' || !msRest.isValidUuid(jobIdentity)) { throw new Error('jobIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Jobs/{jobIdentity}/CancelJob'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); requestUrl = requestUrl.replace('{jobIdentity}', encodeURIComponent(jobIdentity.toString())); 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 = 'POST'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { 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); }); } /** * Submits a job to the specified Data Lake Analytics account. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {uuid} jobIdentity Job identifier. Uniquely identifies the job across * all jobs submitted to the service. * * @param {object} parameters The parameters to submit a job. * * @param {string} parameters.name the friendly name of the job to submit. * * @param {number} [parameters.degreeOfParallelism] the degree of parallelism * to use for this job. This must be greater than 0, if set to less than 0 it * will default to 1. * * @param {number} [parameters.priority] the priority value to use for the * current job. Lower numbers have a higher priority. By default, a job has a * priority of 1000. This must be greater than 0. * * @param {array} [parameters.logFilePatterns] the list of log file name * patterns to find in the logFolder. '*' is the only matching character * allowed. Example format: jobExecution*.log or *mylog*.txt * * @param {object} [parameters.related] the recurring job relationship * information properties. * * @param {uuid} [parameters.related.pipelineId] the job relationship pipeline * identifier (a GUID). * * @param {string} [parameters.related.pipelineName] the friendly name of the * job relationship pipeline, which does not need to be unique. * * @param {string} [parameters.related.pipelineUri] the pipeline uri, unique, * links to the originating service for this pipeline. * * @param {uuid} [parameters.related.runId] the run identifier (a GUID), unique * identifier of the iteration of this pipeline. * * @param {uuid} parameters.related.recurrenceId the recurrence identifier (a * GUID), unique per activity/script, regardless of iterations. This is * something to link different occurrences of the same job together. * * @param {string} [parameters.related.recurrenceName] the recurrence name, * user friendly name for the correlation between jobs. * * @param {string} parameters.type the job type of the current job (Hive or * USql). Possible values include: 'USql', 'Hive' * * @param {object} parameters.properties the job specific properties. * * @param {string} [parameters.properties.runtimeVersion] the runtime version * of the Data Lake Analytics engine to use for the specific type of job being * run. * * @param {string} parameters.properties.script the script to run. Please note * that the maximum script size is 3 MB. * * @param {string} parameters.properties.type Polymorphic Discriminator * * @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 JobInformation} 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(accountName, jobIdentity, parameters, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (jobIdentity === null || jobIdentity === undefined || typeof jobIdentity.valueOf() !== 'string' || !msRest.isValidUuid(jobIdentity)) { throw new Error('jobIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.'); } if (parameters === null || parameters === undefined) { throw new Error('parameters cannot be null or undefined.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.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('/') ? '' : '/') + 'Jobs/{jobIdentity}'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); requestUrl = requestUrl.replace('{jobIdentity}', encodeURIComponent(jobIdentity.toString())); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'PUT'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if (this.client.generateClientRequestId) { httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); } if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } // Serialize Request let requestContent = null; let requestModel = null; try { if (parameters !== null && parameters !== undefined) { let requestModelMapper = new client.models['CreateJobParameters']().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) { 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['JobInformation']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Gets the job information for the specified job ID. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {uuid} jobIdentity JobInfo ID. * * @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 JobInformation} 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(accountName, jobIdentity, 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 (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (jobIdentity === null || jobIdentity === undefined || typeof jobIdentity.valueOf() !== 'string' || !msRest.isValidUuid(jobIdentity)) { throw new Error('jobIdentity cannot be null or undefined and it must be of type string and must be a valid uuid.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Jobs/{jobIdentity}'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); requestUrl = requestUrl.replace('{jobIdentity}', encodeURIComponent(jobIdentity.toString())); 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['JobInformation']().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); }); } /** * Lists the jobs, if any, associated with the specified Data Lake Analytics * account. The response includes a link to the next page of results, if any. * * @param {string} accountName The Azure Data Lake Analytics account to execute * job operations on. * * @param {object} [options] Optional Parameters. * * @param {string} [options.filter] OData filter. Optional. * * @param {number} [options.top] The number of items to return. Optional. * * @param {number} [options.skip] The number of items to skip over before * returning elements. Optional. * * @param {string} [options.select] OData Select statement. Limits the * properties on each entry to just those requested, e.g. * Categories?$select=CategoryName,Description. Optional. * * @param {string} [options.orderby] OrderBy clause. One or more * comma-separated expressions with an optional "asc" (the default) or "desc" * depending on the order you'd like the values sorted, e.g. * Categories?$orderby=CategoryName desc. Optional. * * @param {boolean} [options.count] The Boolean value of true or false to * request a count of the matching resources included with the resources in the * response, e.g. Categories?$count=true. Optional. * * @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 JobInfoListResult} 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(accountName, 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 filter = (options && options.filter !== undefined) ? options.filter : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; let skip = (options && options.skip !== undefined) ? options.skip : undefined; let select = (options && options.select !== undefined) ? options.select : undefined; let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined; let count = (options && options.count !== undefined) ? options.count : undefined; // Validate try { if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { throw new Error('accountName cannot be null or undefined and it must be of type string.'); } if (this.client.adlaJobDnsSuffix === null || this.client.adlaJobDnsSuffix === undefined || typeof this.client.adlaJobDnsSuffix.valueOf() !== 'string') { throw new Error('this.client.adlaJobDnsSuffix cannot be null or undefined and it must be of type string.'); } if (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { throw new Error('filter must be of type string.'); } if (top !== null && top !== undefined && typeof top !== 'number') { throw new Error('top must be of type number.'); } if (top !== null && top !== undefined) { if (top < 1) { throw new Error('"top" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (skip !== null && skip !== undefined && typeof skip !== 'number') { throw new Error('skip must be of type number.'); } if (skip !== null && skip !== undefined) { if (skip < 1) { throw new Error('"skip" should satisfy the constraint - "InclusiveMinimum": 1'); } } if (select !== null && select !== undefined && typeof select.valueOf() !== 'string') { throw new Error('select must be of type string.'); } if (orderby !== null && orderby !== undefined && typeof orderby.valueOf() !== 'string') { throw new Error('orderby must be of type string.'); } if (count !== null && count !== undefined && typeof count !== 'boolean') { throw new Error('count must be of type boolean.'); } if (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Jobs'; requestUrl = requestUrl.replace('{accountName}', accountName); requestUrl = requestUrl.replace('{adlaJobDnsSuffix}', this.client.adlaJobDnsSuffix); let queryParameters = []; if (filter !== null && filter !== undefined) { queryParameters.push('$filter=' + encodeURIComponent(filter)); } if (top !== null && top !== undefined) { queryParameters.push('$top=' + encodeURIComponent(top.toString())); } if (skip !== null && skip !== undefined) { queryParameters.push('$skip=' + encodeURIComponent(skip.toString())); } if (select !== null && select !== undefined) { queryParameters.push('$select=' + encodeURIComponent(select)); } if (orderby !== null && orderby !== undefined) { queryParameters.push('$orderby=' + encodeURIComponent(orderby)); } if (count !== null && count !== undefined) { queryParameters.push('$count=' + encodeURIComponent(count.toString())); } 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) {