Sha256: 7027e65b0181c7abedbabe700a02f2e727e650e731a681c84eb18623573587c8

Contents?: true

Size: 1.75 KB

Versions: 35

Compression:

Stored size: 1.75 KB

Contents

var AWS = require('../core');

AWS.util.update(AWS.EC2.prototype, {
  /**
   * @api private
   */
  setupRequestListeners: function setupRequestListeners(request) {
    request.removeListener('extractError', AWS.EventListeners.Query.EXTRACT_ERROR);
    request.addListener('extractError', this.extractError);

    if (request.operation === 'copySnapshot') {
      request.onAsync('validate', this.buildCopySnapshotPresignedUrl);
    }
  },

  /**
   * @api private
   */
  buildCopySnapshotPresignedUrl: function buildCopySnapshotPresignedUrl(req, done) {
    if (req.params.PresignedUrl || req._subRequest) {
      return done();
    }

    req.params = AWS.util.copy(req.params);
    req.params.DestinationRegion = req.service.config.region;

    var config = AWS.util.copy(req.service.config);
    delete config.endpoint;
    config.region = req.params.SourceRegion;
    var svc = new req.service.constructor(config);
    var newReq = svc[req.operation](req.params);
    newReq._subRequest = true;
    newReq.presign(function(err, url) {
      if (err) done(err);
      else {
        req.params.PresignedUrl = url;
        done();
      }
    });
  },

  /**
   * @api private
   */
  extractError: function extractError(resp) {
    // EC2 nests the error code and message deeper than other AWS Query services.
    var httpResponse = resp.httpResponse;
    var data = new AWS.XML.Parser().parse(httpResponse.body.toString() || '');
    if (data.Errors) {
      resp.error = AWS.util.error(new Error(), {
        code: data.Errors.Error.Code,
        message: data.Errors.Error.Message
      });
    } else {
      resp.error = AWS.util.error(new Error(), {
        code: httpResponse.statusCode,
        message: null
      });
    }
    resp.error.requestId = data.RequestID || null;
  }
});

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
sumomo-0.10.8 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.12 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.11 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.10 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.9 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js
sumomo-0.8.8 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/ec2.js