digitalocean
Version:
nodejs wrapper for digitalocean v2 api
507 lines (452 loc) • 29.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><h1>digitalocean-node</h1><p><a href="https://travis-ci.org/phillbaker/digitalocean-node"><img src="https://travis-ci.org/phillbaker/digitalocean-node.svg?branch=master" alt="Build Status"></a>
<a href="https://www.npmjs.com/package/digitalocean"><img src="https://david-dm.org/phillbaker/digitalocean-node.svg" alt="Dependencies"></a>
<a href="https://www.npmjs.com/package/digitalocean"><img src="https://img.shields.io/npm/dm/digitalocean.svg" alt="Downloads"></a></p>
<p>digitalocean-node is a library for nodejs to access the <a href="https://developers.digitalocean.com/documentation/v2/">DigitalOcean v2 API</a>.</p>
<h2>Installation</h2><pre class="prettyprint source"><code>npm install digitalocean --save</code></pre><h2>Usage</h2><p>Every resource is accessed via an instance of the client. Please <a href="https://cloud.digitalocean.com/settings/api/tokens">chose one of your tokens</a> and use that where ever <code>TOKEN</code> is referenced. For example:</p>
<pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN'); // See
// client.{ RESOURCE_NAME }.{ METHOD_NAME }</code></pre><p>Every resource method accepts an optional callback as the last argument. For example:</p>
<pre class="prettyprint source lang-js"><code>client.account.get(function(err, account) {
console.log(err); // null on success
console.log(account); //
});</code></pre><p>See below <a href="#api-callback-structure">for more options in the callback</a>.</p>
<p>Resource methods also return a <a href="https://promisesaplus.com/">promise</a>. For example:</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list().then(function(droplets) {
var droplet = droplets[0];
return client.droplets.snapshot(droplet.id);
}).then(function() {
console.log("created a snapshot of a Droplet!");
}).catch(function(err) {
// Deal with an error
});</code></pre><p><a href="#all-resources-and-actions">All resources and actions</a> are listed below, however, the general structure of the client follows the following pattern:</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list(callback);
client.droplets.create(options, callback);
client.droplets.get(123, callback);
client.droplets.delete(123, callback);
client.droplets.powerOff(123, callback);
client.droplets.getAction(123, 456, callback);</code></pre><h3>Spaces support</h3><p><a href="https://developers.digitalocean.com/documentation/spaces/">DigitalOcean's Spaces</a> is an S3-compatible object storage service. The API for spaces is a different schema at a different abstraction level (XML and actual file objects) than the normal "control" API. The good news is that it's interopable with lots of existing S3 clients, <a href="https://github.com/andrewrk/node-s3-client">this is a node one</a>.</p>
<p>You should be able to use Spaces similarly to:</p>
<pre class="prettyprint source lang-js"><code>var s3 = require('s3');
var client = s3.createClient({
s3Options: {
accessKeyId: "your spaces key from https://cloud.digitalocean.com/settings/api/tokens",
secretAccessKey: "your spaces secret from https://cloud.digitalocean.com/settings/api/tokens",
region: "nyc3",
endpoint: 'nyc3.digitaloceanspaces.com',
},
});</code></pre><h2>Client Options</h2><p>The DigitalOcean client depends on <a href="https://github.com/request/request"><code>request</code></a>, and <a href="https://github.com/request/request#requestoptions-callback">options can be passed through</a> (e.g. a proxy or user agent). For example:</p>
<pre class="prettyprint source lang-js"><code>var client = digitalocean.client('TOKEN', {
request: myInitializedRequestObject,
requestOptions: {
proxy: 'https://myproxy.com:1085',
headers: {
'User-Agent': 'foo'
}
}
});</code></pre><p>Other options include:</p>
<pre class="prettyprint source lang-js"><code>var client = digitalocean.client('TOKEN', {
promise: MySpecialPromiseVersion, // defaults to Promise
decamelizeKeys: false // defaults to true
});</code></pre><h3>Using a client with an access token</h3><pre class="prettyprint source lang-js"><code>var client = digitalocean.client('TOKEN');
client.get('/account', {}, 200, 'account', function (err, status, body, headers) {
console.log(body); //json object
});</code></pre><h2>Callback function signature</h2><p>All callbacks will be passed:</p>
<ol>
<li>an error (null if no error occurred)</li>
<li>a resource object</li>
<li>the response headers</li>
<li>the raw response body</li>
</ol>
<p>For example:</p>
<pre class="prettyprint source lang-js"><code>client.account.get(function(err, account, headers, response) {
console.log("error: " + err);
console.log("account: " + account);
console.log("headers: " + headers);
console.log("response: " + response);
});</code></pre><h2>Promise result</h2><p>Promise results are the resource(s) returned by a successful response - a list response object, an individual object, or a blank object (for successful empty responses such as deletes). These objects have a special property, <code>_digitalOcean</code> that includes response information. For example:</p>
<pre class="prettyprint source lang-js"><code>// ...
.then(function(object) {
console.log(object); // =>
// {
// _digitalOcean: {
// statusCode: 204,
// body: {},
// headers: {}
// }
// }
})</code></pre><h2>Pagination</h2><h3>Auto pagination</h3><p>Although the DigitalOcean API returns results from query endpoints in <a href="https://developers.digitalocean.com/documentation/v2/#links">pages</a>, this client abstracts that notion by lazily fetching subsequent pages when they are needed. This allows developers to easily handles fetching large lists of resources without having to manually paginate results and perform subsequent requests - adding a layer of convenience on top of what is a common limitation in REST based APIs. An example of using this is:</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list(function(err, droplets) {
if (err) {
return console.error('Error fetching pages', err);
}
droplets.all(function(err, droplet) {
console.log(err, droplet);
});
var error = iterator.error()
if (error) {
console.log(error);
}
});</code></pre><p>Note that the magic <code>.length</code> property on <code>ListResponse</code> is tied to the first page of results.</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list(function(err, droplets) {
if (err) {
return console.error('Error fetching pages', err);
}
// Limited to original page only:
for (var i = 0, len = droplets.length; i < len; i++) {
console.log(droplets[i]);
}
});</code></pre><p>Under the hood, this enumeration is handled by an iterator object, this can be accessed as well (it uses promises internally):</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list(function(err, droplets) {
if (err) {
return console.error('Error fetching pages', err);
}
var iterator = droplets.iterator();
var iterable = iterator.next();
while(!iterable.done) {
iterable.value.then(function(value) {
console.log(value);
iterable = iterator.next();
});
}
// Check the error afterwards:
var error = iterator.error()
if (error) {
console.log(error);
}
});</code></pre><h3>Pagination parameters</h3><p>If a function declares pagination parameters, then results from the function are arranged in <a href="https://developers.digitalocean.com/documentation/v2/#links">pages</a>. These arguments are:</p>
<p>The <code>page</code> argument is optional and is used to specify which page of objects to retrieve.
The <code>perPage</code> argument is also optional and is used to specify how many objects per page.</p>
<pre class="prettyprint source lang-js"><code>// Normal usage of function
client.droplets.list(callback); // Callback receives an array of first 25 issues
// Using pagination parameters
client.droplets.list(2, 100, callback); // Callback receives an array of second 100 issues
client.droplets.list(10, callback); // Callback receives an array of 25 issues from page 10
// Pagination parameters can be set with query object too
client.droplets.list({
page: 2,
per_page: 100
}, callback); //array of second 100 issues which are closed</code></pre><h3>Pagination examples</h3><p>To fetch all the pages of a resource, the pages must be traversed. For example, to fetch all Droplets:</p>
<pre class="prettyprint source lang-js"><code>getAllDroplets(function(allDroplets) {
console.log(allDroplets.length);
});
function getAllDroplets(callback, page, array) {
client.droplets.list(page, function(err, droplets, _, response) {
if (err) {
return console.error('Error fetching pages', err);
}
if (page == null) {
page = 1;
}
if (array == null) {
array = [];
}
array = array.concat(droplets);
// has no pages or has pages and has no last page
var isLastPage = response['links'] && (
!response['links']['pages'] ||
(response['links']['pages'] && response['links']['pages']['last'] === undefined)
);
if (!err && isLastPage) {
callback.call(this, array);
} else if (!err && !isLastPage) {
getAllDroplets(callback, page + 1, array);
} else {
// whoops, try again
getAllDroplets(callback, page, array);
}
});
};</code></pre><p>Or Promise style:</p>
<pre class="prettyprint source lang-js"><code>getAllDroplets().then(function(allDroplets) {
console.log(allDroplets);
}).catch(function(err) {
console.log(err);
});
function getAllDroplets() {
var allDroplets = [];
function getDropletPage(page) {
if (page == null) {
page = 1;
}
return client.droplets.list(page)
.each(function(droplet) {
allDroplets.push(droplet);
})
.then(function(droplets) {
var links = droplets._digitalocean.body.links;
var isLastPage = links && (
!links.pages ||
(links.pages && links.pages.last === undefined)
);
if (isLastPage) {
return allDroplets;
} else {
return getDropletPage(page + 1);
}
});
}
return getDropletPage();
}</code></pre><h2>Rate Limiting</h2><p>You can also check your rate limit status by calling the following.</p>
<pre class="prettyprint source lang-js"><code>client.droplets.list(function (err, account, headers, response) {
console.log(headers['ratelimit-remaining']); // 4999
console.log(headers['ratelimit-limit']); // 5000
console.log(headers['ratelimit-reset']); // Time in Unix Epoch, e.g. 1415984218
});</code></pre><h2>Usage in the Browser</h2><p>This library is also available as a single file built for usage in the browser at <code>dist/digitalocean.js</code>. It uses <a href="http://browserify.org/">browserify</a> to package all dependencies and output the built file. This file is updated and released to <a href="https://bower.io">Bower</a> for each release with the same version.</p>
<p>For example, using the built file at <code>dist/digitalocean.js</code>:</p>
<pre class="prettyprint source lang-html"><code><html>
<head></head>
<body>
<script src="dist/digitalocean.js"></script>
<script>
var client = digitalocean.client('TOKEN');
client.account.get(function(_, account) {
console.log(account.uuid);
});
</script>
</body>
</html></code></pre><h2>All Resources and Actions</h2><p>The following resources and actions correspond to the resources and actions documented on <a href="https://developers.digitalocean.com/documentation/v2">DigitalOcean's API</a>. Some methods take an <code>attributes</code> argument, which is a plain JavaScript object, e.g. <code>{ email: 'foo@example.com' }</code>, whose keys and appropriate values are also documented in DigitalOcean's API documentation.</p>
<h3>Account resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.account</code></pre><ul>
<li><code>client.account.get([callback])</code></li>
<li><code>client.account.listSshKeys([page, perPage], [callback])</code></li>
<li><code>client.account.listSshKeys([queryObject], [callback])</code></li>
<li><code>client.account.createSshKey(attributes, [callback])</code></li>
<li><code>client.account.getSshKey(sshKey.id, [callback])</code></li>
<li><code>client.account.deleteSshKey(sshKey.id, [callback])</code></li>
<li><code>client.account.updateSshKey(sshKey.id, attributes, [callback])</code></li>
</ul>
<p>For the latest valid account attributes, <a href="https://developers.digitalocean.com/documentation/v2/#ssh-keys">see the official docs</a>.</p>
<h3>Action resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.actions</code></pre><ul>
<li><code>client.actions.list([page, perPage], [callback])</code></li>
<li><code>client.actions.get([queryObject], [callback])</code></li>
<li><code>client.actions.get(action.id, [callback])</code></li>
</ul>
<h3>Block Storage/Volume resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.volumes</code></pre><ul>
<li><code>client.volumes.list([page, perPage], [callback])</code></li>
<li><code>client.volumes.list([queryObject], [callback])</code></li>
<li><code>client.volumes.get(volume.id, [callback])</code></li>
<li><code>client.volumes.create(attributes, [callback])</code></li>
<li><code>client.volumes.delete(volume.id, [callback])</code></li>
<li><code>client.volumes.listActions([page, perPage], [callback])</code></li>
<li><code>client.volumes.listActions([queryObject], [callback])</code></li>
<li><code>client.volumes.getAction(volume.id, action.id, [callback])</code></li>
</ul>
<p>Methods resulting in an <code>action</code>:</p>
<ul>
<li><code>client.volumes.attach(volume.id, parametersOrDropletId, [callback])</code></li>
<li><code>client.volumes.detach(volume.id, [callback])</code></li>
<li><code>client.volumes.resize(volume.id, parametersOrSizeGibabytes, region, [callback])</code></li>
</ul>
<p>For the latest valid volume attributes and action parameters, <a href="https://developers.digitalocean.com/documentation/v2/#volumes">see the official docs</a>.</p>
<h3>Certificate resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.certificates</code></pre><ul>
<li><code>client.certificates.list([page, perPage], [callback])</code></li>
<li><code>client.certificates.list([queryObject], [callback])</code></li>
<li><code>client.certificates.get(certificate.id, [callback])</code></li>
<li><code>client.certificates.create(attributes, [callback])</code></li>
<li><code>client.certificates.delete(certificate.id, [callback])</code></li>
</ul>
<p>For the latest valid certificate attributes, <a href="https://developers.digitalocean.com/documentation/v2/#certificates">see the official docs</a>.</p>
<h3>Domain resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.domains</code></pre><ul>
<li><code>client.domains.list([page, perPage,] [callback])</code></li>
<li><code>client.domains.list([queryObject,] [callback])</code></li>
<li><code>client.domains.create(attributes, [callback])</code></li>
<li><code>client.domains.get(domain.name, [callback])</code></li>
<li><code>client.domains.delete(domain.name, [callback])</code></li>
<li><code>client.domains.listRecords([page, perPage,] domain.name, [callback])</code></li>
<li><code>client.domains.listRecords([queryObject,] domain.name, [callback])</code></li>
<li><code>client.domains.createRecord(domain.name, attributes, [callback])</code></li>
<li><code>client.domains.getRecord(domain.name, domainRecord.id, [callback])</code></li>
<li><code>client.domains.deleteRecord(domain.name, domainRecord.id, [callback])</code></li>
<li><code>client.domains.updateRecord(domain.name, domainRecord.id,, attributes, [callback])</code></li>
</ul>
<p>For the latest valid domain attributes, <a href="https://developers.digitalocean.com/documentation/v2/#domains">see the official docs</a>. For the latest valid domain record attributes, <a href="https://developers.digitalocean.com/documentation/v2/#domain-records">see the official docs</a>.</p>
<h3>Droplet resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.droplets</code></pre><ul>
<li><code>client.droplets.list([page, perPage,] [callback])</code></li>
<li><code>client.droplets.list([queryObject,] [callback])</code></li>
<li><code>client.droplets.get(droplet.id, [callback])</code></li>
<li><code>client.droplets.create(attributes, [callback])</code></li>
<li><code>client.droplets.delete(droplet.id, [callback])</code></li>
<li><code>client.droplets.deleteByTag(tag.name, [callback])</code></li>
<li><code>client.droplets.kernels(droplet.id, [page, perPage,] [callback])</code></li>
<li><code>client.droplets.kernels(droplet.id, [queryObject,] [callback])</code></li>
<li><code>client.droplets.snapshots(droplet.id, [page, perPage,] [callback])</code></li>
<li><code>client.droplets.snapshots(droplet.id, [queryObject,] [callback])</code></li>
<li><code>client.droplets.backups(droplet.id, [page, perPage,] [callback])</code></li>
<li><code>client.droplets.backups(droplet.id, [queryObject,] [callback])</code></li>
<li><code>client.droplets.neighbors(droplet.id, [page, perPage,] [callback])</code></li>
<li><code>client.droplets.neighbors(droplet.id, [queryObject,] [callback])</code></li>
<li><code>client.droplets.listActions(droplet.id, [page, perPage,] [callback])</code></li>
<li><code>client.droplets.listActions(droplet.id, [queryObject,] [callback])</code></li>
<li><code>client.droplets.getAction(droplet.id, action.id, [callback])</code></li>
</ul>
<p>Methods resulting in an <code>action</code>:</p>
<ul>
<li><code>client.droplets.actionByTag(tag.name, actionType, [callback])</code></li>
<li><code>client.droplets.reboot(droplet.id, [callback])</code></li>
<li><code>client.droplets.powerCycle(droplet.id, [callback])</code></li>
<li><code>client.droplets.shutdown(droplet.id, [callback])</code></li>
<li><code>client.droplets.powerOff(droplet.id, [callback])</code></li>
<li><code>client.droplets.powerOn(droplet.id, [callback])</code></li>
<li><code>client.droplets.passwordReset(droplet.id, [callback])</code></li>
<li><code>client.droplets.enableIpv6(droplet.id, [callback])</code></li>
<li><code>client.droplets.enableBackups(droplet.id, [callback])</code></li>
<li><code>client.droplets.disableBackups(droplet.id, [callback])</code></li>
<li><code>client.droplets.enablePrivateNetworking(droplet.id, [callback])</code></li>
<li><code>client.droplets.snapshot(droplet.id, parametersOrName, [callback])</code></li>
<li><code>client.droplets.changeKernel(droplet.id, parametersOrKernelId, [callback])</code></li>
<li><code>client.droplets.rename(droplet.id, parametersOrHostname, [callback])</code></li>
<li><code>client.droplets.rebuild(droplet.id, parametersOrImage, [callback])</code></li>
<li><code>client.droplets.restore(droplet.id, parametersOrImageId, [callback])</code></li>
<li><code>client.droplets.resize(droplet.id, parametersOrSizeSlug, [callback])</code></li>
</ul>
<p>For the latest valid droplet attributes, <a href="https://developers.digitalocean.com/documentation/v2/#droplets">see the official docs</a>. For the latest valid droplet action parameters, <a href="https://developers.digitalocean.com/documentation/v2/#droplet-actions">see the official docs</a>.</p>
<h3>Floating IP resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.floatingIps</code></pre><ul>
<li><code>client.floatingIps.list([page, perPage], [callback])</code></li>
<li><code>client.floatingIps.list([queryObject], [callback])</code></li>
<li><code>client.floatingIps.get(floatingIp.ip, [callback])</code></li>
<li><code>client.floatingIps.create(attributes, [callback])</code></li>
<li><code>client.floatingIps.delete(floatingIp.ip, [callback])</code></li>
<li><code>client.floatingIps.listActions(floatingIp.ip, [page, perPage], [callback])</code></li>
<li><code>client.floatingIps.listActions(floatingIp.ip, [queryObject], [callback])</code></li>
<li><code>client.floatingIps.getAction(floatingIp.ip, [callback])</code></li>
</ul>
<p>Methods resulting in an <code>action</code>:</p>
<ul>
<li><code>client.floatingIps.assign(floatingIp.ip, parametersOrDropletId, [callback])</code></li>
<li><code>client.floatingIps.unassign(floatingIp.ip, [callback])</code></li>
</ul>
<p>For the latest valid attributes, <a href="https://developers.digitalocean.com/documentation/v2/#floating-ips">see the official docs</a>.</p>
<h3>Firewall resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.firewalls</code></pre><ul>
<li><code>client.firewalls.list([page, perPage], [callback])</code></li>
<li><code>client.firewalls.list([queryObject], [callback])</code></li>
<li><code>client.firewalls.get(firewall.id, [callback])</code></li>
<li><code>client.firewalls.create(attributes, [callback])</code></li>
<li><code>client.firewalls.delete(firewall.id, [callback])</code></li>
<li><code>client.firewalls.update(firewall.id, attributes, [callback])</code></li>
<li><code>client.firewalls.addDroplets(firewall.id, dropletIds, [callback])</code></li>
<li><code>client.firewalls.removeDroplets(firewall.id, dropletIds, [callback])</code></li>
<li><code>client.firewalls.addTags(firewall.id, tags, [callback])</code></li>
<li><code>client.firewalls.removeTags(firewall.id, tags, [callback])</code></li>
<li><code>client.firewalls.addRules(firewall.id, rules, [callback])</code></li>
<li><code>client.firewalls.removeRules(firewall.id, rules, [callback])</code></li>
</ul>
<h3>Image resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.images</code></pre><ul>
<li><code>client.images.list([page, perPage], [callback])</code></li>
<li><code>client.images.list([queryObject], [callback])</code></li>
<li><code>client.images.get(image.id, [callback])</code></li>
<li><code>client.images.delete(image.id, [callback])</code></li>
<li><code>client.images.update(image.id, attributes, [callback])</code></li>
<li><code>client.images.listActions(image.id, [page, perPage], [callback])</code></li>
<li><code>client.images.listActions(image.id, [queryObject], [callback])</code></li>
<li><code>client.images.getAction(image.id, action.id, [callback])</code></li>
</ul>
<p>Methods resulting in an <code>action</code>:</p>
<ul>
<li><code>client.images.transfer(image.id, parametersOrRegionSlug, [callback])</code></li>
<li><code>client.images.convert(image.id, [callback])</code></li>
</ul>
<p>For the latest valid attributes, <a href="https://developers.digitalocean.com/documentation/v2/#images">see the official docs</a>.</p>
<h3>Load Balancer resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.loadBalancers</code></pre><ul>
<li><code>client.loadBalancers.list([page, perPage], [callback])</code></li>
<li><code>client.loadBalancers.list([queryObject], [callback])</code></li>
<li><code>client.loadBalancers.get(loadBalancer.id, [callback])</code></li>
<li><code>client.loadBalancers.update(loadBalancer.id, attributes, [callback])</code></li>
<li><code>client.loadBalancers.delete(loadBalancer.id, [callback])</code></li>
<li><code>client.loadBalancers.add(loadBalancer.id, parametersOrIds, [callback])</code></li>
<li><code>client.loadBalancers.remove(loadBalancer.id, parametersOrIds, [callback])</code></li>
<li><code>client.loadBalancers.createForwardingRules(loadBalancer.id, parametersOrRules, [callback])</code></li>
<li><code>client.loadBalancers.deleteForwardingRules(loadBalancer.id, parametersOrRules, [callback])</code></li>
</ul>
<p>For the latest valid attributes and parameters, <a href="https://developers.digitalocean.com/documentation/v2/#load-balancers">see the official docs</a>.</p>
<h3>Region resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.regions</code></pre><ul>
<li><code>client.regions.list([page, perPage], [callback])</code></li>
<li><code>client.regions.list([queryObject], [callback])</code></li>
</ul>
<h3>Size resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.sizes</code></pre><ul>
<li><code>client.sizes.list([page, perPage], [callback])</code></li>
<li><code>client.sizes.list([queryObject], [callback])</code></li>
</ul>
<h3>Snapshot resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.snapshots</code></pre><ul>
<li><code>client.snapshots.list([page, perPage], [callback])</code></li>
<li><code>client.snapshots.list([queryObject], [callback])</code></li>
<li><code>client.snapshots.get(snapshots.id, [callback])</code></li>
<li><code>client.snapshots.delete(snapshot.id, [callback])</code></li>
</ul>
<h3>Tag resource</h3><pre class="prettyprint source lang-js"><code>var digitalocean = require('digitalocean');
var client = digitalocean.client('TOKEN');
client.tags</code></pre><ul>
<li><code>client.tags.list([page, perPage], [callback])</code></li>
<li><code>client.tags.list([queryObject], [callback])</code></li>
<li><code>client.tags.get(tag.name, [callback])</code></li>
<li><code>client.tags.create(attributes, [callback])</code></li>
<li><code>client.tags.update(tag.name, attributes, [callback])</code></li>
<li><code>client.tags.tag(tag.name, [resources], [callback])</code></li>
<li><code>client.tags.untag(tag.name, [resources], [callback])</code></li>
<li><code>client.tags.delete(tag.name, [callback])</code></li>
</ul>
<p>For the latest valid attributes, <a href="https://developers.digitalocean.com/documentation/v2/#tags">see the official docs</a>.</p>
<h2>Contributing</h2><ol>
<li>Fork it ( https://github.com/phillbaker/digitalocean-node/fork )</li>
<li>Create your feature branch (<code>git checkout -b my-new-feature</code>)</li>
<li>Commit your changes (<code>git commit -am 'Add some feature'</code>)</li>
<li>Push to the branch (<code>git push origin my-new-feature</code>)</li>
<li>Create new Pull Request</li>
</ol>
<h2>Testing</h2><pre class="prettyprint source"><code>npm test</code></pre><h2>Releasing</h2><p>Run:</p>
<pre class="prettyprint source lang-sh"><code>npm run release:patch # or release:minor or release:major depending on the type of version bump</code></pre><h2>License</h2><p>MIT</p>
<h2>Inspiration</h2><p>Based on the work of @pksunkara in <a href="https://github.com/pksunkara/octonode">octonode</a>.</p></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Account.html">Account</a></li><li><a href="Action.html">Action</a></li><li><a href="Certificate.html">Certificate</a></li><li><a href="Client.html">Client</a></li><li><a href="Domain.html">Domain</a></li><li><a href="Droplet.html">Droplet</a></li><li><a href="Firewall.html">Firewall</a></li><li><a href="FloatingIp.html">FloatingIp</a></li><li><a href="Image.html">Image</a></li><li><a href="ListResponse.html">ListResponse</a></li><li><a href="LoadBalancer.html">LoadBalancer</a></li><li><a href="Region.html">Region</a></li><li><a href="Size.html">Size</a></li><li><a href="Snapshot.html">Snapshot</a></li><li><a href="Tag.html">Tag</a></li><li><a href="Volume.html">Volume</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>