π Unofficial Node.js SDK for Rackspace Cloud Servers API v2.0
The SDK is still in alpha
stage of development and not at all production ready. I am still playing around with the original documentation and doing a lotta hit 'n trial. Feel free to clone/fork and join in. Create an issue or drop a PR, if you feel something is wrong or could be done in a better way. Happy to take 'em all up! βοΈ
git clone https://github.com/Cheesetouched/rackspace-node.git
All rackspace resources are accessed via an instance of the client. It is important to authorize the client first, like shown below. On successful authorization, your token_id & tenant_id gets saved in the client object and is used wherever necessary, automagically. So no need to repeat authorization before each call. π
const Rackspace = require('../rackspace-node');
const client = new Rackspace.createClient({
username: 'your-rackspace-username',
apiKey: 'your-rackspace-api-key',
region: 'your-rackspace-region'
});
client.authorize(done => {
client.server.list(servers => {
console.log(servers);
});
});
NOTE: console.log(done)
above to retrieve your token_id & tenant_id if you wish.
Every resource method accepts an optional callback as the last argument. If the callback argument is provided, it gets populated with the response. Otherwise, the response gets logged.
// Response gets logged
client.server.list();
// Response is in 'servers'
client.server.list((servers) => {
// Do your thing here
});
All errors are thrown by a custom handler called RackspaceError.
Error Format: [RackspaceError: Error Message]
Format: client.resource.method()
Example: client.server.list()
All resources, along with the methods names are given below. π
All given resources and methods correspond to the resources and methods given in Rackspace Cloud Servers API v2.0. Some of the methods expect custom parameters as a JavaScript object, e.g. { key: 'value' }
, where the keys and values also correspond to the same in Rackspace documentation.
These are the resources that are currently available in this SDK. Each method operation has an example attached to it. If you're confused, check those out for a better picture. I'll be adding more resources and examples eventually. Keep an eye out. π
client.authorize(done => {
client.server;
});
client.server.list([callback])
client.server.create(params, [callback])
client.server.delete(server_id, [callback])
client.server.showDetails(server_id, [callback])
client.server.update(server_id, params, [callback])
- Fork this repository
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a pull request
That's all folks! β€οΈ