WARNING: project is no longer actively maintained, make sure to update any dependencies if you plan on using this in your project.
Node.JS Promise-based library to communicate with the Vultr API
Test coverage is currently 100%, although some tests involving actually creating the VPS's itself are currently not tested.
This library creates a new instance of "Vultr" for you, exposing a few libraries and methods you can use to communicate.
To start a new Vultr instance:
var Vultr = require('vultr');
var vultrInstance = new Vultr(apiKey);
apiKey
is your Vultr API key.
You can generate a Vultr API key from the Settings
page.
It's safe for you to run the integration tests, simply copy config/data.example.js
to config/data.js
and fill out your real API key. Run npm test
to run the tests.
vultrInstance.account.info().then(function(info) {
// Returns Object with account info
})
vultrInstance.dns.list().then(function(list) {
// Returns array with DNS entries
})
vultrInstance.dns.createDomain('dualdev.com')
vultrInstance.dns.createRecord({
'domain': 'dualdev.com',
'name': 'test',
'type': 'A',
'data': '127.0.0.1'
})
vultrInstance.dns.records('dualdev.com').then(function(list) {
// Returns array with DNS entries
})
vultrInstance.dns.deleteRecord({
'domain': 'dualdev.com',
'id': id
})
vultrInstance.dns.deleteDomain('dualdev.com');
vultrInstance.os.list().then(function(list) {
// Returns array with OS objects
})
vultrInstance.iso.list().then(function(list) {
// Returns array with ISO objects
})
vultrInstance.iso.createFromUrl().then(function(list) {
// Returns Object with ISO upload status
})
vultrInstance.backup.list().then(function(list) {
// Returns array with Backup objects
})
vultrInstance.plans.list().then(function(list) {
// Returns array with PLAN objects
})
vultrInstance.regions.list().then(function(list) {
// Returns array of REGION objects
})
Retrieve a list of the VPSPLANIDs currently available in this location. (DCID can be retrieved from vultrInstance.regions.list()
)
vultrInstance.regions.availability(DCID).then(function(plans) {
// Returns array of PLAN objects
})
vultrInstance.server.list().then(function(list) {
// Returns array of vps's
})
SUBID
is the VPS ID
vultrInstance.server.bandwidth(SUBID).then(function(bandwidth) {
// Returns bandwidth objects
})
SUBID
is the VPS ID
vultrInstance.server.reboot(SUBID)
SUBID
is the VPS ID
vultrInstance.server.halt(SUBID)
SUBID
is the VPS ID. This function also RESTARTS an already running VPS.
vultrInstance.server.start(SUBID)
SUBID
is the VPS ID
vultrInstance.server.destroy(SUBID)
SUBID
is the VPS ID
vultrInstance.server.reinstall(SUBID)
SUBID
is the VPS ID. SNAPSHOTID
can be retrieved from vultrInstance.snapshot.list()
.
vultrInstance.server.restoreSnapshot(SUBID, SNAPSHOTID)
SUBID
is the VPS ID. BACKUPID
cannot be retrieved yet (asked Vultr support about this).
vultrInstance.server.restoreSnapshot(SUBID, BACKUPID)
create
returns SUBID
, this is used in many other calls. PLAN, OS and REGION can be retrieved from the services offering the same name.
vultrInstance.server.create({
'plan': PLAN,
'os': OS,
'region': REGION
})
SUBID
is the VPS ID.
vultrInstance.server.listIpv4(SUBID).then(function(list) {
// Returns object of ipv4 addresses
})
SUBID
is the VPS ID.
vultrInstance.server.reverseSetIpv4(SUBID, IP, ENTRY)
SUBID
is the VPS ID.
vultrInstance.server.reverseDefaultIpv4(SUBID, IP)
SUBID
is the VPS ID.
vultrInstance.server.listIpv6(SUBID).then(function(list) {
// Returns object of ipv6 addresses
})
SUBID
is the VPS ID.
vultrInstance.server.reverseSetIpv6(SUBID, IP, ENTRY)
SUBID
is the VPS ID.
vultrInstance.server.reverseListIpv6(SUBID).then(function(list) {
// Returns object of reverse ipv6 entries
})
SUBID
is the VPS ID.
vultrInstance.server.reverseDeleteIpv6(SUBID, IP)
SUBID
is the VPS ID. LABEL
is a string
of your choosing.
vultrInstance.server.setLabel(SUBID, LABEL)
SUBID
is the VPS ID. The second argument is "yes" or "no" to trigger a reboot.
vultrInstance.server.createIpv4(SUBID, 'no')
SUBID
is the VPS ID. The second argument is "yes" or "no" to trigger a reboot.
vultrInstance.server.destroyIpv4(SUBID, 'no')
SUBID
is the VPS ID.
vultrInstance.server.osChangeList(SUBID).then(function(list) {
// Returns object of available OS's
})
SUBID
is the VPS ID.
vultrInstance.server.osChange(SUBID, OSID)
SUBID
is the VPS ID.
vultrInstance.server.upgradePlanlist(SUBID).then(function(list) {
// Returns object of available upgrade plans
})
SUBID
is the VPS ID.
vultrInstance.server.upgradePlan(SUBID, PLANID)
vultrInstance.snapshot.list().then(function(list) {
// Returns array of snapshot objects
})
SUBID
is the VPS ID. DESCRIPTION
is an optional description for this snapshot.
vultrInstance.snapshot.create(SUBID, DESCRIPTION)
SNAPSHOTID
can be retrieved from vultrInstance.snapshopt.list()
.
vultrInstance.snapshot.destroy(SNAPSHOTID)
vultrInstance.sshkey.list().then(function(list) {
// Returns array of sshkey objects
})
vultrInstance.sshkey.create(NAME, KEY)
SSHKEYID
can be retrieved from vultrInstance.sshkey.list()
or after calling vultrInstance.sshkey.create()
.
vultrInstance.sshkey.update(NAME, KEY, SSHKEYID)
SSHKEYID
can be retrieved from vultrInstance.sshkey.list()
or after calling vultrInstance.sshkey.create()
.
vultrInstance.sshkey.destroy(SSHKEYID)
vultrInstance.startupscript.list().then(function(list) {
// Returns array of startupscript objects
})
vultrInstance.startupscript.create(NAME, KEY)
SCRIPTID
can be retrieved from vultrInstance.startupscript.list()
or after calling vultrInstance.startupscript.create()
.
vultrInstance.startupscript.update(NAME, KEY, SCRIPTID)
SCRIPTID
can be retrieved from vultrInstance.startupscript.list()
or after calling vultrInstance.startupscript.create()
.
vultrInstance.startupscript.destroy(SCRIPTID)