Permalink
Browse files

Add Auto Scaling API support , example and unit test.

  • Loading branch information...
1 parent c65ab7f commit 13331e6ae131a8a218ca6f20684e5b03cb677b1c Mike MacCana committed Sep 13, 2012
Showing with 53 additions and 2 deletions.
  1. +1 −0 README.md
  2. +7 −0 examples/as.js
  3. +23 −0 lib/as.js
  4. +2 −0 lib/aws.js
  5. +3 −2 package.json
  6. +17 −0 test/as.js
View
@@ -96,4 +96,5 @@ Van Nguyen
Ian Ward
Johannes Auer
Chris Castle
+Mike MacCana
```
View
@@ -0,0 +1,7 @@
+var aws = require("../lib/aws");
+
+as = aws.createASlient(yourAccessKeyId, yourSecretAccessKey);
+
+as.call("DescribeAutoScalingGroups", {}, function(err, result) {
+ console.log(JSON.stringify(result));
+})
View
@@ -0,0 +1,23 @@
+
+exports.init = function(genericAWSClient) {
+ // Creates an AS (Auto Scaling) API client
+ var createASClient = function (accessKeyId, secretAccessKey, options) {
+ options = options || {};
+ var aws = genericAWSClient({
+ host: options.host || "autoscaling.amazonaws.com",
+ path: options.path || "/",
+ accessKeyId: accessKeyId,
+ secretAccessKey: secretAccessKey,
+ secure: options.secure
+ });
+ var callFn = function(action, query, callback) {
+ query["Action"] = action
+ query["Version"] = options.version || '2011-01-01'
+ query["SignatureMethod"] = "HmacSHA256"
+ query["SignatureVersion"] = "2"
+ return aws.call(action, query, callback);
+ }
+ return {call: callFn};
+ }
+ return createASClient;
+}
View
@@ -16,6 +16,7 @@ var elb = require("./elb");
var iam = require("./iam");
var sts = require("./sts");
var cw = require("./cw");
+var as = require("./as");
var cfn = require("./cfn");
// Returns the hmac digest using the SHA256 algorithm.
@@ -128,4 +129,5 @@ exports.createELBClient = elb.init(genericAWSClient);
exports.createIAMClient = iam.init(genericAWSClient);
exports.createSTSClient = sts.init(genericAWSClient);
exports.createCWClient = cw.init(genericAWSClient);
+exports.createASClient = as.init(genericAWSClient);
exports.createCFNClient = cfn.init(genericAWSClient);
View
@@ -3,14 +3,15 @@
"description": "Extensible Node.js library for the Amazon Web Services API",
"version": "0.1.2",
"homepage": "http://github.com/livelycode/aws-lib",
- "keywords": ["amazon","aws", "ec2", "product advertising", "simpledb", "Simple Queue Service", "SQS", "Simple Email Service", "SES"],
+ "keywords": ["amazon","aws", "ec2", "product advertising", "simpledb", "Simple Queue Service", "SQS", "Simple Email Service", "SES", "Auto Scaling", "AS"],
"repository": "git://github.com/livelycode/aws-lib.git",
"author": "Mirko Kiefer <mail@mirkokiefer.com> (http://mirkokiefer.com)",
"contributors": [
"Mirko Kiefer <mail@mirkokiefer.com> (http://mirkokiefer.com)",
"Paul Bonser <pib@paulbonser.com> (http://probablyprogramming.com)",
"Richard Rodger <richard@ricebridge.com> (http://www.ricebridge.com/)",
- "Ross Duggan <ross@boards.ie> (http://rossduggan.ie/)"
+ "Ross Duggan <ross@boards.ie> (http://rossduggan.ie/)",
+ "Mike MacCana <mike.maccana@gmail.com> (http://mikemaccana.com/)"
],
"dependencies": {
"xml2js": "0.1.x",
View
@@ -0,0 +1,17 @@
+
+assert = require('assert');
+aws = require('../lib/aws');
+credentials = require('./credentials');
+
+as = aws.createASClient(credentials.accessKeyId, credentials.secretAccessKey);
+
+describe('as', function() {
+ describe('DescribeAutoScalingGroups', function() {
+ it('should return a list to Auto Scaling groups', function(done) {
+ as.call("DescribeAutoScalingGroups", {}, function(err, res) {
+ assert.ok(res.DescribeAutoScalingGroupsResult);
+ done(err);
+ })
+ })
+ })
+})

0 comments on commit 13331e6

Please sign in to comment.