-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.js
28 lines (23 loc) · 934 Bytes
/
status.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
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 dropletsStatus = 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)
const statusOfDeletedDroplets = await Promise.all(dropletIds.map(id => api.dropletsGetById(id)))
console.log('all droplet status', statusOfDeletedDroplets.map(res => res.body).map(droplet => droplet.droplet).map(droplet => ({id: droplet.id, status: droplet.status, ip4: droplet.networks.v4[0].ip_address})))
}
dropletsStatus()