Skip to content

Commit

Permalink
Merge pull request #8 from erulabs/0.2
Browse files Browse the repository at this point in the history
0.2
  • Loading branch information
erulabs committed Apr 27, 2014
2 parents 0afdf4a + 0e182ac commit 3a12645
Show file tree
Hide file tree
Showing 24 changed files with 2,262 additions and 1,567 deletions.
4 changes: 2 additions & 2 deletions .gitignore
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
/node_modules
node_modules
npm-debug.log
.racksjs
.racksjs
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- 0.10

notifications:
email: "seandon.mooy@gmail.com"

env:
global:
- secure: "nIiLEnJdo6fyrcDs9g6wouOY6sb1ksAtw8GxmMw68BVjsPDmSLlO/1A8222UU/t3Cd47Jn/1fO6BxPRx7xBowCDTNs5YazUUc1RATRepW/jssQeLVJc0iGxx85hfgFVZSVrdYCF3Oa8aYSzPKJTgSeGDZiIvkqJ+5p2OG4sj1tY="
- secure: "b5Ez39ER0Xj+SomxeswoDgVh9tGqvEPGv98M9gnpGkzfXlOHDqojiGwycOqP9Lvp0+jmCso43Ihbi2l2Nx2LcJcKJyxygQuxHV2OVpNhwxincyVcJcVxPxINYk4PgbLF+94doW6sLzIJxuAmh89MAHwvPs7exYhOBT7+G+H+JrA="
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test-all:
@./node_modules/.bin/mocha -t 10000 -R spec

.PHONY: test-all
123 changes: 75 additions & 48 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,62 +1,89 @@
# Racks.js
### a javascript SDK for the Rackspace Cloud
Racks.js [![Build Status](https://travis-ci.org/erulabs/racksjs.png?branch=0.2)](https://travis-ci.org/erulabs/racksjs)
=======
__An unoffical javascript SDK for the Rackspace Cloud__

by Seandon Mooy with contributions from Matt Ellsworth

### About / News
### About / News ###

Racksjs is mostly an attempt by the author to get intimate with the Rackspace API. It's also quite nice to script with - particularly because it doesn't invent any vocabulary - it simply wraps the rackspace api documentation as closely as possible.

Proper documentation and a lot more examples are soon to come - we're still missing a lot of functionality, but that too is on its way! For now, here is some example code:

### Usage
// Include racks.js and start it with a few settings
new (require('../racks.js'))({
username: 'Rackspace cloud username',
apiKey: 'Rackspace cloud API KEY',
verbosity: 1, // 0 - 5, 0 is no output, 1 is script only (rs.log), 5 is debug.
}, function (rs) {
// Log the error and stop if we fail to authenticate
if (rs.error) return rs.log(rs.error);
//
// You can find details about all the products and their resources by diving into RacksJS.products object.
// If you're familiar with docs.rackspace.com, the "product -> resource -> action" concept
// shouldn't seem strange. With the docs in mind, you'll start to guess at products:
// rs.cloudServersOpenStack.servers ... .networks ... .flavors
// rs.cloudLoadBalancers.loadBalancers
// rs.cloudFiles.containers
// RacksJS provides shortcuts as well, which should be easy to guess: rs.servers, rs.clbs, rs.cf...
// each "resource" (containers, servers) belongs to one "product" (cloudLoadBalancers)
// and each resource has some common functionality: .all(), .find(), and sometimes .new().
// there are often other, resource specific functions. (and sometimes product functions!)
// read the docs, the racks.js code, or console.log(resource);
//
// Below I will try to illistrate some example Racks.js code. For brand new stuff,
// check tests/generic.js
//
//
// shorthand for: RacksJS.cloudFiles.containers.all()
rs.cf.all(function (containers){
rs.log(containers);
### Usage ###
```html
// Include racks.js and start it with a few settings
new (require('../racks.js'))({
username: 'Rackspace cloud username',
apiKey: 'Rackspace cloud API KEY',
verbosity: 1, // 0 - 5, 0 is no output, 1 is script only (rs.log), 5 is debug.
}, function (rs) {
// Log the error and stop if we fail to authenticate
if (rs.error) return rs.log(rs.error);

// Get a list of all images:
rs.cloudServersOpenStack.images.all( function( anArrayOfAllImages ) {
...
});

// Create a new server:
rs.cloudServersOpenStack.servers.new({
'name': 'racksjs_test',
'flavorRef': 'performance1-1',
'imageRef': 'f70ed7c7-b42e-4d77-83d8-40fa29825b85',
}, function (server) {
// Since servers aren't ready right away, you need to poll until they're complete
// Racksjs provides helper functions for this:
server.systemActive(function () {
// systemAction fires once the server is fully built
server.reboot();
});
// Do something to every OpenStack (NextGen) server
// Keep in mind, rs.cloudServersOpenStack.servers is the same as rs.servers (it's the full product -> resource!)
rs.cloudServersOpenStack.servers.all(function(servers){
servers.forEach(function (server) {
// These very closely match: http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Servers-d1e2073.html
server.updateMetadata ...
server.reboot ...
// Method names are aimed at matching the documentation exactly: http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Addresses-d1e3014.html
server.addresses ...
});
});

// You can find details about all the products and their resources by diving into
// the RacksJS.products object. If you're familiar with docs.rackspace.com,
// the "product.resource.action" concept shouldn't seem strange:
// rs.cloudServersOpenStack.servers
// rs.cloudLoadBalancers.loadBalancers
// rs.cloudFiles.containers
// and so on
//
// RacksJS provides shortcuts as wel: rs.servers, rs.clbs, rs.cf...
// each "resource" (containers, servers) belongs to one "product" (cloudLoadBalancers)
// and each resource has some common functionality: .all(), .find(), and sometimes .new().
// there are often other, resource specific functions. (and sometimes product functions!)
// read the docs, the racks.js code, or console.log(resource);
//
// Below I will try to illistrate some example Racks.js code. For brand new stuff,
// check tests/generic.js
//
//
// shorthand for: RacksJS.cloudFiles.containers.all()
rs.cf.all(function (containers){
rs.log(containers);
});
// Do something to every OpenStack (NextGen) server
// Keep in mind, rs.cloudServersOpenStack.servers is the same as rs.servers
rs.cloudServersOpenStack.servers.all(function(servers){
servers.forEach(function (server) {
// These very closely match:
// http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Servers-d1e2073.html
server.updateMetadata ...
server.reboot ...
// Method names are aimed at matching the documentation exactly:
// http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Addresses-d1e3014.html
server.addresses ...
});
// Many other resources live in various products. For instance:
rs.cloudServersOpenStack.images.all(function (images) {});
// When in doubt about the naming convention, the rackspace API documentation ought to help,
// However, RackJS is incomplete. I recommend checking out our product catalog in racks.js:
// RacksJS.prototype.buildCatalog() contains all product and resource information
});
// Many other resources live in various products. For instance:
rs.cloudServersOpenStack.images.all(function (images) {});
// When in doubt about the naming convention, the rackspace API documentation ought to help,
// However, RackJS is incomplete. I recommend checking out our product catalog in racks.js:
// RacksJS.prototype.buildCatalog() contains all product and resource information
});
```

### Important info
### Important info ###
This repo is not an official rackspace SDK and as such don't expect anyone to support it! (outside of this github). Unless you're messing around with experimental code, I highly recommend using nodejitsu's pkgcloud.

Feel free to issue pull requests :) Thanks!
Expand Down
Loading

0 comments on commit 3a12645

Please sign in to comment.