aws-sdk 2.0.1 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/.eslintrc +20 -0
  2. package/.gitignore +10 -0
  3. package/.travis.yml +20 -0
  4. package/.yardopts +20 -0
  5. package/.yardopts_guide +21 -0
  6. package/Gemfile +16 -0
  7. package/Gemfile.lock +34 -0
  8. package/README.md +5 -6
  9. package/Rakefile +14 -0
  10. package/UPGRADING.md +9 -4
  11. package/configuration.sample +5 -0
  12. package/dist/BUNDLE_LICENSE.txt +96 -0
  13. package/dist/aws-sdk.js +9594 -0
  14. package/dist/aws-sdk.min.js +21 -0
  15. package/dist-tools/.eslintrc +10 -0
  16. package/dist-tools/browser-builder.js +142 -0
  17. package/dist-tools/strategies/cache.js +68 -0
  18. package/dist-tools/strategies/default.js +165 -0
  19. package/dist-tools/test/browser-builder.mocha.spec.coffee +182 -0
  20. package/dist-tools/test/helpers.coffee +16 -0
  21. package/doc-src/guide/browser-building.md +93 -0
  22. package/doc-src/guide/browser-configuring-wif.md +287 -0
  23. package/doc-src/guide/browser-configuring.md +218 -0
  24. package/doc-src/guide/browser-examples.md +220 -0
  25. package/doc-src/guide/browser-intro.md +46 -0
  26. package/doc-src/guide/browser-making-requests.md +279 -0
  27. package/doc-src/guide/browser-services.md +75 -0
  28. package/doc-src/guide/index.md +41 -0
  29. package/doc-src/guide/node-configuring.md +272 -0
  30. package/doc-src/guide/node-examples.md +341 -0
  31. package/doc-src/guide/node-intro.md +32 -0
  32. package/doc-src/guide/node-making-requests.md +309 -0
  33. package/doc-src/guide/node-services.md +159 -0
  34. package/doc-src/templates/api-versions/model_documentor.rb +366 -0
  35. package/doc-src/templates/api-versions/plugin.rb +230 -0
  36. package/doc-src/templates/api-versions/templates/default/class/html/setup.rb +9 -0
  37. package/doc-src/templates/api-versions/templates/default/class/html/waiter_details_list.erb +7 -0
  38. package/doc-src/templates/api-versions/templates/default/class/html/waiter_summary.erb +7 -0
  39. package/doc-src/templates/api-versions/templates/default/docstring/html/experimental.erb +4 -0
  40. package/doc-src/templates/api-versions/templates/default/docstring/setup.rb +9 -0
  41. package/doc-src/templates/api-versions/templates/default/fulldoc/html/css/common.css +6 -0
  42. package/doc-src/templates/api-versions/templates/default/fulldoc/html/setup.rb +62 -0
  43. package/doc-src/templates/api-versions/templates/default/layout/html/services.erb +10 -0
  44. package/doc-src/templates/api-versions/templates/default/layout/html/setup.rb +28 -0
  45. package/doc-src/templates/api-versions/templates/default/module/html/box_info.erb +45 -0
  46. package/doc-src/templates/api-versions/templates/default/module/html/children.erb +8 -0
  47. package/doc-src/templates/api-versions/templates/default/tags/setup.rb +3 -0
  48. package/doc-src/templates/api-versions/templates/default/waiter_details/html/method_signature.erb +3 -0
  49. package/doc-src/templates/api-versions/templates/default/waiter_details/html/setup.rb +5 -0
  50. package/doc-src/templates/default/layout/html/footer.erb +31 -0
  51. package/doc-src/templates/default/layout/html/layout.erb +23 -0
  52. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/highlight.github.css +127 -0
  53. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/style.css +1192 -0
  54. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/img/logo.png +0 -0
  55. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/app.js +33 -0
  56. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/highlight.pack.js +27 -0
  57. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/AUTHORS +55 -0
  58. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/LICENSE +25 -0
  59. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js +247 -0
  60. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/file.png +0 -0
  61. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js +568 -0
  62. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/underscore.js +23 -0
  63. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search.erb +29 -0
  64. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search_index.erb +1 -0
  65. package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/setup.rb +75 -0
  66. package/doc-src/templates/flasky_sphinx_guide/layout/html/layout.erb +93 -0
  67. package/doc-src/templates/flasky_sphinx_guide/layout/html/setup.rb +9 -0
  68. package/doc-src/templates/flasky_sphinx_guide/layout/html/sidebar.erb +45 -0
  69. package/doc-src/templates/flasky_sphinx_guide/onefile/html/layout.erb +51 -0
  70. package/doc-src/templates/flasky_sphinx_guide/onefile/html/setup.rb +1 -0
  71. package/eslint-rules/no-require-in-service.js +10 -0
  72. package/features/autoscaling/autoscaling.feature +21 -0
  73. package/features/autoscaling/step_definitions/autoscaling.js +49 -0
  74. package/features/cloudformation/cloudformation.feature +22 -0
  75. package/features/cloudformation/step_definitions/cloudformation.js +26 -0
  76. package/features/cloudfront/cloudfront.feature +28 -0
  77. package/features/cloudfront/step_definitions/cloudfront-latest.js +54 -0
  78. package/features/cloudfront/step_definitions/cloudfront.js +21 -0
  79. package/features/cloudsearch/cloudsearch.feature +34 -0
  80. package/features/cloudsearch/step_definitions/cloudsearch.js +42 -0
  81. package/features/cloudtrail/cloudtrail.feature +17 -0
  82. package/features/cloudtrail/step_definitions/cloudtrail.js +14 -0
  83. package/features/cloudwatch/cloudwatch.feature +15 -0
  84. package/features/cloudwatch/step_definitions/cloudwatch.js +48 -0
  85. package/features/datapipeline/datapipeline.feature +23 -0
  86. package/features/datapipeline/step_definitions/datapipeline.js +79 -0
  87. package/features/directconnect/directconnect.feature +20 -0
  88. package/features/directconnect/step_definitions/directconnect.js +44 -0
  89. package/features/dynamodb/crc32.feature +18 -0
  90. package/features/dynamodb/step_definitions/dynamodb.js +154 -0
  91. package/features/dynamodb/tables.feature +50 -0
  92. package/features/ec2/ec2.feature +28 -0
  93. package/features/ec2/step_definitions/ec2.js +65 -0
  94. package/features/elasticache/elasticache.feature +20 -0
  95. package/features/elasticache/step_definitions/elasticache.js +34 -0
  96. package/features/elasticbeanstalk/elasticbeanstalk.feature +22 -0
  97. package/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js +38 -0
  98. package/features/elastictranscoder/elastictranscoder.feature +24 -0
  99. package/features/elastictranscoder/step_definitions/elastictranscoder.js +56 -0
  100. package/features/elb/elb.feature +19 -0
  101. package/features/elb/step_definitions/elb.js +37 -0
  102. package/features/emr/emr.feature +16 -0
  103. package/features/emr/step_definitions/emr.js +45 -0
  104. package/features/extra/assertions.js +29 -0
  105. package/features/extra/dummy.feature +0 -0
  106. package/features/extra/fixtures/testfile.txt +1 -0
  107. package/features/extra/helpers.js +113 -0
  108. package/features/extra/hooks.js +107 -0
  109. package/features/extra/world.js +12 -0
  110. package/features/glacier/glacier.feature +47 -0
  111. package/features/glacier/step_definitions/glacier.js +112 -0
  112. package/features/iam/iam.feature +24 -0
  113. package/features/iam/step_definitions/iam.js +66 -0
  114. package/features/importexport/importexport.feature +53 -0
  115. package/features/importexport/step_definitions/importexport.js +42 -0
  116. package/features/kinesis/kinesis.feature +9 -0
  117. package/features/kinesis/step_definitions/kinesis.js +10 -0
  118. package/features/opsworks/opsworks.feature +26 -0
  119. package/features/opsworks/step_definitions/opsworks.js +42 -0
  120. package/features/rds/rds.feature +32 -0
  121. package/features/rds/step_definitions/rds.js +72 -0
  122. package/features/redshift/redshift.feature +20 -0
  123. package/features/redshift/step_definitions/redshift.js +33 -0
  124. package/features/route53/route53.feature +41 -0
  125. package/features/route53/step_definitions/route53.js +97 -0
  126. package/features/s3/buckets.feature +40 -0
  127. package/features/s3/objects.feature +122 -0
  128. package/features/s3/step_definitions/buckets.js +136 -0
  129. package/features/s3/step_definitions/hooks.js +39 -0
  130. package/features/s3/step_definitions/objects.js +204 -0
  131. package/features/s3/step_definitions/proxy.js +44 -0
  132. package/features/ses/ses.feature +20 -0
  133. package/features/ses/step_definitions/ses.js +22 -0
  134. package/features/simpledb/simpledb.feature +29 -0
  135. package/features/simpledb/step_definitions/simpledb.js +46 -0
  136. package/features/sns/sns.feature +15 -0
  137. package/features/sns/step_definitions/sns.js +33 -0
  138. package/features/sqs/messages.feature +21 -0
  139. package/features/sqs/queues.feature +18 -0
  140. package/features/sqs/step_definitions/messages.js +46 -0
  141. package/features/sqs/step_definitions/queues.js +33 -0
  142. package/features/sqs/step_definitions/sqs.js +7 -0
  143. package/features/storagegateway/step_definitions/storagegateway.js +16 -0
  144. package/features/storagegateway/storagegateway.feature +13 -0
  145. package/features/sts/step_definitions/sts.js +35 -0
  146. package/features/sts/sts.feature +29 -0
  147. package/features/support/step_definitions/support.js +35 -0
  148. package/features/support/support.feature +18 -0
  149. package/features/swf/step_definitions/swf.js +38 -0
  150. package/features/swf/swf.feature +15 -0
  151. package/index.js +2 -0
  152. package/lib/core.js +2 -2
  153. package/lib/credentials/shared_ini_file_credentials.js +0 -1
  154. package/lib/event_listeners.js +13 -1
  155. package/lib/http/node.js +19 -30
  156. package/lib/model/resource_waiter.js +0 -4
  157. package/lib/model/shape.js +2 -1
  158. package/lib/protocol/rest_xml.js +1 -1
  159. package/lib/region_config.js +31 -0
  160. package/lib/region_config.json +56 -0
  161. package/lib/request.js +37 -45
  162. package/lib/sequential_executor.js +17 -34
  163. package/lib/service.js +17 -44
  164. package/lib/services/cloudsearchdomain.js +69 -0
  165. package/lib/services/route53.js +0 -12
  166. package/lib/services/s3.js +3 -19
  167. package/lib/signers/v4.js +2 -1
  168. package/lib/util.js +28 -3
  169. package/package.json +3 -3
  170. package/scripts/console +11 -3
  171. package/scripts/coverage +126 -0
  172. package/tasks/apis.rake +122 -0
  173. package/tasks/browser.rake +89 -0
  174. package/tasks/docs.rake +36 -0
  175. package/tasks/lib/cucumber_generator.rb +40 -0
  176. package/tasks/util.rake +33 -0
  177. package/test/browser/js/jasmine-1.3.1.js +2600 -0
  178. package/test/browser/js/jasmine-html.js +681 -0
  179. package/test/browser/runner.html +109 -0
  180. package/test/browser/runner.js +92 -0
  181. package/test/browser/sample/appinfo.sample.js +15 -0
  182. package/test/browser/sample/console.html +429 -0
  183. package/test/browser/sample/css/smoothness/images/animated-overlay.gif +0 -0
  184. package/test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  185. package/test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  186. package/test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  187. package/test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  188. package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  189. package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  190. package/test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  191. package/test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  192. package/test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
  193. package/test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  194. package/test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
  195. package/test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
  196. package/test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  197. package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.css +1175 -0
  198. package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.min.css +5 -0
  199. package/test/browser/sample/img/loading.gif +0 -0
  200. package/test/browser/sample/js/jquery-1.9.1.js +9597 -0
  201. package/test/browser/sample/js/jquery-ui-1.10.1.custom.js +14903 -0
  202. package/test/browser/sample/js/jquery-ui-1.10.1.custom.min.js +6 -0
  203. package/test/browser/sample/s3upload.html +111 -0
  204. package/test/browser.spec.coffee +207 -0
  205. package/test/config.spec.coffee +202 -0
  206. package/test/credential_provider_chain.spec.coffee +90 -0
  207. package/test/credentials.spec.coffee +452 -0
  208. package/test/endpoint.spec.coffee +80 -0
  209. package/test/event_listeners.spec.coffee +493 -0
  210. package/test/helpers.coffee +150 -0
  211. package/test/http_request.spec.coffee +55 -0
  212. package/test/json/builder.spec.coffee +129 -0
  213. package/test/json/parser.spec.coffee +108 -0
  214. package/test/metadata_service.spec.coffee +54 -0
  215. package/test/model/api.spec.coffee +67 -0
  216. package/test/model/shape.spec.coffee +23 -0
  217. package/test/node_http_client.spec.coffee +40 -0
  218. package/test/param_validator.spec.coffee +456 -0
  219. package/test/protocol/json.spec.coffee +167 -0
  220. package/test/protocol/query.spec.coffee +191 -0
  221. package/test/protocol/rest.spec.coffee +237 -0
  222. package/test/protocol/rest_json.spec.coffee +255 -0
  223. package/test/protocol/rest_xml.spec.coffee +329 -0
  224. package/test/query/query_param_serializer.spec.coffee +327 -0
  225. package/test/region_config.spec.coffee +50 -0
  226. package/test/request.spec.coffee +316 -0
  227. package/test/resource_waiter.spec.coffee +89 -0
  228. package/test/response.spec.coffee +81 -0
  229. package/test/sequential_executor.spec.coffee +118 -0
  230. package/test/service.spec.coffee +230 -0
  231. package/test/services/cloudfront.spec.coffee +44 -0
  232. package/test/services/cloudsearchdomain.spec.coffee +23 -0
  233. package/test/services/dynamodb.spec.coffee +32 -0
  234. package/test/services/ec2.spec.coffee +78 -0
  235. package/test/services/elastictranscoder.spec.coffee +43 -0
  236. package/test/services/glacier.spec.coffee +61 -0
  237. package/test/services/rds.spec.coffee +38 -0
  238. package/test/services/route53.spec.coffee +77 -0
  239. package/test/services/s3.spec.coffee +538 -0
  240. package/test/services/simpledb.spec.coffee +12 -0
  241. package/test/services/sqs.spec.coffee +130 -0
  242. package/test/services/sts.spec.coffee +72 -0
  243. package/test/services/swf.spec.coffee +6 -0
  244. package/test/signers/presign.spec.coffee +36 -0
  245. package/test/signers/s3.spec.coffee +297 -0
  246. package/test/signers/v2.spec.coffee +68 -0
  247. package/test/signers/v4.spec.coffee +135 -0
  248. package/test/util.spec.coffee +510 -0
  249. package/test/xml/builder.spec.coffee +529 -0
  250. package/test/xml/parser.spec.coffee +587 -0
  251. package/lib/services/simpledb.js +0 -15
