Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add streaming alias functions

  • Loading branch information...
commit 698a5ffdac6f28496e6bdc304b81b8864c18d509 1 parent 5c43318
Christian Tellnes authored

Showing 2 changed files with 62 additions and 0 deletions. Show diff stats Hide diff stats

  1. +11 0 examples/listStreamingDistributions.js
  2. +51 0 lib/index.js
11 examples/listStreamingDistributions.js
... ... @@ -0,0 +1,11 @@
  1 +var cloudfront = require('..');
  2 +
  3 +var cf = cloudfront.createClient(process.env.AWS_KEY, process.env.AWS_SECRET);
  4 +
  5 +cf.listStreamingDistributions(function(err, list, info) {
  6 + if (err) {
  7 + console.error(err);
  8 + } else {
  9 + console.log(list);
  10 + }
  11 +});
51 lib/index.js
@@ -94,6 +94,23 @@ function itemFactory(that, DataConstr, opts, cb) {
94 94 };
95 95 }
96 96
  97 +function getOptions(args, count, optName) {
  98 + var opts, len = args.length;
  99 + if (len === count) {
  100 + opts = args[len-2];
  101 + } else {
  102 + opts = {};
  103 +
  104 + if (optName) {
  105 + opts[optName] = args[len-2];
  106 + }
  107 + }
  108 +
  109 + opts.cb = args[args.length-1];
  110 +
  111 + return opts;
  112 +}
  113 +
97 114 function toUnixTime(time) {
98 115 if (Number(time) == time) {
99 116 time = Number(time);
@@ -576,6 +593,40 @@ CloudFront.prototype.getPrivateUrl = function(a, b, c, d) {
576 593
577 594 };
578 595
  596 +CloudFront.prototype.createStreamingDistribution = function(config, callerReference, cb) {
  597 + config.streaming = true;
  598 + this.createDistribution.apply(this, arguments);
  599 +};
  600 +
  601 +CloudFront.prototype.getStreamingDistribution = function(a) {
  602 + var opts = getOptions(arguments, 3);
  603 + opts.streaming = true;
  604 + this.getDistribution(a, opts, opts.cb);
  605 +};
  606 +
  607 +CloudFront.prototype.getStreamingDistributionConfig = function(a) {
  608 + var opts = getOptions(arguments, 3);
  609 + opts.streaming = true;
  610 + this.getDistributionConfig(a, opts, opts.cb);
  611 +};
  612 +
  613 +CloudFront.prototype.setStreamingDistributionConfig = function(distribution, config, etag, cb) {
  614 + config.streaming = true;
  615 + this.setDistributionConfig.apply(this, arguments);
  616 +};
  617 +
  618 +CloudFront.prototype.listStreamingDistributions = function() {
  619 + var opts = getOptions(arguments, 2);
  620 + opts.streaming = true;
  621 + this.listDistributions(opts, opts.cb);
  622 +};
  623 +
  624 +CloudFront.prototype.deleteStreamingDistribution = function(a, b) {
  625 + var opts = getOptions(arguments, 4);
  626 + opts.streaming = true;
  627 + this.deleteDistribution(a, b, opts, opts.cb);
  628 +};
  629 +
579 630
580 631 function CFObject(client) {
581 632 Object.defineProperty(this, 'client', {

0 comments on commit 698a5ff

Please sign in to comment.
Something went wrong with that request. Please try again.