Navigation Menu

Skip to content

Commit

Permalink
Added new EC2 methods: allocateAddress and releaseAddress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Ryan Moore committed May 4, 2011
1 parent ea55647 commit 7d1402a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ec2.js
Expand Up @@ -7,7 +7,9 @@ var
var version = module.exports.version = '2011-02-28';
var xmlns = module.exports.xmlns = 'http://ec2.amazonaws.com/doc/' + version + '/';
var methods = module.exports.methods = {
'allocateAddress': true,
'describeAddresses': true,
'releaseAddress': true,
}

/**
Expand Down
36 changes: 36 additions & 0 deletions lib/ec2/allocateAddress.js
@@ -0,0 +1,36 @@
var
util = require('util'),
ec2 = require('../ec2'),
aws = require('../aws'),
_ = require('../util');

/**
* GET AllocateAddress
*/
var Request = module.exports.Request = function(args) {
ec2.Request.call(this, args, 'AllocateAddress');

var self = this;

if (null != args.domain) {
self._query['Domain'] = _.asString(args.domain);
}
}

util.inherits(Request, ec2.Request);

/**
* AllocateAddressResponse
*/
var Response = module.exports.Response = function(response) {
ec2.Response.call(this, response);

var self = this;
var response = _.xmlToJson(self._xml.get('/AllocateAddressResponse'));
self.publicIp = response.publicIp;
self.domain = response.domain;
self.allocationId = response.allocationId;

}

util.inherits(Response, ec2.Response);
38 changes: 38 additions & 0 deletions lib/ec2/releaseAddress.js
@@ -0,0 +1,38 @@
var
util = require('util'),
ec2 = require('../ec2'),
aws = require('../aws'),
_ = require('../util');

/**
* GET ReleaseAddress
*/
var Request = module.exports.Request = function(args) {
ec2.Request.call(this, args, 'ReleaseAddress');

var self = this;

if (null != args.publicIp) {
self._query['PublicIp'] = _.asString(args.publicIp);
}

if (null != args.allocationId) {
self._query['AllocationId'] = _.asString(args.allocationId);
}
}

util.inherits(Request, ec2.Request);

/**
* ReleaseAddressResponse
*/
var Response = module.exports.Response = function(response) {
ec2.Response.call(this, response);

var self = this;
var response = _.xmlToJson(self._xml.get('/ReleaseAddressResponse'));
self.return = _.asBoolean(response.return);

}

util.inherits(Response, ec2.Response);

0 comments on commit 7d1402a

Please sign in to comment.