Skip to content

Cheesetouched/rackspace-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

rackspace-node

πŸš€ Unofficial Node.js SDK for Rackspace Cloud Servers API v2.0

Status

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! ✌️

Installation

git clone https://github.com/Cheesetouched/rackspace-node.git

Usage

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.

Callback arguments

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
});

Error handling

All errors are thrown by a custom handler called RackspaceError.

Error Format: [RackspaceError: Error Message]

General request

Format: client.resource.method()

Example: client.server.list()

All resources, along with the methods names are given below. πŸ‘‡

All Resources & Methods

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. πŸ‘€

Cloud Servers

client.authorize(done => {
    client.server;
});

Contributing

  1. Fork this repository
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a pull request

Fin

That's all folks! ❀️

About

πŸš€ Unofficial Node.js SDK for Rackspace Cloud Servers API v2.0

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published