• Published 10 years ago

digitalocean_wrapper v

Weekly downloads
-
License
-
Repository
-
Last release
10 years ago

do-wrapper

Digital Ocean API v2 - Node.js Wrapper

If you spot any mistakes or have any suggestions, please raise an issue here: https://github.com/matt-major/do-wrapper/issues

Usage

//Import
var DigitalOcean = require('do-wrapper');

//Add your Digital Ocean API Access Token
var key = 'xxxxx';

//Create a new instance with your Access Token
var api = new DigitalOcean(key);

Example - Return all Droplets

api.dropletsGetAll(function(err, droplets) {
    console.log(droplets);
});

Methods

###Droplets Some Droplet methods require additional parameters, for this we pass in "extras".

If the method you are using requires no additional parameters pass in {}.

Example

var options = {"private_networking": true};
api.dropletsCreateNewDroplet("a-droplet-test", "nyc2", "512mb", 1601, options, function(err, droplet) {
    console.log(droplet.id);
});

Available Methods

dropletsGetAll(callback)
dropletsGetKernelsForDroplet(dropletID, callback)
dropletsGetBackupsForDroplet(dropletID, callback)
dropletsGetActionsForDroplet(dropletID, callback)
dropletsCreateNewDroplet(name, region, size, image, extras, callback)
dropletsGetDropletById(dropletID, callback)
dropletsDeleteDroplet(dropletID, callback)

###Droplet Actions Some Droplet Actions require more than one parameter, for this we pass in the "options".

If the method you are using requires no additional parameters pass in {}.

Example

var options = {"name": "ny2-njs"};
api.dropletActionRequest(1805584, 'rename', options, function(err, action) {
    console.log(action);
});

Available Methods

dropletActionRequest(dropletID, action, options, callback)
dropletActionGetStatus(dropletID, actionID, callback)

###Domains Available Methods

domainGetAll(callback)
domainAddNew(domain, ip, callback)
domainDeleteDomain(domain, callback)

###Domain Records Some Domain Records require additional parameters.

If the method you are using requires no additional parameters pass in {}.

Example

var options = {"name": "subdomain", "data": "2001:db8::ff01:52:8339"};
api.domainRecordsAddnew('test.com', 'A', options, function(err, record) {
    console.log(record);
});

Available Methods

domainRecordsGetAll(domain, callback)
domainRecordsAddnew(domain, type, options, callback)
domainRecordsGetRecord(domain, recordID, callback)
domainRecordsDeleteRecord(domain, recordID, callback)

###Images Available Methods

imagesGetAll(callback)
imagesGetImage(imageID, callback)
imagesGetBySlug(imageSlug, callback)
imagesDeleteImage(imageID, callback)

###Image Actions Available Methods

imagesTransferImage(imageID, region, callback)
imagesGetActionStatus(imageID, actionID, callback)

###Keys Available Methods

keysGetAll(callback)
keysAddNew(name, key, callback)
keysGetKey(keyID, callback)
keysUpdateKey(keyID, name, callback)
keysDestroyKey(keyID, callback)

###Regions Available Methods

regionsGetAll(callback)

###Sizes Available Methods

sizesGetAll(callback)

##License The MIT License (MIT)

Copyright (c) 2014 Matt Major

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.