Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var getSas = require('./common.js').getSas;
var JobClient = require('azure-iothub').JobClient;
var showDeprecationText = require('./common.js').showDeprecationText;
showDeprecationText('az iot hub job cancel');
program
.description('Cancel existing job')
.usage('[options] ')
.option('-l, --login ', 'use the connection string provided as argument to use to authenticate with your IoT Hub instance')
.parse(process.argv);
var jobId = program.args[0];
var sas = getSas(program.login);
var jobClient = JobClient.fromSharedAccessSignature(sas);
jobClient.cancelJob(jobId, function (err) {
if (err) {
serviceError(err);
} else {
console.log('Job ' + jobId + ' cancelled');
}
});
var showDeprecationText = require('./common.js').showDeprecationText;
showDeprecationText('az iot hub job list');
program
.description('Query existing jobs')
.usage('[options] [job-type] [job-status]')
.option('-l, --login ', 'use the connection string provided as argument to use to authenticate with your IoT Hub instance')
.option('-r, --raw', 'use this flag to return raw output instead of pretty-printed output')
.parse(process.argv);
var jobType = program.args[0];
var jobStatus = program.args[1];
var sas = getSas(program.login);
var jobClient = JobClient.fromSharedAccessSignature(sas);
var query = jobClient.createQuery(jobType, jobStatus);
var onNewResults = function(err, results) {
if (err) {
serviceError(err);
} else {
results.forEach(function(job) {
var output = program.raw ? JSON.stringify(job) : prettyjson.render(job);
console.log(output);
});
if(query.hasMoreResults) {
query.next(onNewResults);
}
}
};
query.next(onNewResults);