brinydeep

node.js wrapper for Digital Ocean's API

brinydeep

=========

  •   now correctly returns IPs if called on a single ID
    
  •   fixed error checking, digital ocean made a minor change in their JSON
    
  • added a function that takes in ID's and returns IPs (if not available will continue to poll until IP is assigned):
get_ips([185733,185734,185735], callback) 

returns:

[ { ip: '192.81.212.217', id: 185733 },
  { ip: '198.211.115.4', id: 185734 },
  { ip: '192.81.218.144', id: 185735 } ]
  • fixed several bugs due with untested functions
  • seperated requesting logic for the api exposure functions
  • ensure 100% test coverage
  • implement ssh functionality
  • clean up credentials string handling so it is only in one file
  •   documentation for get_ids_created_this_session
    

node.js wrapper for Digital Ocean's API

install

With npm do:

npm install brinydeep

example

var brinydeep = require('brinydeep');
brinydeep.setup(CLIENT_KEY, API_KEY);
var new_droplet = {
    name: "test1",
    size_id: 66,
    image_id: 25306,
    region_id: 1
};
brinydeep.new_droplets(new_droplet,function (e,o) {
    console.log(o);
});
brinydeep.get_ids(function (e,o) {
    temp_ids = o;
});
 

example with multiple machines

var new_droplet_multi = {
    droplets: [
        {
            name: "test2",
            size_id: 66,
            image_id: 25306,
            region_id: 1
        },
        {
            name: "test3",
            size_id: 66,
            image_id: 25306,
            region_id: 1
        }
    ]
};
var temp_ids = '';
 
brinydeep.new_droplets(new_droplet_multi,function (e,o) {
    console.log(o);
});
brinydeep.get_ids(function (e,o) {
    temp_ids = o;
});
 

#TODO *SSH commands to hosts *Clean up test suite

API methods

var brinydeep = require('brinydeep').setup(CLIENT_KEY, API_KEY);

This sets up the API for use

returns the html for digitaloceans api

returns an array of all the ids

returns active ids in Digital Oceans API form, (all functions taking IDs can be passed an array of IDs, and will return an array of seperate JSON responses).

{"status":"OK","droplets":[{"backups_active":null,"id":100823,"image_id":420,"name":"test222","region_id":1,"size_id":33,"status":"active"}]}

returns active ids in Digital Oceans API form

{"status":"OK","droplets":[{"backups_active":null,"id":100823,"image_id":420,"name":"test222","region_id":1,"size_id":33,"status":"active"}]}

creates a new droplet

Options: *name Required, String, this is the name of the droplet - must be formatted by hostname rules *size_id Required, Numeric, this is the id of the size you would like the droplet created at *image_id Required, Numeric, this is the id of the image you would like the droplet created with *region_id Required, Numeric, this is the id of the region you would like your server in IE: US/Amsterdam *ssh_key_ids Optional, Numeric CSV, comma separated list of ssh_key_ids that you would like to be added to the server

{"status":"OK","droplet":{"id":100824,"name":"test","image_id":419,"size_id":32,"event_id":7499}}

reboots droplets

{"status":"OK","event_id":7501}

power cycles droplets

{"status":"OK","event_id":7501}

shuts off droplets

{"status":"OK","event_id":7501}

powers off droplets

{"status":"OK","event_id":7501}

powers on droplets

{"status":"OK","event_id":7501}

This method will reset the root password for a droplet. Please be aware that this will reboot the droplet to allow resetting the password.

{"status":"OK","event_id":7501}

This method will resize a droplet based on id size

{"status":"OK","event_id":7501}

This method will take a snapshot of a droplet (this will only take one id as an arg)

{"status":"OK","event_id":7504}

This method allows you to restore a droplet with a previous image or snapshot. This will be a mirror copy of the image or snapshot to your droplet. Be sure you have backed up any necessary information prior to restore.

{"status":"OK","event_id":7504}

This method allows you to reinstall a droplet with a default image. This is useful if you want to start again but retain the same IP address for your droplet.

{"status":"OK","event_id":7504}

This method enables automatic backups which run in the background daily to backup your droplet's data.

{"status":"OK","event_id":7504}

This method disables automatic backups.

{"status":"OK","event_id":7504}

This method destroys all droplets.

{"status":"OK","event_id":7504}

This method destroys droplets provided their ids.

{"status":"OK","event_id":7504}

Returns all regions.

{"status":"OK","regions":[{"id":1,"name":"New York 1"},{"id":2,"name":"Amsterdam 1"}]}

Returns all images.

{"status":"OK","images":[{"id":429,"name":"Real Backup 10242011","distribution":"Ubuntu"},{"id":430,"name":"test233","distribution":"Ubuntu"},{"id":431,"name":"test888","distribution":"Ubuntu"},{"id":442,"name":"tesah22","distribution":"Ubuntu"},{"id":443,"name":"testah33","distribution":"Ubuntu"},{"id":444,"name":"testah44","distribution":"Ubuntu"},{"id":447,"name":"ahtest55","distribution":"Ubuntu"},{"id":448,"name":"ahtest66","distribution":"Ubuntu"},{"id":449,"name":"ahtest77","distribution":"Ubuntu"},{"id":458,"name":"Rails3-1Ruby1-9-2","distribution":"Ubuntu"},{"id":466,"name":"NYTD Backup 1-18-2012","distribution":"Ubuntu"},{"id":478,"name":"NLP Final","distribution":"Ubuntu"},{"id":540,"name":"API - Final","distribution":"Ubuntu"},{"id":577,"name":"test1-1","distribution":"Ubuntu"},{"id":578,"name":"alec snapshot1","distribution":"Ubuntu"}]}

Shows images for given ids.

{"status":"OK","image":{"id":429,"name":"Real Backup 10242011","distribution":"Ubuntu"}}

destroys images for given ids.

{"status":"OK","image":{"id":429,"name":"Real Backup 10242011","distribution":"Ubuntu"}}

shows all ssh keys

{"status":"OK","ssh_keys":[{"id":10,"name":"office-imac"},{"id":11,"name":"macbook-air"}]}

shows all ssh keys

{"status":"OK","ssh_keys":[{"id":10,"name":"office-imac"},{"id":11,"name":"macbook-air"}]}

shows all different sizes

{"status":"OK","sizes":[{"id":33,"name":"512MB"},{"id":34,"name":"1GB"},{"id":35,"name":"2GB"},{"id":36,"name":"4GB"},{"id":37,"name":"8GB"},{"id":38,"name":"16GB"}]}

license

MIT