node-do-api
DigitalOcean API v2.0 for Node.js
Installation
npm install do-api --save
Configuration
Create a api token on digitalocean and save it under config/Default.json
{
"Token": "y0wCcq9UvKuSHm39q5FQqbT6K8oU7o1D2Fc723658ds1DHyXzkztt0sFQRG8JplK"
}
Code Example
var api = require('do-api');
api.getAccount()
.then(function(account) {
...
})
.fail(function (error) {
...
});
Usage
For further details visit the original API Documentation on here
Account
api.getAccount()
.then(function(account) {
...
});
Actions
Get all actions
api.getActions()
.then(function(actions) {
...
});
Get action by id
api.getAction(action_id)
.then(function(action) {
...
});
Domains
Get all domains
api.getDomains()
.then(function(domains) {
...
});
Get domain by name
api.getDomain(name)
.then(function(domain) {
...
});
Add domain
api.addDomain(name, ip_address)
.then(function(domain) {
...
});
Delete domain
api.deleteDomain(name)
.then(function() {
...
});
Domain Records
Get all records of by domain name
api.getDomainRecords(domain_name)
.then(function(records) {
...
});
Get domain record by id
api.getDomainRecord(record_id)
.then(function(record) {
...
});
Add record to a domain
api.addDomainRecord(domain_name, type, name, data, priority, port, weight)
.then(function(domain) {
...
});
Update an existing domain record
api.updateDomainRecord(domain_name, record_id, type, name, data, priority, port, weight)
.then(function(domain) {
...
});
Delete domain record
api.deleteDomainRecord(domain_name, record_id)
.then(function() {
...
});
Droplets
Get your droplets
api.getDroplets()
.then(function(droplets) {
...
});
Get droplet by id
api.getDroplet(domain_id)
.then(function(droplet) {
...
});
Create droplet
api.addDroplet(name, region, size, image, ssh_keys, backups, ipv6, user_data, private_networking)
.then(function(droplet) {
...
});
Delete droplet by id
api.deleteDroplet(droplet_id)
.then(function() {
...
});
Get available droplet kernels
api.getDropletKernels(droplet_id)
.then(function(kernels) {
...
});
Get droplet snapshots
api.getDropletSnapshots(droplet_id)
.then(function(snapshots) {
...
});
Get droplet backups
api.getDropletBackups(droplet_id)
.then(function(backups) {
...
});
Get droplet actions
api.getDropletActions(droplet_id)
.then(function(actions) {
...
});
Get droplet neighbors
api.getDropletNeighbors(droplet_id)
.then(function(droplets) {
...
});
Get neighbors
api.getNeighbors()
.then(function(neighbors) {
...
});
Droplet Actions
Disable backup on droplet
api.disableBackupOnDroplet(droplet_id)
.then(function(action) {
...
});
Reboot droplet
api.rebootDroplet(droplet_id)
.then(function(action) {
...
});
PowerCycle droplet
api.powerCycleDroplet(droplet_id)
.then(function(action) {
...
});
Shutdown droplet
api.shutdownDroplet(droplet_id)
.then(function(action) {
...
});
Power Off droplet
api.powerOffDroplet(droplet_id)
.then(function(action) {
...
});
Power On droplet
api.powerOnDroplet(droplet_id)
.then(function(action) {
...
});
Restore droplet
api.restoreDroplet(droplet_id)
.then(function(action) {
...
});
Reset password on droplet
api.passwordResetOnDroplet(droplet_id)
.then(function(action) {
...
});
Resize droplet
api.resizeDroplet(droplet_id, size)
.then(function(action) {
...
});
Rebuild droplet
api.rebuildDroplet(droplet_id, image)
.then(function(action) {
...
});
Rename droplet
api.renameDroplet(droplet_id, name)
.then(function(action) {
...
});
Change kernel on droplet
api.changeKernelOnDroplet(droplet_id, kernel)
.then(function(action) {
...
});
Enable ipv6 on droplet
api.enableIpv6OnDroplet(droplet_id)
.then(function(action) {
...
});
Enable private networking on droplet
api.enablePrivateNetworkingOnDroplet(droplet_id)
.then(function(action) {
...
});
Snapshot droplet
api.snapshotDroplet(droplet_id, name)
.then(function(action) {
...
});
Upgrade droplet
api.upgradeDroplet(droplet_id)
.then(function(action) {
...
});
Get action of droplet
api.getDropletAction(droplet_id, action_id)
.then(function(action) {
...
});
Images
Get images
api.getImages()
.then(function(images) {
...
});
Get distribution images
api.getDistributionImages()
.then(function(images) {
...
});
Get application images
api.getApplicationImages()
.then(function(images) {
...
});
Get user images
api.getUserImages()
.then(function(images) {
...
});
Get image
api.getImage(image_id)
.then(function(image) {
...
});
Image Actions
Get action of image
api.getImageAction(image_id, action_id)
.then(function(action) {
...
});
Update name of image
api.updateImage(image_id, name)
.then(function(image) {
...
});
Delete Image by id
api.deleteImage(image_id)
.then(function() {
...
});
Transfer image
api.transferImage(image_id, region)
.then(function(action) {
...
});
SSH Keys
Get SSH Keys
api.getSSHKeys()
.then(function(keys) {
...
});
Add SSH key
api.addSSHKey(name, public_key)
.then(function(key) {
...
});
Get SSH key by id
api.getSSHKey(key_id)
.then(function(key) {
...
});
Update name of SSH key
api.updateSSHKey(key_id, name)
.then(function(key) {
...
});
Delete SSH key
api.deleteSSHKey(key_id)
.then(function() {
...
});
Regions
Get regions
api.getRegions()
.then(function(regions) {
...
});
Sizes
Get sizes
api.getSizes()
.then(function(sizes) {
...
});