Permalink
Browse files

add streaming alias functions

  • Loading branch information...
tellnes committed Apr 26, 2012
1 parent 5c43318 commit 698a5ffdac6f28496e6bdc304b81b8864c18d509
Showing with 62 additions and 0 deletions.
  1. +11 −0 examples/listStreamingDistributions.js
  2. +51 −0 lib/index.js
@@ -0,0 +1,11 @@
+var cloudfront = require('..');
+
+var cf = cloudfront.createClient(process.env.AWS_KEY, process.env.AWS_SECRET);
+
+cf.listStreamingDistributions(function(err, list, info) {
+ if (err) {
+ console.error(err);
+ } else {
+ console.log(list);
+ }
+});
View
@@ -94,6 +94,23 @@ function itemFactory(that, DataConstr, opts, cb) {
};
}
+function getOptions(args, count, optName) {
+ var opts, len = args.length;
+ if (len === count) {
+ opts = args[len-2];
+ } else {
+ opts = {};
+
+ if (optName) {
+ opts[optName] = args[len-2];
+ }
+ }
+
+ opts.cb = args[args.length-1];
+
+ return opts;
+}
+
function toUnixTime(time) {
if (Number(time) == time) {
time = Number(time);
@@ -576,6 +593,40 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
};
+CloudFront.prototype.createStreamingDistribution = function(config, callerReference, cb) {
+ config.streaming = true;
+ this.createDistribution.apply(this, arguments);
+};
+
+CloudFront.prototype.getStreamingDistribution = function(a) {
+ var opts = getOptions(arguments, 3);
+ opts.streaming = true;
+ this.getDistribution(a, opts, opts.cb);
+};
+
+CloudFront.prototype.getStreamingDistributionConfig = function(a) {
+ var opts = getOptions(arguments, 3);
+ opts.streaming = true;
+ this.getDistributionConfig(a, opts, opts.cb);
+};
+
+CloudFront.prototype.setStreamingDistributionConfig = function(distribution, config, etag, cb) {
+ config.streaming = true;
+ this.setDistributionConfig.apply(this, arguments);
+};
+
+CloudFront.prototype.listStreamingDistributions = function() {
+ var opts = getOptions(arguments, 2);
+ opts.streaming = true;
+ this.listDistributions(opts, opts.cb);
+};
+
+CloudFront.prototype.deleteStreamingDistribution = function(a, b) {
+ var opts = getOptions(arguments, 4);
+ opts.streaming = true;
+ this.deleteDistribution(a, b, opts, opts.cb);
+};
+
function CFObject(client) {
Object.defineProperty(this, 'client', {

0 comments on commit 698a5ff

Please sign in to comment.