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
@@ -0,0 +1,220 @@
1
+ # @title Examples in the Browser
2
+
3
+ # Examples in the Browser
4
+
5
+ All of these examples assume that the AWS library is loaded, configured,
6
+ and authenticated with the correct credentials.
7
+
8
+ The common preamble code can be summarized as follows:
9
+
10
+ <script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.5.min.js"></script>
11
+ <script type="text/javascript">
12
+ // See the Configuring section to configure credentials in the SDK
13
+ AWS.config.credentials = ...;
14
+
15
+ // Configure your region
16
+ AWS.config.region = 'us-west-2';
17
+ </script>
18
+
19
+ ## Basic Usage Example
20
+
21
+ The following example shows basic usage of the SDK to list objects in an
22
+ Amazon S3 bucket:
23
+
24
+ <div id="status"></div>
25
+ <ul id="objects"></ul>
26
+
27
+ <script type="text/javascript">
28
+ var bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
29
+ bucket.listObjects(function (err, data) {
30
+ if (err) {
31
+ document.getElementById('status').innerHTML =
32
+ 'Could not load objects from S3';
33
+ } else {
34
+ document.getElementById('status').innerHTML =
35
+ 'Loaded ' + data.Contents.length + ' items from S3';
36
+ for (var i = 0; i < data.Contents.length; i++) {
37
+ document.getElementById('objects').innerHTML +=
38
+ '<li>' + data.Contents[i].Key + '</li>';
39
+ }
40
+ }
41
+ });
42
+ </script>
43
+
44
+ ## Amazon S3
45
+
46
+ ### Uploading data into an object
47
+
48
+ The following example will upload the contents of a `<textarea>` tag to an
49
+ object in S3:
50
+
51
+ <textarea id="data"></textarea>
52
+ <button id="upload-button">Upload to S3</button>
53
+ <div id="results"></div>
54
+
55
+ <script type="text/javascript">
56
+ var bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
57
+
58
+ var textarea = document.getElementById('data');
59
+ var button = document.getElementById('upload-button');
60
+ var results = document.getElementById('results');
61
+ button.addEventListener('click', function() {
62
+ results.innerHTML = '';
63
+
64
+ var params = {Key: 'data.txt', Body: textarea.value};
65
+ s3.putObject(params, function (err, data) {
66
+ results.innerHTML = err ? 'ERROR!' : 'SAVED.';
67
+ });
68
+ }, false);
69
+ </script>
70
+
71
+ ### Uploading a local file using the File API
72
+
73
+ The following example uses the [HTML5 File API](http://www.w3.org/TR/FileAPI/)
74
+ to upload a file on disk to S3:
75
+
76
+ <input type="file" id="file-chooser" />
77
+ <button id="upload-button">Upload to S3</button>
78
+ <div id="results"></div>
79
+
80
+ <script type="text/javascript">
81
+ var bucket = new AWS.S3({params: {Bucket: 'myBucket'}});
82
+
83
+ var fileChooser = document.getElementById('file-chooser');
84
+ var button = document.getElementById('upload-button');
85
+ var results = document.getElementById('results');
86
+ button.addEventListener('click', function() {
87
+ var file = fileChooser.files[0];
88
+ if (file) {
89
+ results.innerHTML = '';
90
+
91
+ var params = {Key: file.name, ContentType: file.type, Body: file};
92
+ bucket.putObject(params, function (err, data) {
93
+ results.innerHTML = err ? 'ERROR!' : 'UPLOADED.';
94
+ });
95
+ } else {
96
+ results.innerHTML = 'Nothing to upload.';
97
+ }
98
+ }, false);
99
+ </script>
100
+
101
+ ### Getting a pre-signed URL for a getObject operation
102
+
103
+ A pre-signed URL allows you to give one-off access to other users who may not
104
+ have direct access to execute the operations. Pre-signing generates a valid
105
+ URL signed with your credentials that any user can access. By default, the SDK
106
+ sets all URLs to expire within 15 minutes, but this value can be adjusted.
107
+
108
+ To generate a simple pre-signed URL that allows any user to view the contents
109
+ of a private object in a bucket you own, you can use the following call to
110
+ `getSignedUrl()`:
111
+
112
+ ```javascript
113
+ var params = {Bucket: 'myBucket', Key: 'myKey'};
114
+ s3.getSignedUrl('getObject', params, function (err, url) {
115
+ console.log("The URL is", url);
116
+ });
117
+ ```
118
+
119
+ ### Controlling Expires time with pre-signed URLs
120
+
121
+ As mentioned above, pre-signed URLs will expire in 15 minutes by default
122
+ when generated by the SDK. This value is adjustable with the `Expires`
123
+ parameter, an integer representing the number of seconds that the URL will be
124
+ valid, and can be set with any call to `getSignedUrl()`:
125
+
126
+ ```javascript
127
+ // This URL will expire in one minute (60 seconds)
128
+ var params = {Bucket: 'myBucket', Key: 'myKey', Expires: 60};
129
+ var url = s3.getSignedUrl('getObject', params, function (err, url) {
130
+ if (url) console.log("The URL is", url);
131
+ });
132
+ ```
133
+
134
+ ## Amazon DynamoDB
135
+
136
+ ### Listing tables
137
+
138
+ The following example will list all tables in a DynamoDB instance.
139
+
140
+ ```javascript
141
+ var db = new AWS.DynamoDB();
142
+ db.listTables(function(err, data) {
143
+ console.log(data.TableNames);
144
+ });
145
+ ```
146
+
147
+ ### Reading and writing items in a table
148
+
149
+ The following example puts an item in a DynamoDB table and then reads it back
150
+ using the hash key.
151
+
152
+ ```javascript
153
+ var table = new AWS.DynamoDB({params: {TableName: 'MY_TABLE'}});
154
+ var key = 'UNIQUE_KEY_ID';
155
+
156
+ // Write the item to the table
157
+ var itemParams = {Item: {id: {S: key}, data: {S: 'data'}}};
158
+ table.putItem(itemParams, function() {
159
+ // Read the item from the table
160
+ table.getItem({Key: {id: {S: key}}}, function(err, data) {
161
+ console.log(data.Item); // print the item data
162
+ });
163
+ });
164
+ ```
165
+
166
+ ## Amazon SQS
167
+
168
+ ### Creating a queue
169
+
170
+ The following example creates a queue resource in Amazon SQS.
171
+
172
+ ```javascript
173
+ var sqs = new AWS.SQS();
174
+ sqs.createQueue({QueueName: 'MY_QUEUE_NAME'}, function (err, data) {
175
+ if (data) {
176
+ var url = data.QueueUrl; // use this queue URL to operate on the queue
177
+ }
178
+ });
179
+ ```
180
+
181
+ ### Sending a message
182
+
183
+ The following example sends a message to the queue created in the previous
184
+ example.
185
+
186
+ ```javascript
187
+ // using Queue URL variable (`url`) from previous example
188
+ var queue = new AWS.SQS({params: {QueueUrl: url}});
189
+ queue.sendMessage({MessageBody: 'THE MESSAGE TO SEND'}, function (err, data) {
190
+ if (!err) console.log('Message sent.');
191
+ });
192
+ ```
193
+
194
+ ### Receiving a message
195
+
196
+ The following example receives the message from the queue sent in the
197
+ previous example.
198
+
199
+ ```javascript
200
+ var queue = new AWS.SQS({params: {QueueUrl: url}}); // using url to queue
201
+ queue.receiveMessage(function (err, data) {
202
+ if (data) {
203
+ console.log(data.Messages); // message data in Messages structure
204
+ }
205
+ });
206
+ ```
207
+
208
+ ## Amazon SNS
209
+
210
+ ### Publishing to a topic
211
+
212
+ The following example publishes a message to an SNS topic resource. The topic
213
+ can be identified with a topic ARN.
214
+
215
+ ```javascript
216
+ var sns = new AWS.SNS({params: {TopicArn: 'ARN_FOR_SNS_TOPIC'}});
217
+ sns.publish({Message: 'THE MESSAGE TO PUBLISH'}, function (err, data) {
218
+ if (!err) console.log('Message published');
219
+ });
220
+ ```
@@ -0,0 +1,46 @@
1
+ # @title AWS SDK for JavaScript in the Browser
2
+
3
+ # Getting Started with the SDK in the Browser
4
+
5
+ ## Loading the SDK
6
+
7
+ The quickest way to get started with the SDK is to load it using the hosted
8
+ package directly from Amazon Web Services. To do this, simply add the following
9
+ script tag to your HTML pages:
10
+
11
+ <script src="https://sdk.amazonaws.com/js/aws-sdk-2.0.5.min.js"></script>
12
+
13
+ You can also download this package by clicking the following link:
14
+ [aws-sdk-2.0.5.min.js](https://sdk.amazonaws.com/js/aws-sdk-2.0.5.min.js)
15
+
16
+ Once the SDK is loaded in your page, the module will be available from
17
+ the global variable `AWS` (or `window.AWS`).
18
+
19
+ ## Browser Support
20
+
21
+ The SDK supports all modern web browsers:
22
+
23
+ <table>
24
+ <tr>
25
+ <td><strong>Google Chrome</strong></td><td>28.0+</td>
26
+ <td><strong>Microsoft Internet Explorer</strong></td><td>10.0+</td>
27
+ </tr>
28
+ <tr>
29
+ <td><strong>Mozilla Firefox</strong></td><td>23.0+</td>
30
+ <td><strong>Apple Safari</strong></td><td>5.1+</td>
31
+ <tr>
32
+ <td><strong>Opera</strong></td><td>17.0+</td>
33
+ <td><strong>Android Browser</strong></td><td>4.3+</td>
34
+ </tr>
35
+ </table>
36
+
37
+ ## Next Steps
38
+
39
+ Now that you have installed and loaded the SDK, continue on to learn how to
40
+ configure and use the SDK to make requests to API operations on services.
41
+
42
+ * {file:browser-configuring.md Configuring the SDK}
43
+ * {file:browser-services.md Working with Services}
44
+ * {file:browser-making-requests.md Making Requests}
45
+ * {file:browser-examples.md Common Examples}
46
+ * {file:browser-building.md Building the SDK}
@@ -0,0 +1,279 @@
1
+ # @title Making Requests in the Browser
2
+
3
+ # Making Requests in the Browser
4
+
5
+ A "request" to an AWS service includes the full request and response lifecycle
6
+ of a call to an operation on a service object, including any retries that are
7
+ transparently attempted on your behalf. A request is encapsulated in the SDK by
8
+ the `AWS.Request` object. The semantics of a request are described below,
9
+ specifically, the support for callbacks, events, and streaming of raw HTTP
10
+ response data.
11
+
12
+ ## Asynchronous Callbacks
13
+
14
+ All requests made through the SDK are asynchronous and use a
15
+ callback interface. Each service method that kicks off a request
16
+ can accept a callback as the last parameter with the signature
17
+ `function(error, data) { ... }`. This callback will be called when
18
+ the response or error data is available.
19
+
20
+ For example, the following service method can be called with
21
+ a standard callback to retrieve the response data or error:
22
+
23
+ ```javascript
24
+ new AWS.S3().listObjects({Bucket: 'myBucket'}, function(error, data) {
25
+ if (error) {
26
+ console.log(error); // an error occurred
27
+ } else {
28
+ console.log(data); // request succeeded
29
+ }
30
+ });
31
+ ```
32
+
33
+ The `error` and `data` parameters are described in the "Response Object"
34
+ section below.
35
+
36
+ Note that if you do not specify a callback, the operation will
37
+ return an `AWS.Request` object that must be manually sent using
38
+ the `send()` method:
39
+
40
+ ```javascript
41
+ // create the AWS.Request object
42
+ var request = new AWS.S3().listObjects({Bucket: 'myBucket'});
43
+
44
+ // register a callback to report on the data
45
+ request.on('success', function(resp) {
46
+ console.log(resp.data); // log the successful data response
47
+ });
48
+
49
+ // send the request
50
+ request.send();
51
+ ```
52
+
53
+ ### The Response Object (`AWS.Response`)
54
+
55
+ The response object is passed into each callback function so
56
+ that you can access response data. The `AWS.Response` object that
57
+ is passed in contains two important properties to get at this data:
58
+
59
+ When using the standard callback mechanism, the two properties will
60
+ be made available as parameters on the callback method in the form:
61
+ `function(error, data) { ... }`
62
+
63
+ #### The `data` property
64
+
65
+ The `response.data` property contains the serialized object data
66
+ retrieved from the service request. For instance, for an
67
+ Amazon DynamoDB `listTables` method call, the response data might
68
+ look like this:
69
+
70
+ ```javascript
71
+ > response.data
72
+ { TableNames:
73
+ [ 'table1', 'table2', ... ] }
74
+ ```
75
+
76
+ The `data` property can be null if an error occurs (see below).
77
+
78
+ #### The `error` property
79
+
80
+ In the event of a service error (or transfer error), the
81
+ `response.error` property will be filled with the given
82
+ error data in the form:
83
+
84
+ ```javascript
85
+ { code: 'SHORT_UNIQUE_ERROR_CODE',
86
+ message: 'Some human readable error message' }
87
+ ```
88
+
89
+ In the case of an error, the `data` property will be null.
90
+ Note that if you handle events that can be in a failure state,
91
+ you should always check whether `response.error` is set
92
+ before attempting to access the `response.data` property.
93
+
94
+ #### The `request` property
95
+
96
+ Access to the originating request object is available through this
97
+ property. For example, to access the parameters that were sent
98
+ with a request:
99
+
100
+ ```javascript
101
+ s3.getObject({Bucket: 'bucket', Key: 'key'}).on('success', function(response) {
102
+ console.log("Key was", response.request.params.Key);
103
+ }).send();
104
+ ```
105
+
106
+ ### Simplified Callback Method
107
+
108
+ Each operation supports a simplified callback that can be passed as the last
109
+ parameter to any service operation. The callback function should
110
+ accept an `error` parameter, followed by the `data` from the response.
111
+
112
+ For example:
113
+
114
+ ```javascript
115
+ s3.listBuckets(function(error, data) {
116
+ if (err) {
117
+ console.log(error); // error is Response.error
118
+ } else {
119
+ console.log(data); // data is Response.data
120
+ }
121
+ });
122
+ ```
123
+
124
+ Prints (assuming the request succeeded):
125
+
126
+ ```javascript
127
+ { Owner: { ID: '...', DisplayName: '...' },
128
+ Buckets:
129
+ [ { Name: 'someBucketName', CreationDate: someCreationDate },
130
+ { Name: 'otherBucketName', CreationDate: otherCreationDate } ],
131
+ RequestId: '...' }
132
+ ```
133
+
134
+ The error and data parameters accepted are equivalent to the `error` and
135
+ `data` properties discussed in the `AWS.Response` response object section
136
+ above.
137
+
138
+ If you are passing parameters to the operation, the callback should be placed
139
+ after the parameters:
140
+
141
+ ```
142
+ s3.getObject({Bucket: 'bucket', Key: 'key'}, function(err, data) {
143
+ // ...
144
+ });
145
+ ```
146
+
147
+ ### AWS.Request Events
148
+
149
+ You can alternatively register callbacks on events provided by the
150
+ `AWS.Request` object returned by each service operation method.
151
+ This request object exposes the `success`, `error`, `complete`, and `httpData`
152
+ events, each taking a callback that accepts the response object.
153
+
154
+ Note that if you omit the simplified callback parameter on the operation
155
+ method, you must call `send()` on the returned request object in order to
156
+ kick off the request to the remote server.
157
+
158
+ #### Event: 'success'
159
+
160
+ ```javascript
161
+ req.on('success', function(response) { ... });
162
+ ```
163
+
164
+ This event triggers when a successful response
165
+ from the server is returned. The response contains a `.data` field
166
+ with the serialized response data from the service.
167
+
168
+ For example:
169
+
170
+ ```javascript
171
+ s3.listBuckets().done(function(response) {
172
+ console.log(response.data);
173
+ }).send();
174
+ ```
175
+
176
+ Prints:
177
+
178
+ ```javascript
179
+ { Owner: { ID: '...', DisplayName: '...' },
180
+ Buckets:
181
+ [ { Name: 'someBucketName', CreationDate: someCreationDate },
182
+ { Name: 'otherBucketName', CreationDate: otherCreationDate } ],
183
+ RequestId: '...' }
184
+ ```
185
+
186
+ #### Event: 'error'
187
+
188
+ ```javascript
189
+ req.on('error', function(error, response) { ... });
190
+ ```
191
+
192
+ The `error` event works similarly to the `success` event, except that it
193
+ triggers in the case of a request failure. In this case, `response.data`
194
+ will be `null` and the `response.error` field will be filled with
195
+ the error data. Note that the `error` object is also passed directly
196
+ as the first parameter to the event:
197
+
198
+ ```javascript
199
+ s3.config.credentials.accessKeyId = 'invalid';
200
+ s3.listBuckets().fail(function(error, response) {
201
+ console.log(error);
202
+ // or:
203
+ console.log(response.error);
204
+ }).send();
205
+ ```
206
+
207
+ Prints:
208
+
209
+ ```javascript
210
+ { code: 'Forbidden', message: null }
211
+ ```
212
+
213
+ #### Event: 'complete'
214
+
215
+ ```javascript
216
+ req.on('complete', function(response) { ... });
217
+ ```
218
+
219
+ The `complete` event triggers a callback in any final state of a request, i.e.,
220
+ both `success` and `error`. Use this callback to handle any request cleanup
221
+ that must be executed regardless of the success state. Note that if you
222
+ do intend to use response data inside of this callback, you must check
223
+ for the presence of `response.data` or `response.error` before attempting
224
+ to access either property. For example:
225
+
226
+ ```javascript
227
+ request.on('complete', function(response) {
228
+ if (response.error) {
229
+ // an error occurred, handle it
230
+ } else {
231
+ // we can use response.data here
232
+ }
233
+ }).send();
234
+ ```
235
+
236
+ #### Event: 'httpData'
237
+
238
+ ```javascript
239
+ req.on('httpData', function(chunk, response) { ... });
240
+ ```
241
+
242
+ <p class="note">If you register a <code>httpData</code> callback,
243
+ <code>response.data</code> will still contain serialized output
244
+ for the entire request. It will be your responsibility to remove
245
+ the default 'httpData' listener if you do not wish to have the
246
+ extra parsing and memory overhead from the built-in handlers.
247
+ </p>
248
+
249
+ The `httpData` event is used to stream response data from the
250
+ service packet-by-packet. This event is mostly used for large responses,
251
+ when it is inefficient (or impossible) to load the entire response into
252
+ memory.
253
+
254
+ Note that this event contains an extra `chunk` parameter containing the
255
+ actual data passed on by the server.
256
+
257
+ ## Multiple Callbacks and Chaining
258
+
259
+ You can register multiple callbacks on any request object. The
260
+ callbacks can be registered for different events, or all for the
261
+ same event. In addition, you can chain callback registration, for
262
+ example:
263
+
264
+ ```javascript
265
+ request.
266
+ on('success', function(response) {
267
+ console.log("Success!");
268
+ }).
269
+ on('error', function(response) {
270
+ console.log("Error!");
271
+ }).
272
+ on('complete', function() {
273
+ console.log("Always!");
274
+ }).
275
+ send();
276
+ ```
277
+
278
+ The above example will print either "Success! Always!", or "Error! Always!",
279
+ depending on whether the request succeeded or not.
@@ -0,0 +1,75 @@
1
+ # @title Working with Services in the Browser
2
+
3
+ # Working with Services in the Browser
4
+
5
+ ## Supported Services
6
+
7
+ By default, the SDK ships with support for 7 AWS services. Each service object
8
+ in the SDK currently provides low-level access to every API call in the
9
+ respective AWS service. The full list of methods and their parameters are
10
+ documented in the complete API reference documentation (linked from each
11
+ service name in the list below).
12
+
13
+ The 5 services that come with the default hosted package of the SDK are:
14
+
15
+ * [AWS.DynamoDB](/AWSJavaScriptSDK/latest/frames.html#!AWS/DynamoDB.html)
16
+ * [AWS.S3](/AWSJavaScriptSDK/latest/frames.html#!AWS/S3.html)
17
+ * [AWS.SNS](/AWSJavaScriptSDK/latest/frames.html#!AWS/SNS.html)
18
+ * [AWS.SQS](/AWSJavaScriptSDK/latest/frames.html#!AWS/SQS.html)
19
+ * [AWS.Kinesis](/AWSJavaScriptSDK/latest/frames.html#!AWS/Kinesis.html)
20
+ * [AWS.CloudWatch](/AWSJavaScriptSDK/latest/frames.html#!AWS/CloudWatch.html)
21
+ * [AWS.STS](/AWSJavaScriptSDK/latest/frames.html#!AWS/STS.html)
22
+
23
+ <div class="clear"></div>
24
+
25
+ It is possible to use the SDK with other services if [CORS](http://www.w3.org/TR/cors/)
26
+ security checking is disabled in your environment. In this case, you can build
27
+ your own custom version of the SDK. See the {file:browser-building.md Building the SDK}
28
+ section of the guide for more information on how to create a custom build of
29
+ the SDK.
30
+
31
+ ## Constructing a Service
32
+
33
+ Each service can be constructed with runtime configuration data that is
34
+ specific to that service object. The service-specific configuration data
35
+ will be merged on top of global configuration, so there is no need to
36
+ re-specify any global settings. For example, an DynamoDB object can be created
37
+ for a specific region:
38
+
39
+ ```javascript
40
+ var dynamodb = new AWS.DynamoDB({region: 'us-west-2'});
41
+ ```
42
+
43
+ This object will continue to use the globally provided credentials.
44
+
45
+ ## Passing Parameters to a Service Operation
46
+
47
+ When calling a method to a service, you should pass parameters in as
48
+ option values, similar to the way configuration is passed.
49
+ For example, to read an object for a given bucket and key in S3, you
50
+ can pass the following parameters to the `getObject` method:
51
+
52
+ ```javascript
53
+ s3.getObject({Bucket: 'bucketName', Key: 'keyName'});
54
+ ```
55
+
56
+ Note that the full parameter documentation for each method is found
57
+ in each service page in the complete API reference documentation.
58
+
59
+ ## Bound Parameters
60
+
61
+ Parameters can be automatically passed to service operations by binding them
62
+ directly when constructing the service object. To do this, pass the `params`
63
+ parameter to your constructed service with the map of default parameter
64
+ values like so:
65
+
66
+ ```javascript
67
+ var s3bucket = new AWS.S3({ params: {Bucket: 'myBucket'} });
68
+ ```
69
+
70
+ The `s3bucket` object will now represent an S3 service object bound to a bucket
71
+ named 'myBucket'. Any operation that takes the `Bucket` parameter will now
72
+ have it auto-filled with this value. This value can be overridden by passing
73
+ a new value in the service operation. Additionally, operations that do not
74
+ require a `Bucket` parameter will automatically ignore this bound parameter,
75
+ so the `s3bucket` object can still be used to call `listBuckets`, for instance.
@@ -0,0 +1,41 @@
1
+ # @title AWS SDK for JavaScript
2
+
3
+ # AWS SDK for JavaScript
4
+
5
+ <p class="subtitle">Available for browsers and mobile devices, or Node.js backends</p>
6
+
7
+ ## Developer Guide
8
+
9
+ <p class="note">
10
+ If you are upgrading from 1.x to 2.0 of the SDK, please see
11
+ the {file:UPGRADING.md} notes for information on how to migrate existing code
12
+ to work with the new major version.
13
+ </p>
14
+
15
+ The **AWS SDK for JavaScript** allows developers to build libraries or
16
+ applications that make use of AWS services using a simple and easy-to-use
17
+ API available both in the browser or inside of Node.js applications on the
18
+ server.
19
+
20
+ This guide will walk developers through many of the high level concepts
21
+ that the SDK provides, as well as provide example code to get started with
22
+ some services. For a more complete look at the classes and methods provided by
23
+ the library, it is recommended to look at the SDK's
24
+ [API reference documentation](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html).
25
+
26
+ Depending on the platform you are developing for, the installation guide
27
+ may be slightly different, but in both cases, usage of the SDK is the same.
28
+
29
+ ## Select a Platform
30
+
31
+ <div class="buttons">
32
+ {file:browser-intro.md JavaScript in the Browser}
33
+ {file:node-intro.md JavaScript in Node.js}
34
+ </div>
35
+ <div class="clear"></div>
36
+
37
+ If you are developing applications in the browser, please visit the
38
+ {file:browser-intro.md AWS SDK for JavaScript in the Browser} section.
39
+
40
+ If you are developing applications on the server side using Node.js, see the
41
+ {file:node-intro.md AWS SDK for Node.js} section.