-
Notifications
You must be signed in to change notification settings - Fork 5
/
bl-data-delete.js
executable file
·30 lines (25 loc) · 983 Bytes
/
bl-data-delete.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
const axios = require('axios');
const config = require('./config');
const fs = require('fs');
const commander = require('commander');
const util = require('./util');
const size = require('window-size');
commander
.option('-i, --id <id>', 'data object id to remove')
.option('-j, --json', 'output info in json format')
.parse(process.argv);
if (commander.args.length > 0 && util.isValidObjectId(commander.args[0])) {
commander.id = commander.id || commander.args[0];
commander.args = commander.args.slice(1);
}
util.loadJwt().then(jwt => {
let headers = { "Authorization": "Bearer " + jwt };
axios.delete(config.api.warehouse+"/dataset/"+commander.id, {headers}).then(res=>{
if(commander.json) console.dir(res.data);
else console.log("successfully removed dataset");
}).catch(err=>{
if(commander.json) console.error(err.response.data);
else console.error(err.response.data.message);
});
});