-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.js
30 lines (25 loc) · 887 Bytes
/
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
if (!process.env.API_KEY) {
console.error('missing API_KEY')
process.exit(1)
}
const DigitalOcean = require('do-wrapper').default
const api = new DigitalOcean(process.env.API_KEY, 0)
const getAllQ = {
tag_name: '',
per_page: 25,
page: 1
}
const deleteAllDroplets = async () => {
const accountInfo = await api.account()
console.log('connecting to account')
if (!accountInfo.body.account.uuid) {
return console.log("can't connect to account")
}
const getAllDroplets = await api.dropletsGetAll(getAllQ)
const dropletIds = getAllDroplets.body.droplets.map(droplet => droplet.id)
console.log('all-droplets', dropletIds)
console.log('deleting all droplets')
const deletedDroplets = await api.tagsDeleteDroplets('loom')
console.log('Delete all droplets by tag returns 204?? (success): ', deletedDroplets.response.statusCode === 204)
}
deleteAllDroplets()