1.0.0 • Published 8 years ago

digitalocean-droplet-sdk v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

DigitalOcean-Droplet-SDK

Build Status Coverage Status Known Vulnerabilities

A simple interface to get metadata about a DigitalOcean Droplet.

Install

npm install digitalocean-droplet-sdk --save

Usage

DigitalOcean-Droplet-SDK was designed to provide a simple and easy to use interface to get metadata about the droplet that it is running on. You can chose to either request the entire metadata for a droplet, or specific values from the metadata.

Request all metadata

var dropletSDK = require('digitalocean-droplet-sdk');

dropletSDK.getMetadata().then(function(metadata) {
	/* do something with the result */
}).catch(function() {
	/* error :( */
})

Request IPv4 Private IP Addresses

var dropletSDK = require('digitalocean-droplet-sdk');

dropletSDK.getPrivateIP4Addresses().then(function(ipAddresses) {
	/* do something with the result */
}).catch(function() {
	/* error :( */
})

All available methods

FunctionDescriptionType
getMetadata()Returns all the metadata for the droplet see the DigitalOcean guides for moreJSON
getID()Returns the id of the dropletNumber
getVendorData()Returns the vendor data about the dropletString
getAuthKey()Returns the Auth KeyString
getHostName()Returns the hostname/name of the dropletString
getName()Returns the hostname/name of the dropletString
getPublicKeysList of public ssh keys that have been added to the dropletArray<String>
getRegion()Returns the region of the dropletString
getInterfaces()Returns both the public and private interfaces for the droplet. This is in the form of an object with two values; 'public' and 'private' which in turn contain arrays of respective interfaces (see format below)JSON
getPrivateInterfaces()Returns an array of the private interfaces for the droplet (see format below)JSON
getPrivateIP4Addresses()Returns an array of the private ipv4 addresses as stringsArray<String>
getPrivateIP6Addresses()Returns an array of the private ipv6 addresses as stringsArray<String>
getPrivateMacAddresses()Returns an array of the private MAC addresses as stringsArray<String>
getPublicInterfaces()Returns an array of the public interfaces for the droplet (see format below)JSON
getPublicIP4Addresses()Returns an array of the public ipv4 addresses as stringsArray<String>
getPublicIP6Addresses()Returns an array of the public ipv6 addresses as stringsArray<String>
getPublicMacAddresses()Returns an array of the public MAC addresses as stringsArray<String>
hasFloatingIP()Returns whether or not the droplet has a floating ipBoolean
getFloatingIP()Returns a string representation of the droplet floating ip if it has one, if it does not it will return a string of length 0String
getDNS()Returns an array of strings of the name servers for this dropletArray<String>
getNameServers()Returns an array of strings of the name servers for this dropletArray<String>
getTags()Returns an array of strings of the tags for this dropletArray<String>

If you feel there are any missing methods please create an issue for it on GitHub.

Example Of Interface JSON
{
  'ipv4':{
    'ip_address':'10.132.255.114',
    'netmask':'255.255.0.0',
    'gateway':'10.132.0.1',
  },
  'ipv6':{
    'ip_address':'2604:A880:0800:0010:0000:0000:017D:2001',
    'cidr':64,
    'gateway':'2604:A880:0800:0010:0000:0000:0000:0001',
  },
  'mac':'04:01:2a:0f:2a:02',
  'type':'private',
}