OceanusAncora
A DigitalOcean API client for use with NodeJS.
Example
var oa = require('oceanusancora'),
fs = require('fs');
var client = oa.createClient({
client_id: 'id',
api_key: 'key'
});
client.droplets.list(function (err, statusCode, body, response, res) {
if (err) {
console.log(err);
return;
}
console.log(JSON.stringify(res, null, 2, true));
});
Take a look in the examples
folder for more examples.
Install
Install using npm:
npm install oceanusancora
Command Line Options for scripts
Below is a list of options you may use when calling any scripts you may have written
-c --client_id X
-a --api_key X
--debug
--no-cookies
--timeout X(ms)
--proxy X
--encoding X
They are fairly self-explanatory no-cookies, timeout, proxy, encoding are all options to request. if using debug its reccomended you use --encoding utf8
or something similar as all you will see is a buffer otherwise in the response.
Because of these command line options you can try a few already from the examples section:
node examples/list_droplets.js -c <client_id> -a <api_key>
Methods
domains
list(cb)
new(name, ip_address, cb)
show(domain_id, cb)
destroy(domain_id, cb)
records(domain_id, cb)
newRecord(domain_id, record_type, data, options, cb)
showRecord(domain_id, record_id, cb)
destroyRecord(domain_id, record_id, cb)
editRecord(domain_id, record_id, record_type, data, options, cb)
droplets
list(cb)
new(name, size, image, region, options, cb)
show(droplet_id, cb)
reboot(droplet_id, cb)
powerCycle(droplet_id, cb)
shutDown(droplet_id, cb)
powerOff(droplet_id, cb)
powerOn(droplet_id, cb)
passwordReset(droplet_id, cb)
resize(droplet_id, size, cb)
snapshot(droplet_id, name, cb)
restore(droplet_id, image_id, cb)
rebuild(droplet_id, image_id, cb)
rename(droplet_id, name, cb)
destroy(droplet_id, scrub_data, cb)
events
show(event_id, cb)
images
list(filter, cb)
show(image, cb)
destroy(image, cb)
transfer(image, region_id, cb)
regions
list(cb)
sizes
list(cb)
ssh_keys
list(cb)
new(name, ssh_pub_key, cb)
show(ssh_key_id, cb)
edit(ssh_key_id, options, cb)
destroy(ssh_key_id, cb)
Tests
npm test
todo: further client testing; nock reply data does not represent what DigitalOcean responds with in all cases, but is currently unused.
License
MIT.