package/lib/request.js CHANGED
@@ -3,14 +3,6 @@ var AcceptorStateMachine = require('./state_machine');
3
3
  var inherit = AWS.util.inherit;
4
4
 
5
5
  var hardErrorStates = {success:1, error:1, complete:1};
6
- var hardErrors = {
7
- EvalError: 1,
8
- RangeError: 1,
9
- ReferenceError: 1,
10
- SyntaxError: 1,
11
- TypeError: 1,
12
- URIError: 1
13
- };
14
6
 
15
7
  function isTerminalState(machine) {
16
8
  return hardErrorStates.hasOwnProperty(machine._asm.currentState);
@@ -23,37 +15,24 @@ fsm.setupStates = function() {
23
15
  var self = this;
24
16
  self.emit(self._asm.currentState, function() {
25
17
  var nextError = self.response.error;
26
- if (nextError && isTerminalState(self)) {
27
- var isHardError = hardErrors.hasOwnProperty(nextError.name);
28
- if (!isHardError) nextError = null;
18
+ if (nextError && nextError !== err && isTerminalState(self)) {
19
+ throw nextError;
29
20
  }
30
21
 
31
22
  done(nextError);
32
23
  });
33
24
 
34
25
  } catch (e) {
35
- err = e;
36
- if (isTerminalState(self)) {
37
- var isHardError = hardErrors.hasOwnProperty(err.name);
38
- if (!isHardError) err = null;
26
+ if (e !== err && isTerminalState(self)) {
27
+ AWS.SequentialExecutor.prototype.unhandledErrorCallback.call(this, e);
28
+ done();
29
+ } else {
30
+ done(e);
39
31
  }
40
- done(err);
41
32
  }
42
33
  };
43
34
 
44
35
  this.addState('validate', 'build', 'error', transition);
45
- this.addState('restart', 'build', 'error', function(err, done) {
46
- err = this.response.error;
47
- if (!err) return done();
48
- if (!err.retryable) return done(err);
49
-
50
- if (this.response.retryCount < this.service.config.maxRetries) {
51
- this.response.retryCount++;
52
- done();
53
- } else {
54
- done(err);
55
- }
56
- });
57
36
  this.addState('build', 'afterBuild', 'restart', transition);
58
37
  this.addState('afterBuild', 'sign', 'restart', transition);
59
38
  this.addState('sign', 'send', 'retry', transition);
@@ -63,13 +42,10 @@ fsm.setupStates = function() {
63
42
  this.addState('validateResponse', 'extractData', 'extractError', transition);
64
43
  this.addState('extractError', 'extractData', 'retry', transition);
65
44
  this.addState('extractData', 'success', 'retry', transition);
45
+ this.addState('restart', 'build', 'error', transition);
66
46
  this.addState('success', 'complete', 'complete', transition);
67
47
  this.addState('error', 'complete', 'complete', transition);
68
- this.addState('complete', null, 'uncaughtException', transition);
69
- this.addState('uncaughtException', function(err, done) {
70
- AWS.SequentialExecutor.prototype.unhandledErrorCallback.call(this, err);
71
- done(err);
72
- });
48
+ this.addState('complete', null, null, transition);
73
49
  };
74
50
  fsm.setupStates();
75
51
 
@@ -322,7 +298,7 @@ AWS.Request = inherit({
322
298
  var region = service.config.region;
323
299
 
324
300
  // global endpoints sign as us-east-1
325
- if (service.hasGlobalEndpoint()) region = 'us-east-1';
301
+ if (service.isGlobalEndpoint) region = 'us-east-1';
326
302
 
327
303
  this.service = service;
328
304
  this.operation = operation;
@@ -331,7 +307,6 @@ AWS.Request = inherit({
331
307
  this.startTime = AWS.util.date.getDate();
332
308
 
333
309
  this.response = new AWS.Response(this);
334
- this.restartCount = 0;
335
310
  this._asm = new AcceptorStateMachine(fsm.states, 'validate');
336
311
 
337
312
  AWS.SequentialExecutor.call(this);
@@ -437,30 +412,46 @@ AWS.Request = inherit({
437
412
  * console.log("Page", pages++);
438
413
  * console.log(data);
439
414
  * });
440
- * @callback callback function(err, data)
441
- * Called with each page of resulting data from the request.
415
+ * @example Iterating over multiple pages with an asynchronous callback
416
+ * s3.listObjects(params).eachPage(function(err, data, done) {
417
+ * doSomethingAsyncAndOrExpensive(function() {
418
+ * // The next page of results isn't fetched until done is called
419
+ * done();
420
+ * });
421
+ * });
422
+ * @callback callback function(err, data, [doneCallback])
423
+ * Called with each page of resulting data from the request. If the
424
+ * optional `doneCallback` is provided in the function, it must be called
425
+ * when the callback is complete.
442
426
  *
443
427
  * @param err [Error] an error object, if an error occurred.
444
428
  * @param data [Object] a single page of response data. If there is no
445
429
  * more data, this object will be `null`.
430
+ * @param doneCallback [Function] an optional done callback. If this
431
+ * argument is defined in the function declaration, it should be called
432
+ * when the next page is ready to be retrieved. This is useful for
433
+ * controlling serial pagination across asynchronous operations.
446
434
  * @return [Boolean] if the callback returns `false`, pagination will
447
435
  * stop.
448
436
  *
449
- * @api experimental
450
437
  * @see AWS.Request.eachItem
451
438
  * @see AWS.Response.nextPage
452
439
  * @since v1.4.0
453
440
  */
454
441
  eachPage: function eachPage(callback) {
442
+ // Make all callbacks async-ish
443
+ callback = AWS.util.fn.makeAsync(callback, 3);
444
+
455
445
  function wrappedCallback(response) {
456
- var result = callback.call(response, response.error, response.data);
457
- if (result === false) return;
446
+ callback.call(response, response.error, response.data, function (result) {
447
+ if (result === false) return;
458
448
 
459
- if (response.hasNextPage()) {
460
- response.nextPage().on('complete', wrappedCallback).send();
461
- } else {
462
- callback.call(response, null, null);
463
- }
449
+ if (response.hasNextPage()) {
450
+ response.nextPage().on('complete', wrappedCallback).send();
451
+ } else {
452
+ callback.call(response, null, null, AWS.util.fn.noop);
453
+ }
454
+ });
464
455
  }
465
456
 
466
457
  this.on('complete', wrappedCallback).send();
@@ -601,6 +592,7 @@ AWS.Request = inherit({
601
592
  */
602
593
  eventParameters: function eventParameters(eventName) {
603
594
  switch (eventName) {
595
+ case 'restart':
604
596
  case 'validate':
605
597
  case 'sign':
606
598
  case 'build':
@@ -73,9 +73,6 @@ AWS.SequentialExecutor = AWS.util.inherit({
73
73
  */
74
74
  emit: function emit(eventName, eventArgs, doneCallback) {
75
75
  if (!doneCallback) doneCallback = this.unhandledErrorCallback;
76
- if (domain && this.domain instanceof domain.Domain)
77
- this.domain.enter();
78
-
79
76
  var listeners = this.listeners(eventName);
80
77
  var count = listeners.length;
81
78
  this.callListeners(listeners, eventArgs, doneCallback);
@@ -88,39 +85,25 @@ AWS.SequentialExecutor = AWS.util.inherit({
88
85
  callListeners: function callListeners(listeners, args, doneCallback) {
89
86
  if (listeners.length === 0) {
90
87
  doneCallback.call(this);
91
- if (domain && this.domain instanceof domain.Domain)
92
- this.domain.exit();
93
- } else {
94
- var listener = listeners.shift();
95
- if (listener._isAsync) {
96
-
97
- // asynchronous listener
98
- var self = this;
99
- var callNextListener = function(err) {
100
- if (err) {
101
- doneCallback.call(self, err);
102
- if (domain && self.domain instanceof domain.Domain)
103
- self.domain.exit();
104
- } else {
105
- self.callListeners(listeners, args, doneCallback);
106
- }
107
- };
108
- listener.apply(this, args.concat([callNextListener]));
109
-
110
- } else {
111
-
112
- // synchronous listener
113
- try {
114
- listener.apply(this, args);
115
- this.callListeners(listeners, args, doneCallback);
116
- } catch (err) {
117
- if (err._hardError) throw err;
88
+ return;
89
+ }
118
90
 
119
- doneCallback.call(this, err);
120
- if (domain && this.domain instanceof domain.Domain)
121
- this.domain.exit();
91
+ var self = this, listener = listeners.shift();
92
+ if (listener._isAsync) { // asynchronous listener
93
+ var callNextListener = function(err) {
94
+ if (err) {
95
+ doneCallback.call(self, err);
96
+ } else {
97
+ self.callListeners(listeners, args, doneCallback);
122
98
  }
123
-
99
+ };
100
+ listener.apply(self, args.concat([callNextListener]));
101
+ } else { // synchronous listener
102
+ try {
103
+ listener.apply(self, args);
104
+ self.callListeners(listeners, args, doneCallback);
105
+ } catch (err) {
106
+ doneCallback.call(self, err);
124
107
  }
125
108
  }
126
109
  },
package/lib/service.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var AWS = require('./core');
2
2
  var Api = require('./model/api');
3
+ var regionConfig = require('./region_config');
3
4
  var inherit = AWS.util.inherit;
4
5
 
5
6
  /**
@@ -34,10 +35,19 @@ AWS.Service = inherit({
34
35
  this.config = new AWS.Config(AWS.config);
35
36
  if (config) this.config.update(config, true);
36
37
 
38
+ this.validateService();
39
+ regionConfig(this);
40
+
37
41
  this.config.endpoint = this.endpointFromTemplate(this.config.endpoint);
38
42
  this.setEndpoint(this.config.endpoint);
39
43
  },
40
44
 
45
+ /**
46
+ * @api private
47
+ */
48
+ validateService: function validateService() {
49
+ },
50
+
41
51
  /**
42
52
  * @api private
43
53
  */
@@ -236,9 +246,12 @@ AWS.Service = inherit({
236
246
  * @api private
237
247
  */
238
248
  getSignerClass: function getSignerClass() {
239
- var version = this.api.signatureVersion;
240
- if (this.config.signatureVersion) version = this.config.signatureVersion;
241
- else if (this.isRegionV4()) version = 'v4';
249
+ var version;
250
+ if (this.config.signatureVersion) {
251
+ version = this.config.signatureVersion;
252
+ } else {
253
+ version = this.api.signatureVersion;
254
+ }
242
255
  return AWS.Signers.RequestSigner.getVersion(version);
243
256
  },
244
257
 
@@ -342,47 +355,7 @@ AWS.Service = inherit({
342
355
  * @api private
343
356
  */
344
357
  setEndpoint: function setEndpoint(endpoint) {
345
- if (endpoint) {
346
- this.endpoint = new AWS.Endpoint(endpoint, this.config);
347
- } else if (this.hasGlobalEndpoint()) {
348
- this.endpoint = new AWS.Endpoint(this.api.globalEndpoint, this.config);
349
- } else {
350
- var host = this.api.endpointPrefix + '.' + this.config.region +
351
- this.endpointSuffix();
352
- this.endpoint = new AWS.Endpoint(host, this.config);
353
- }
354
- },
355
-
356
- /**
357
- * @api private
358
- */
359
- hasGlobalEndpoint: function hasGlobalEndpoint() {
360
- if (this.isRegionV4()) return false;
361
- return this.api.globalEndpoint;
362
- },
363
-
364
- /**
365
- * @api private
366
- */
367
- endpointSuffix: function endpointSuffix() {
368
- var suffix = '.amazonaws.com';
369
- if (this.isRegionCN()) return suffix + '.cn';
370
- else return suffix;
371
- },
372
-
373
- /**
374
- * @api private
375
- */
376
- isRegionCN: function isRegionCN() {
377
- if (!this.config.region) return false;
378
- return this.config.region.match(/^cn-/) ? true : false;
379
- },
380
-
381
- /**
382
- * @api private
383
- */
384
- isRegionV4: function isRegionV4() {
385
- return this.isRegionCN();
358
+ this.endpoint = new AWS.Endpoint(endpoint, this.config);
386
359
  },
387
360
 
388
361
  /**
@@ -0,0 +1,69 @@
1
+ var AWS = require('../core');
2
+
3
+ /**
4
+ * Constructs a service interface object. Each API operation is exposed as a
5
+ * function on service.
6
+ *
7
+ * ### Sending a Request Using CloudSearchDomain
8
+ *
9
+ * ```javascript
10
+ * var csd = new AWS.CloudSearchDomain({endpoint: 'my.host.tld'});
11
+ * csd.search(params, function (err, data) {
12
+ * if (err) console.log(err, err.stack); // an error occurred
13
+ * else console.log(data); // successful response
14
+ * });
15
+ * ```
16
+ *
17
+ * ### Locking the API Version
18
+ *
19
+ * In order to ensure that the CloudSearchDomain object uses this specific API,
20
+ * you can construct the object by passing the `apiVersion` option to the
21
+ * constructor:
22
+ *
23
+ * ```javascript
24
+ * var csd = new AWS.CloudSearchDomain({
25
+ * endpoint: 'my.host.tld',
26
+ * apiVersion: '2013-01-01'
27
+ * });
28
+ * ```
29
+ *
30
+ * You can also set the API version globally in `AWS.config.apiVersions` using
31
+ * the **cloudsearchdomain** service identifier:
32
+ *
33
+ * ```javascript
34
+ * AWS.config.apiVersions = {
35
+ * cloudsearchdomain: '2013-01-01',
36
+ * // other service API versions
37
+ * };
38
+ *
39
+ * var csd = new AWS.CloudSearchDomain({endpoint: 'my.host.tld'});
40
+ * ```
41
+ *
42
+ * @note You *must* provide an `endpoint` configuration parameter when
43
+ * constructing this service. See {constructor} for more information.
44
+ *
45
+ * @!method constructor(options = {})
46
+ * Constructs a service object. This object has one method for each
47
+ * API operation.
48
+ *
49
+ * @example Constructing a CloudSearchDomain object
50
+ * var csd = new AWS.CloudSearchDomain({endpoint: 'my.host.tld'});
51
+ * @note You *must* provide an `endpoint` when constructing this service.
52
+ * @option (see AWS.Config.constructor)
53
+ *
54
+ * @service cloudsearchdomain
55
+ * @version 2013-01-01
56
+ */
57
+ AWS.util.update(AWS.CloudSearchDomain.prototype, {
58
+ /**
59
+ * @api private
60
+ */
61
+ validateService: function validateService() {
62
+ if (!this.config.endpoint || this.config.endpoint.indexOf('{') >= 0) {
63
+ var msg = 'AWS.CloudSearchDomain requires an explicit ' +
64
+ '`endpoint\' configuration option.';
65
+ throw AWS.util.error(new Error(),
66
+ {name: 'InvalidEndpoint', message: msg});
67
+ }
68
+ }
69
+ });
@@ -14,17 +14,5 @@ AWS.util.update(AWS.Route53.prototype, {
14
14
  sanitizeUrl: function sanitizeUrl(request) {
15
15
  var path = request.httpRequest.path;
16
16
  request.httpRequest.path = path.replace(/\/%2F\w+%2F/, '/');
17
- },
18
-
19
- /**
20
- * @api private
21
- */
22
- setEndpoint: function setEndpoint(endpoint) {
23
- if (endpoint) {
24
- AWS.Service.prototype.setEndpoint(endpoint);
25
- } else {
26
- var opts = {sslEnabled: true}; // SSL is always enabled for Route53
27
- this.endpoint = new AWS.Endpoint(this.api.globalEndpoint, opts);
28
- }
29
17
  }
30
18
  });
@@ -4,9 +4,9 @@ AWS.util.update(AWS.S3.prototype, {
4
4
  /**
5
5
  * @api private
6
6
  */
7
- initialize: function initialize(options) {
8
- AWS.Service.prototype.initialize.call(this, options);
9
- this.setEndpoint(this.config.endpoint, options);
7
+ validateService: function validateService() {
8
+ // default to us-east-1 when no region is provided
9
+ if (!this.config.region) this.config.region = 'us-east-1';
10
10
  },
11
11
 
12
12
  /**
@@ -287,22 +287,6 @@ AWS.util.update(AWS.S3.prototype, {
287
287
  }
288
288
  },
289
289
 
290
- /**
291
- * @api private
292
- */
293
- setEndpoint: function setEndpoint(endpoint) {
294
- if (endpoint) {
295
- this.endpoint = new AWS.Endpoint(endpoint, this.config);
296
- } else if (this.config.region && this.config.region !== 'us-east-1') {
297
- var sep = '-';
298
- if (this.isRegionV4()) sep = '.';
299
- var hostname = 's3' + sep + this.config.region + this.endpointSuffix();
300
- this.endpoint = new AWS.Endpoint(hostname);
301
- } else {
302
- this.endpoint = new AWS.Endpoint(this.api.globalEndpoint, this.config);
303
- }
304
- },
305
-
306
290
  /**
307
291
  * Get a pre-signed URL for a given operation name.
308
292
  *
package/lib/signers/v4.js CHANGED
@@ -195,9 +195,10 @@ AWS.Signers.V4 = inherit(AWS.Signers.RequestSigner, {
195
195
  },
196
196
 
197
197
  unsignableHeaders: ['authorization', 'content-type', 'content-length',
198
- 'user-agent', expiresHeader, 'x-amz-user-agent', 'x-amz-content-sha256'],
198
+ 'user-agent', expiresHeader],
199
199
 
200
200
  isSignableHeader: function isSignableHeader(key) {
201
+ if (key.toLowerCase().indexOf('x-amz-') === 0) return true;
201
202
  return this.unsignableHeaders.indexOf(key) < 0;
202
203
  },
203
204
 
package/lib/util.js CHANGED
@@ -98,7 +98,7 @@ var util = {
98
98
 
99
99
  readFileSync: function readFileSync(path) {
100
100
  if (typeof window !== 'undefined') return null;
101
- return require('fs').readFileSync(path, 'utf-8');
101
+ return util.nodeRequire('fs').readFileSync(path, 'utf-8');
102
102
  },
103
103
 
104
104
  base64: {
@@ -151,7 +151,7 @@ var util = {
151
151
  } else if (typeof string.size === 'number') {
152
152
  return string.size;
153
153
  } else if (typeof string.path === 'string') {
154
- return require('fs').lstatSync(string.path).size;
154
+ return util.nodeRequire('fs').lstatSync(string.path).size;
155
155
  } else {
156
156
  throw util.error(new Error('Cannot determine length of ' + string),
157
157
  { object: string });
@@ -188,6 +188,29 @@ var util = {
188
188
  }
189
189
  },
190
190
 
191
+ fn: {
192
+ noop: function(){},
193
+
194
+ /**
195
+ * Turn a synchronous function into as "async" function by making it call
196
+ * a callback. The underlying function is called with all but the last argument,
197
+ * which is treated as the callback. The callback is passed passed a first argument
198
+ * of null on success to mimick standard node callbacks.
199
+ */
200
+ makeAsync: function makeAsync(fn, expectedArgs) {
201
+ if (expectedArgs && expectedArgs <= fn.length) {
202
+ return fn;
203
+ }
204
+
205
+ return function() {
206
+ var args = Array.prototype.slice.call(arguments, 0);
207
+ var callback = args.pop();
208
+ var result = fn.apply(null, args);
209
+ callback(result);
210
+ };
211
+ }
212
+ },
213
+
191
214
  jamespath: {
192
215
  query: function query(expression, data) {
193
216
  if (!data) return [];
@@ -310,7 +333,9 @@ var util = {
310
333
  },
311
334
 
312
335
  parseTimestamp: function parseTimestamp(value) {
313
- if (value.match(/^\d+$/)) { // unix timestamp
336
+ if (typeof value === 'number') { // unix timestamp (number)
337
+ return new Date(value * 1000);
338
+ } else if (value.match(/^\d+$/)) { // unix timestamp
314
339
  return new Date(value * 1000);
315
340
  } else if (value.match(/^\d{4}/)) { // iso8601
316
341
  return new Date(value);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aws-sdk",
3
3
  "description": "AWS SDK for JavaScript",
4
- "version": "2.0.1",
4
+ "version": "2.0.5",
5
5
  "author": {
6
6
  "name":"Amazon Web Services",
7
7
  "email":"",
@@ -14,7 +14,8 @@
14
14
  ],
15
15
  "devDependencies": {
16
16
  "repl.history": "*",
17
- "jasmine-node": "*",
17
+ "jasmine-node": "1.x",
18
+ "jasmine-reporters": "1.x",
18
19
  "semver": "*",
19
20
  "coffee-script": "1.6.3",
20
21
  "eslint": "*",
@@ -27,7 +28,6 @@
27
28
  "istanbul": "*"
28
29
  },
29
30
  "dependencies": {
30
- "agentkeepalive": "0.2.2",
31
31
  "aws-sdk-apis": "3.x",
32
32
  "xml2js": "0.2.6",
33
33
  "xmlbuilder": "0.4.2"
package/scripts/console CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  var repl = require('repl').start('aws-sdk> '),
4
4
  replEval = repl.eval,
5
- replHistory = require('repl.history'),
6
5
  defaultOptions = {
7
6
  logger: process.stdout,
8
7
  region: process.env.AWS_REGION || 'us-east-1'
@@ -52,11 +51,20 @@ repl.context.request = null;
52
51
  repl.context.response = null;
53
52
 
54
53
  // setup REPL history
55
- replHistory(repl, process.env.HOME + '/.node_history');
54
+ try {
55
+ var replHistory = require('repl.history');
56
+ replHistory(repl, process.env.HOME + '/.node_history');
57
+ } catch (e) {
58
+ console.log("Missing repl.history package, history will not be supported.");
59
+ console.log(" Type `npm install repl.history` to enable history.");
60
+ }
56
61
 
57
62
  // load services as defined instances
58
63
  for (var key in AWS) {
59
- if (AWS[key].serviceIdentifier) {
64
+ var id = AWS[key].serviceIdentifier;
65
+ if (id) {
66
+ if (id === 'cloudsearchdomain') continue; // this required an explicit endpoint
67
+
60
68
  var svcClass = AWS[key];
61
69
  var svc = new svcClass(defaultOptions);
62
70
  svc.with = function(config) {