conservatory-api
v1.0.3
Published
conservatory API client wrapper
Downloads
7
Readme
conservatory-api/node.js
The node.js conservatory-api library enables access to the RESTful API for conservatory
.
Example:
var conservatory = require('conservatory-api');
var client = conservatory.createClient({
host: 'api.nodejitsu.com',
port: 80,
auth: {
username: 'charlie',
password: 'foobar',
}
});
client.groups.list(function (err, result) {
if (err) {
console.log(err);
return;
}
console.log(JSON.stringify(result, null, 2, true));
});
Usage:
api.createClient(options)
This method sets up a client for connecting to conservatory
. Here's a minimal example for connecting to conservatory as charlie
:
var client = conservatory.createClient({
host: 'api.nodejitsu.com',
port: 80,
auth: {
username: 'charlie',
password: 'foobar',
}
});
The options object contains three required properties:
auth.username
: The username for your Nodejitsu accountauth.password
: The password for your Nodejitsu accounthost
: The api host (typically http://conservatory.nodejitsu.com.
client
Method calls are generally structured as resource
and action
.
client.resource.action("data", function (err, result) {
if (err) {
throw err;
}
//
// use the result
//
});
Most actions take a string argument and a callback, though a few actions only take a callback.
The client's methods are reflective of conservatory
resources. Here's a broad overview:
- client.servers: Manage your server instances. Methods include:
servers.provision
servers.getPosition
servers.free
servers.get
servers.list
servers.list
servers.listRole
servers.update
- client.groups: Manage your server groups. Methods include:
groups.get
groups.list
groups.listProvider
groups.update
groups.destroy
- client.users: Manage your conservatory accounts. Methods include:
users.create
users.get
users.list
users.update
users.destroy
users.getKey
users.getKeys
users.addKey
users.updateKey
Installation
This library may be installed using npm:
$ npm install nodejitsu-api
Tests
All tests are included in conservatory
to facilitate integration tests and to avoid the need for complex mocking.
License
Proprietary. Copyright (c) 2011 Nodejitsu Inc.