aws-sdk 1.32.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (551) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +100 -0
  3. data/LICENSE.txt +199 -9
  4. data/VERSION +1 -0
  5. data/lib/aws-sdk.rb +2 -14
  6. metadata +22 -591
  7. data/.yardopts +0 -7
  8. data/README.md +0 -291
  9. data/bin/aws-rb +0 -169
  10. data/ca-bundle.crt +0 -3554
  11. data/endpoints.json +0 -1506
  12. data/lib/aws.rb +0 -14
  13. data/lib/aws/api_config/AutoScaling-2011-01-01.yml +0 -869
  14. data/lib/aws/api_config/CloudFormation-2010-05-15.yml +0 -358
  15. data/lib/aws/api_config/CloudFront-2013-05-12.yml +0 -2448
  16. data/lib/aws/api_config/CloudFront-2013-08-26.yml +0 -2599
  17. data/lib/aws/api_config/CloudFront-2013-09-27.yml +0 -2765
  18. data/lib/aws/api_config/CloudFront-2013-11-11.yml +0 -2886
  19. data/lib/aws/api_config/CloudSearch-2011-02-01.yml +0 -681
  20. data/lib/aws/api_config/CloudTrail-2013-11-01.yml +0 -159
  21. data/lib/aws/api_config/CloudWatch-2010-08-01.yml +0 -433
  22. data/lib/aws/api_config/DataPipeline-2012-10-29.yml +0 -422
  23. data/lib/aws/api_config/DirectConnect-2012-10-25.yml +0 -735
  24. data/lib/aws/api_config/DynamoDB-2011-12-05.yml +0 -1168
  25. data/lib/aws/api_config/DynamoDB-2012-08-10.yml +0 -2005
  26. data/lib/aws/api_config/EC2-2013-08-15.yml +0 -4708
  27. data/lib/aws/api_config/EC2-2013-10-01.yml +0 -4726
  28. data/lib/aws/api_config/EC2-2013-10-15.yml +0 -4726
  29. data/lib/aws/api_config/ELB-2012-06-01.yml +0 -632
  30. data/lib/aws/api_config/EMR-2009-03-31.yml +0 -953
  31. data/lib/aws/api_config/ElastiCache-2013-06-15.yml +0 -1188
  32. data/lib/aws/api_config/ElasticBeanstalk-2010-12-01.yml +0 -847
  33. data/lib/aws/api_config/ElasticTranscoder-2012-09-25.yml +0 -2285
  34. data/lib/aws/api_config/Glacier-2012-06-01.yml +0 -649
  35. data/lib/aws/api_config/IAM-2010-05-08.yml +0 -1297
  36. data/lib/aws/api_config/ImportExport-2010-06-01.yml +0 -109
  37. data/lib/aws/api_config/Kinesis-2013-12-02.yml +0 -201
  38. data/lib/aws/api_config/OpsWorks-2013-02-18.yml +0 -1825
  39. data/lib/aws/api_config/RDS-2013-05-15.yml +0 -2464
  40. data/lib/aws/api_config/RDS-2013-09-09.yml +0 -2641
  41. data/lib/aws/api_config/Redshift-2012-12-01.yml +0 -2137
  42. data/lib/aws/api_config/Route53-2012-12-12.yml +0 -547
  43. data/lib/aws/api_config/SNS-2010-03-31.yml +0 -433
  44. data/lib/aws/api_config/SQS-2012-11-05.yml +0 -319
  45. data/lib/aws/api_config/STS-2011-06-15.yml +0 -147
  46. data/lib/aws/api_config/SimpleDB-2009-04-15.yml +0 -306
  47. data/lib/aws/api_config/SimpleEmailService-2010-12-01.yml +0 -346
  48. data/lib/aws/api_config/SimpleWorkflow-2012-01-25.yml +0 -2388
  49. data/lib/aws/api_config/StorageGateway-2012-06-30.yml +0 -748
  50. data/lib/aws/api_config/StorageGateway-2013-06-30.yml +0 -1025
  51. data/lib/aws/api_config/Support-2013-04-15.yml +0 -426
  52. data/lib/aws/auto_scaling.rb +0 -163
  53. data/lib/aws/auto_scaling/activity.rb +0 -102
  54. data/lib/aws/auto_scaling/activity_collection.rb +0 -81
  55. data/lib/aws/auto_scaling/client.rb +0 -48
  56. data/lib/aws/auto_scaling/config.rb +0 -18
  57. data/lib/aws/auto_scaling/errors.rb +0 -22
  58. data/lib/aws/auto_scaling/group.rb +0 -421
  59. data/lib/aws/auto_scaling/group_collection.rb +0 -96
  60. data/lib/aws/auto_scaling/group_options.rb +0 -155
  61. data/lib/aws/auto_scaling/instance.rb +0 -192
  62. data/lib/aws/auto_scaling/instance_collection.rb +0 -63
  63. data/lib/aws/auto_scaling/launch_configuration.rb +0 -162
  64. data/lib/aws/auto_scaling/launch_configuration_collection.rb +0 -160
  65. data/lib/aws/auto_scaling/notification_configuration.rb +0 -89
  66. data/lib/aws/auto_scaling/notification_configuration_collection.rb +0 -183
  67. data/lib/aws/auto_scaling/scaling_policy.rb +0 -142
  68. data/lib/aws/auto_scaling/scaling_policy_collection.rb +0 -72
  69. data/lib/aws/auto_scaling/scaling_policy_options.rb +0 -65
  70. data/lib/aws/auto_scaling/scheduled_action.rb +0 -141
  71. data/lib/aws/auto_scaling/scheduled_action_collection.rb +0 -202
  72. data/lib/aws/auto_scaling/tag.rb +0 -59
  73. data/lib/aws/auto_scaling/tag_collection.rb +0 -114
  74. data/lib/aws/cloud_formation.rb +0 -272
  75. data/lib/aws/cloud_formation/client.rb +0 -48
  76. data/lib/aws/cloud_formation/config.rb +0 -18
  77. data/lib/aws/cloud_formation/errors.rb +0 -22
  78. data/lib/aws/cloud_formation/stack.rb +0 -266
  79. data/lib/aws/cloud_formation/stack_collection.rb +0 -232
  80. data/lib/aws/cloud_formation/stack_event.rb +0 -73
  81. data/lib/aws/cloud_formation/stack_event_collection.rb +0 -47
  82. data/lib/aws/cloud_formation/stack_options.rb +0 -72
  83. data/lib/aws/cloud_formation/stack_output.rb +0 -53
  84. data/lib/aws/cloud_formation/stack_resource.rb +0 -117
  85. data/lib/aws/cloud_formation/stack_resource_collection.rb +0 -83
  86. data/lib/aws/cloud_formation/stack_resource_summary_collection.rb +0 -64
  87. data/lib/aws/cloud_formation/stack_summary_collection.rb +0 -123
  88. data/lib/aws/cloud_front.rb +0 -72
  89. data/lib/aws/cloud_front/client.rb +0 -45
  90. data/lib/aws/cloud_front/config.rb +0 -18
  91. data/lib/aws/cloud_front/errors.rb +0 -22
  92. data/lib/aws/cloud_search.rb +0 -73
  93. data/lib/aws/cloud_search/client.rb +0 -36
  94. data/lib/aws/cloud_search/config.rb +0 -18
  95. data/lib/aws/cloud_search/errors.rb +0 -22
  96. data/lib/aws/cloud_trail.rb +0 -72
  97. data/lib/aws/cloud_trail/client.rb +0 -35
  98. data/lib/aws/cloud_trail/config.rb +0 -18
  99. data/lib/aws/cloud_trail/errors.rb +0 -22
  100. data/lib/aws/cloud_watch.rb +0 -118
  101. data/lib/aws/cloud_watch/alarm.rb +0 -290
  102. data/lib/aws/cloud_watch/alarm_collection.rb +0 -153
  103. data/lib/aws/cloud_watch/alarm_history_item.rb +0 -50
  104. data/lib/aws/cloud_watch/alarm_history_item_collection.rb +0 -84
  105. data/lib/aws/cloud_watch/client.rb +0 -40
  106. data/lib/aws/cloud_watch/config.rb +0 -18
  107. data/lib/aws/cloud_watch/errors.rb +0 -22
  108. data/lib/aws/cloud_watch/metric.rb +0 -135
  109. data/lib/aws/cloud_watch/metric_alarm_collection.rb +0 -160
  110. data/lib/aws/cloud_watch/metric_collection.rb +0 -129
  111. data/lib/aws/cloud_watch/metric_statistics.rb +0 -69
  112. data/lib/aws/core.rb +0 -701
  113. data/lib/aws/core/async_handle.rb +0 -90
  114. data/lib/aws/core/cacheable.rb +0 -77
  115. data/lib/aws/core/client.rb +0 -778
  116. data/lib/aws/core/collection.rb +0 -263
  117. data/lib/aws/core/collection/simple.rb +0 -82
  118. data/lib/aws/core/collection/with_limit_and_next_token.rb +0 -71
  119. data/lib/aws/core/collection/with_next_token.rb +0 -97
  120. data/lib/aws/core/configuration.rb +0 -541
  121. data/lib/aws/core/credential_providers.rb +0 -506
  122. data/lib/aws/core/data.rb +0 -247
  123. data/lib/aws/core/deprecations.rb +0 -84
  124. data/lib/aws/core/endpoints.rb +0 -37
  125. data/lib/aws/core/http/connection_pool.rb +0 -349
  126. data/lib/aws/core/http/curb_handler.rb +0 -148
  127. data/lib/aws/core/http/handler.rb +0 -89
  128. data/lib/aws/core/http/net_http_handler.rb +0 -147
  129. data/lib/aws/core/http/patch.rb +0 -102
  130. data/lib/aws/core/http/request.rb +0 -249
  131. data/lib/aws/core/http/response.rb +0 -81
  132. data/lib/aws/core/indifferent_hash.rb +0 -88
  133. data/lib/aws/core/inflection.rb +0 -56
  134. data/lib/aws/core/json_client.rb +0 -47
  135. data/lib/aws/core/json_parser.rb +0 -76
  136. data/lib/aws/core/json_request_builder.rb +0 -35
  137. data/lib/aws/core/json_response_parser.rb +0 -79
  138. data/lib/aws/core/lazy_error_classes.rb +0 -90
  139. data/lib/aws/core/log_formatter.rb +0 -428
  140. data/lib/aws/core/managed_file.rb +0 -32
  141. data/lib/aws/core/meta_utils.rb +0 -45
  142. data/lib/aws/core/model.rb +0 -57
  143. data/lib/aws/core/naming.rb +0 -30
  144. data/lib/aws/core/option_grammar.rb +0 -738
  145. data/lib/aws/core/options/json_serializer.rb +0 -82
  146. data/lib/aws/core/options/validator.rb +0 -155
  147. data/lib/aws/core/options/xml_serializer.rb +0 -118
  148. data/lib/aws/core/page_result.rb +0 -75
  149. data/lib/aws/core/policy.rb +0 -942
  150. data/lib/aws/core/query_client.rb +0 -41
  151. data/lib/aws/core/query_error_parser.rb +0 -24
  152. data/lib/aws/core/query_request_builder.rb +0 -47
  153. data/lib/aws/core/query_response_parser.rb +0 -35
  154. data/lib/aws/core/region.rb +0 -85
  155. data/lib/aws/core/region_collection.rb +0 -80
  156. data/lib/aws/core/resource.rb +0 -413
  157. data/lib/aws/core/resource_cache.rb +0 -40
  158. data/lib/aws/core/response.rb +0 -211
  159. data/lib/aws/core/response_cache.rb +0 -50
  160. data/lib/aws/core/rest_error_parser.rb +0 -24
  161. data/lib/aws/core/rest_json_client.rb +0 -40
  162. data/lib/aws/core/rest_request_builder.rb +0 -154
  163. data/lib/aws/core/rest_response_parser.rb +0 -66
  164. data/lib/aws/core/rest_xml_client.rb +0 -47
  165. data/lib/aws/core/service_interface.rb +0 -83
  166. data/lib/aws/core/signers/base.rb +0 -46
  167. data/lib/aws/core/signers/cloud_front.rb +0 -56
  168. data/lib/aws/core/signers/s3.rb +0 -159
  169. data/lib/aws/core/signers/version_2.rb +0 -72
  170. data/lib/aws/core/signers/version_3.rb +0 -86
  171. data/lib/aws/core/signers/version_3_https.rb +0 -61
  172. data/lib/aws/core/signers/version_4.rb +0 -228
  173. data/lib/aws/core/signers/version_4/chunk_signed_stream.rb +0 -191
  174. data/lib/aws/core/uri_escape.rb +0 -44
  175. data/lib/aws/core/xml/frame.rb +0 -244
  176. data/lib/aws/core/xml/frame_stack.rb +0 -85
  177. data/lib/aws/core/xml/grammar.rb +0 -306
  178. data/lib/aws/core/xml/parser.rb +0 -70
  179. data/lib/aws/core/xml/root_frame.rb +0 -65
  180. data/lib/aws/core/xml/sax_handlers/libxml.rb +0 -47
  181. data/lib/aws/core/xml/sax_handlers/nokogiri.rb +0 -56
  182. data/lib/aws/core/xml/sax_handlers/ox.rb +0 -41
  183. data/lib/aws/core/xml/sax_handlers/rexml.rb +0 -47
  184. data/lib/aws/core/xml/stub.rb +0 -123
  185. data/lib/aws/data_pipeline.rb +0 -72
  186. data/lib/aws/data_pipeline/client.rb +0 -36
  187. data/lib/aws/data_pipeline/config.rb +0 -18
  188. data/lib/aws/data_pipeline/errors.rb +0 -20
  189. data/lib/aws/direct_connect.rb +0 -73
  190. data/lib/aws/direct_connect/client.rb +0 -36
  191. data/lib/aws/direct_connect/config.rb +0 -18
  192. data/lib/aws/direct_connect/errors.rb +0 -22
  193. data/lib/aws/dynamo_db.rb +0 -214
  194. data/lib/aws/dynamo_db/attribute_collection.rb +0 -456
  195. data/lib/aws/dynamo_db/batch_get.rb +0 -213
  196. data/lib/aws/dynamo_db/batch_write.rb +0 -252
  197. data/lib/aws/dynamo_db/binary.rb +0 -35
  198. data/lib/aws/dynamo_db/client.rb +0 -129
  199. data/lib/aws/dynamo_db/client/v20111205.rb +0 -1266
  200. data/lib/aws/dynamo_db/client/v20120810.rb +0 -1409
  201. data/lib/aws/dynamo_db/client_v2.rb +0 -44
  202. data/lib/aws/dynamo_db/config.rb +0 -24
  203. data/lib/aws/dynamo_db/errors.rb +0 -20
  204. data/lib/aws/dynamo_db/expectations.rb +0 -40
  205. data/lib/aws/dynamo_db/item.rb +0 -133
  206. data/lib/aws/dynamo_db/item_collection.rb +0 -856
  207. data/lib/aws/dynamo_db/item_data.rb +0 -31
  208. data/lib/aws/dynamo_db/keys.rb +0 -41
  209. data/lib/aws/dynamo_db/primary_key_element.rb +0 -48
  210. data/lib/aws/dynamo_db/resource.rb +0 -33
  211. data/lib/aws/dynamo_db/table.rb +0 -496
  212. data/lib/aws/dynamo_db/table_collection.rb +0 -165
  213. data/lib/aws/dynamo_db/types.rb +0 -111
  214. data/lib/aws/ec2.rb +0 -428
  215. data/lib/aws/ec2/attachment.rb +0 -135
  216. data/lib/aws/ec2/attachment_collection.rb +0 -54
  217. data/lib/aws/ec2/availability_zone.rb +0 -86
  218. data/lib/aws/ec2/availability_zone_collection.rb +0 -43
  219. data/lib/aws/ec2/block_device_mappings.rb +0 -53
  220. data/lib/aws/ec2/client.rb +0 -101
  221. data/lib/aws/ec2/collection.rb +0 -36
  222. data/lib/aws/ec2/config.rb +0 -30
  223. data/lib/aws/ec2/customer_gateway.rb +0 -90
  224. data/lib/aws/ec2/customer_gateway_collection.rb +0 -73
  225. data/lib/aws/ec2/dhcp_options.rb +0 -106
  226. data/lib/aws/ec2/dhcp_options_collection.rb +0 -87
  227. data/lib/aws/ec2/elastic_ip.rb +0 -209
  228. data/lib/aws/ec2/elastic_ip_collection.rb +0 -93
  229. data/lib/aws/ec2/errors.rb +0 -32
  230. data/lib/aws/ec2/export_task.rb +0 -120
  231. data/lib/aws/ec2/export_task_collection.rb +0 -67
  232. data/lib/aws/ec2/filtered_collection.rb +0 -87
  233. data/lib/aws/ec2/has_permissions.rb +0 -44
  234. data/lib/aws/ec2/image.rb +0 -270
  235. data/lib/aws/ec2/image_collection.rb +0 -220
  236. data/lib/aws/ec2/instance.rb +0 -803
  237. data/lib/aws/ec2/instance_collection.rb +0 -391
  238. data/lib/aws/ec2/internet_gateway.rb +0 -122
  239. data/lib/aws/ec2/internet_gateway/attachment.rb +0 -78
  240. data/lib/aws/ec2/internet_gateway_collection.rb +0 -54
  241. data/lib/aws/ec2/key_pair.rb +0 -82
  242. data/lib/aws/ec2/key_pair_collection.rb +0 -99
  243. data/lib/aws/ec2/network_acl.rb +0 -256
  244. data/lib/aws/ec2/network_acl/association.rb +0 -56
  245. data/lib/aws/ec2/network_acl/entry.rb +0 -147
  246. data/lib/aws/ec2/network_acl_collection.rb +0 -64
  247. data/lib/aws/ec2/network_interface.rb +0 -237
  248. data/lib/aws/ec2/network_interface/attachment.rb +0 -100
  249. data/lib/aws/ec2/network_interface_collection.rb +0 -103
  250. data/lib/aws/ec2/permission_collection.rb +0 -174
  251. data/lib/aws/ec2/region.rb +0 -106
  252. data/lib/aws/ec2/region_collection.rb +0 -51
  253. data/lib/aws/ec2/reserved_instances.rb +0 -56
  254. data/lib/aws/ec2/reserved_instances_collection.rb +0 -40
  255. data/lib/aws/ec2/reserved_instances_offering.rb +0 -60
  256. data/lib/aws/ec2/reserved_instances_offering_collection.rb +0 -45
  257. data/lib/aws/ec2/resource.rb +0 -161
  258. data/lib/aws/ec2/resource_tag_collection.rb +0 -211
  259. data/lib/aws/ec2/route_table.rb +0 -205
  260. data/lib/aws/ec2/route_table/association.rb +0 -119
  261. data/lib/aws/ec2/route_table/route.rb +0 -119
  262. data/lib/aws/ec2/route_table_collection.rb +0 -72
  263. data/lib/aws/ec2/security_group.rb +0 -482
  264. data/lib/aws/ec2/security_group/ip_permission.rb +0 -135
  265. data/lib/aws/ec2/security_group/ip_permission_collection.rb +0 -82
  266. data/lib/aws/ec2/security_group_collection.rb +0 -133
  267. data/lib/aws/ec2/snapshot.rb +0 -143
  268. data/lib/aws/ec2/snapshot_collection.rb +0 -131
  269. data/lib/aws/ec2/subnet.rb +0 -161
  270. data/lib/aws/ec2/subnet_collection.rb +0 -115
  271. data/lib/aws/ec2/tag.rb +0 -81
  272. data/lib/aws/ec2/tag_collection.rb +0 -107
  273. data/lib/aws/ec2/tagged_collection.rb +0 -53
  274. data/lib/aws/ec2/tagged_item.rb +0 -85
  275. data/lib/aws/ec2/volume.rb +0 -174
  276. data/lib/aws/ec2/volume_collection.rb +0 -98
  277. data/lib/aws/ec2/vpc.rb +0 -166
  278. data/lib/aws/ec2/vpc_collection.rb +0 -70
  279. data/lib/aws/ec2/vpn_connection.rb +0 -99
  280. data/lib/aws/ec2/vpn_connection/telemetry.rb +0 -49
  281. data/lib/aws/ec2/vpn_connection_collection.rb +0 -96
  282. data/lib/aws/ec2/vpn_gateway.rb +0 -123
  283. data/lib/aws/ec2/vpn_gateway/attachment.rb +0 -45
  284. data/lib/aws/ec2/vpn_gateway_collection.rb +0 -77
  285. data/lib/aws/elastic_beanstalk.rb +0 -49
  286. data/lib/aws/elastic_beanstalk/client.rb +0 -36
  287. data/lib/aws/elastic_beanstalk/config.rb +0 -18
  288. data/lib/aws/elastic_beanstalk/errors.rb +0 -22
  289. data/lib/aws/elastic_transcoder.rb +0 -29
  290. data/lib/aws/elastic_transcoder/client.rb +0 -48
  291. data/lib/aws/elastic_transcoder/config.rb +0 -18
  292. data/lib/aws/elastic_transcoder/errors.rb +0 -23
  293. data/lib/aws/elasticache.rb +0 -49
  294. data/lib/aws/elasticache/client.rb +0 -35
  295. data/lib/aws/elasticache/config.rb +0 -18
  296. data/lib/aws/elasticache/errors.rb +0 -22
  297. data/lib/aws/elb.rb +0 -66
  298. data/lib/aws/elb/availability_zone_collection.rb +0 -138
  299. data/lib/aws/elb/backend_server_policy_collection.rb +0 -139
  300. data/lib/aws/elb/client.rb +0 -35
  301. data/lib/aws/elb/config.rb +0 -18
  302. data/lib/aws/elb/errors.rb +0 -26
  303. data/lib/aws/elb/instance_collection.rb +0 -168
  304. data/lib/aws/elb/listener.rb +0 -190
  305. data/lib/aws/elb/listener_collection.rb +0 -113
  306. data/lib/aws/elb/listener_opts.rb +0 -45
  307. data/lib/aws/elb/load_balancer.rb +0 -280
  308. data/lib/aws/elb/load_balancer_collection.rb +0 -146
  309. data/lib/aws/elb/load_balancer_policy.rb +0 -93
  310. data/lib/aws/elb/load_balancer_policy_collection.rb +0 -208
  311. data/lib/aws/emr.rb +0 -87
  312. data/lib/aws/emr/client.rb +0 -35
  313. data/lib/aws/emr/config.rb +0 -18
  314. data/lib/aws/emr/errors.rb +0 -22
  315. data/lib/aws/emr/instance_group.rb +0 -138
  316. data/lib/aws/emr/instance_group_collection.rb +0 -82
  317. data/lib/aws/emr/job_flow.rb +0 -307
  318. data/lib/aws/emr/job_flow_collection.rb +0 -185
  319. data/lib/aws/errors.rb +0 -162
  320. data/lib/aws/glacier.rb +0 -79
  321. data/lib/aws/glacier/archive.rb +0 -56
  322. data/lib/aws/glacier/archive_collection.rb +0 -146
  323. data/lib/aws/glacier/client.rb +0 -49
  324. data/lib/aws/glacier/config.rb +0 -19
  325. data/lib/aws/glacier/errors.rb +0 -22
  326. data/lib/aws/glacier/resource.rb +0 -30
  327. data/lib/aws/glacier/vault.rb +0 -145
  328. data/lib/aws/glacier/vault_collection.rb +0 -75
  329. data/lib/aws/glacier/vault_notification_configuration.rb +0 -29
  330. data/lib/aws/iam.rb +0 -408
  331. data/lib/aws/iam/access_key.rb +0 -185
  332. data/lib/aws/iam/access_key_collection.rb +0 -128
  333. data/lib/aws/iam/account_alias_collection.rb +0 -79
  334. data/lib/aws/iam/client.rb +0 -49
  335. data/lib/aws/iam/collection.rb +0 -83
  336. data/lib/aws/iam/config.rb +0 -18
  337. data/lib/aws/iam/errors.rb +0 -22
  338. data/lib/aws/iam/group.rb +0 -111
  339. data/lib/aws/iam/group_collection.rb +0 -132
  340. data/lib/aws/iam/group_policy_collection.rb +0 -47
  341. data/lib/aws/iam/group_user_collection.rb +0 -84
  342. data/lib/aws/iam/login_profile.rb +0 -99
  343. data/lib/aws/iam/mfa_device.rb +0 -52
  344. data/lib/aws/iam/mfa_device_collection.rb +0 -127
  345. data/lib/aws/iam/policy.rb +0 -46
  346. data/lib/aws/iam/policy_collection.rb +0 -188
  347. data/lib/aws/iam/resource.rb +0 -62
  348. data/lib/aws/iam/server_certificate.rb +0 -141
  349. data/lib/aws/iam/server_certificate_collection.rb +0 -138
  350. data/lib/aws/iam/signing_certificate.rb +0 -174
  351. data/lib/aws/iam/signing_certificate_collection.rb +0 -131
  352. data/lib/aws/iam/user.rb +0 -200
  353. data/lib/aws/iam/user_collection.rb +0 -133
  354. data/lib/aws/iam/user_group_collection.rb +0 -98
  355. data/lib/aws/iam/user_policy.rb +0 -90
  356. data/lib/aws/iam/user_policy_collection.rb +0 -45
  357. data/lib/aws/iam/virtual_mfa_device.rb +0 -139
  358. data/lib/aws/iam/virtual_mfa_device_collection.rb +0 -73
  359. data/lib/aws/import_export.rb +0 -73
  360. data/lib/aws/import_export/client.rb +0 -35
  361. data/lib/aws/import_export/config.rb +0 -19
  362. data/lib/aws/import_export/errors.rb +0 -22
  363. data/lib/aws/kinesis.rb +0 -53
  364. data/lib/aws/kinesis/client.rb +0 -35
  365. data/lib/aws/kinesis/config.rb +0 -18
  366. data/lib/aws/kinesis/errors.rb +0 -20
  367. data/lib/aws/ops_works.rb +0 -29
  368. data/lib/aws/ops_works/client.rb +0 -35
  369. data/lib/aws/ops_works/config.rb +0 -18
  370. data/lib/aws/ops_works/errors.rb +0 -20
  371. data/lib/aws/rails.rb +0 -195
  372. data/lib/aws/rds.rb +0 -70
  373. data/lib/aws/rds/client.rb +0 -42
  374. data/lib/aws/rds/config.rb +0 -18
  375. data/lib/aws/rds/db_instance.rb +0 -216
  376. data/lib/aws/rds/db_instance_collection.rb +0 -75
  377. data/lib/aws/rds/db_snapshot.rb +0 -163
  378. data/lib/aws/rds/db_snapshot_collection.rb +0 -89
  379. data/lib/aws/rds/errors.rb +0 -22
  380. data/lib/aws/record.rb +0 -139
  381. data/lib/aws/record/abstract_base.rb +0 -690
  382. data/lib/aws/record/attributes.rb +0 -388
  383. data/lib/aws/record/conversion.rb +0 -38
  384. data/lib/aws/record/dirty_tracking.rb +0 -287
  385. data/lib/aws/record/errors.rb +0 -143
  386. data/lib/aws/record/exceptions.rb +0 -51
  387. data/lib/aws/record/hash_model.rb +0 -204
  388. data/lib/aws/record/hash_model/attributes.rb +0 -195
  389. data/lib/aws/record/hash_model/finder_methods.rb +0 -172
  390. data/lib/aws/record/hash_model/scope.rb +0 -108
  391. data/lib/aws/record/model.rb +0 -453
  392. data/lib/aws/record/model/attributes.rb +0 -377
  393. data/lib/aws/record/model/finder_methods.rb +0 -232
  394. data/lib/aws/record/model/scope.rb +0 -212
  395. data/lib/aws/record/naming.rb +0 -31
  396. data/lib/aws/record/scope.rb +0 -203
  397. data/lib/aws/record/validations.rb +0 -694
  398. data/lib/aws/record/validator.rb +0 -246
  399. data/lib/aws/record/validators/acceptance.rb +0 -49
  400. data/lib/aws/record/validators/block.rb +0 -36
  401. data/lib/aws/record/validators/confirmation.rb +0 -41
  402. data/lib/aws/record/validators/count.rb +0 -106
  403. data/lib/aws/record/validators/exclusion.rb +0 -41
  404. data/lib/aws/record/validators/format.rb +0 -55
  405. data/lib/aws/record/validators/inclusion.rb +0 -54
  406. data/lib/aws/record/validators/length.rb +0 -105
  407. data/lib/aws/record/validators/method.rb +0 -31
  408. data/lib/aws/record/validators/numericality.rb +0 -136
  409. data/lib/aws/record/validators/presence.rb +0 -43
  410. data/lib/aws/redshift.rb +0 -51
  411. data/lib/aws/redshift/client.rb +0 -35
  412. data/lib/aws/redshift/config.rb +0 -18
  413. data/lib/aws/redshift/errors.rb +0 -22
  414. data/lib/aws/route_53.rb +0 -86
  415. data/lib/aws/route_53/change_batch.rb +0 -161
  416. data/lib/aws/route_53/change_info.rb +0 -72
  417. data/lib/aws/route_53/client.rb +0 -35
  418. data/lib/aws/route_53/config.rb +0 -18
  419. data/lib/aws/route_53/errors.rb +0 -22
  420. data/lib/aws/route_53/hosted_zone.rb +0 -111
  421. data/lib/aws/route_53/hosted_zone_collection.rb +0 -100
  422. data/lib/aws/route_53/resource_record_set.rb +0 -251
  423. data/lib/aws/route_53/resource_record_set_collection.rb +0 -110
  424. data/lib/aws/s3.rb +0 -156
  425. data/lib/aws/s3/access_control_list.rb +0 -265
  426. data/lib/aws/s3/acl_object.rb +0 -264
  427. data/lib/aws/s3/acl_options.rb +0 -204
  428. data/lib/aws/s3/bucket.rb +0 -742
  429. data/lib/aws/s3/bucket_collection.rb +0 -162
  430. data/lib/aws/s3/bucket_lifecycle_configuration.rb +0 -457
  431. data/lib/aws/s3/bucket_tag_collection.rb +0 -111
  432. data/lib/aws/s3/bucket_version_collection.rb +0 -79
  433. data/lib/aws/s3/cipher_io.rb +0 -120
  434. data/lib/aws/s3/client.rb +0 -1919
  435. data/lib/aws/s3/client/xml.rb +0 -259
  436. data/lib/aws/s3/config.rb +0 -48
  437. data/lib/aws/s3/cors_rule.rb +0 -108
  438. data/lib/aws/s3/cors_rule_collection.rb +0 -194
  439. data/lib/aws/s3/data_options.rb +0 -191
  440. data/lib/aws/s3/encryption_utils.rb +0 -146
  441. data/lib/aws/s3/errors.rb +0 -94
  442. data/lib/aws/s3/multipart_upload.rb +0 -351
  443. data/lib/aws/s3/multipart_upload_collection.rb +0 -76
  444. data/lib/aws/s3/object_collection.rb +0 -353
  445. data/lib/aws/s3/object_metadata.rb +0 -103
  446. data/lib/aws/s3/object_upload_collection.rb +0 -77
  447. data/lib/aws/s3/object_version.rb +0 -154
  448. data/lib/aws/s3/object_version_collection.rb +0 -89
  449. data/lib/aws/s3/paginated_collection.rb +0 -75
  450. data/lib/aws/s3/policy.rb +0 -74
  451. data/lib/aws/s3/prefix_and_delimiter_collection.rb +0 -47
  452. data/lib/aws/s3/prefixed_collection.rb +0 -85
  453. data/lib/aws/s3/presign_v4.rb +0 -127
  454. data/lib/aws/s3/presigned_post.rb +0 -554
  455. data/lib/aws/s3/request.rb +0 -62
  456. data/lib/aws/s3/s3_object.rb +0 -1781
  457. data/lib/aws/s3/tree.rb +0 -116
  458. data/lib/aws/s3/tree/branch_node.rb +0 -68
  459. data/lib/aws/s3/tree/child_collection.rb +0 -104
  460. data/lib/aws/s3/tree/leaf_node.rb +0 -94
  461. data/lib/aws/s3/tree/node.rb +0 -22
  462. data/lib/aws/s3/tree/parent.rb +0 -87
  463. data/lib/aws/s3/uploaded_part.rb +0 -82
  464. data/lib/aws/s3/uploaded_part_collection.rb +0 -84
  465. data/lib/aws/s3/website_configuration.rb +0 -102
  466. data/lib/aws/simple_db.rb +0 -218
  467. data/lib/aws/simple_db/attribute.rb +0 -156
  468. data/lib/aws/simple_db/attribute_collection.rb +0 -240
  469. data/lib/aws/simple_db/client.rb +0 -67
  470. data/lib/aws/simple_db/config.rb +0 -20
  471. data/lib/aws/simple_db/consistent_read_option.rb +0 -42
  472. data/lib/aws/simple_db/delete_attributes.rb +0 -62
  473. data/lib/aws/simple_db/domain.rb +0 -123
  474. data/lib/aws/simple_db/domain_collection.rb +0 -86
  475. data/lib/aws/simple_db/domain_metadata.rb +0 -110
  476. data/lib/aws/simple_db/errors.rb +0 -55
  477. data/lib/aws/simple_db/expect_condition_option.rb +0 -45
  478. data/lib/aws/simple_db/item.rb +0 -93
  479. data/lib/aws/simple_db/item_collection.rb +0 -654
  480. data/lib/aws/simple_db/item_data.rb +0 -73
  481. data/lib/aws/simple_db/put_attributes.rb +0 -60
  482. data/lib/aws/simple_email_service.rb +0 -430
  483. data/lib/aws/simple_email_service/client.rb +0 -37
  484. data/lib/aws/simple_email_service/config.rb +0 -18
  485. data/lib/aws/simple_email_service/email_address_collection.rb +0 -69
  486. data/lib/aws/simple_email_service/errors.rb +0 -22
  487. data/lib/aws/simple_email_service/identity.rb +0 -209
  488. data/lib/aws/simple_email_service/identity_collection.rb +0 -81
  489. data/lib/aws/simple_email_service/quotas.rb +0 -66
  490. data/lib/aws/simple_workflow.rb +0 -227
  491. data/lib/aws/simple_workflow/activity_task.rb +0 -178
  492. data/lib/aws/simple_workflow/activity_task_collection.rb +0 -123
  493. data/lib/aws/simple_workflow/activity_type.rb +0 -131
  494. data/lib/aws/simple_workflow/activity_type_collection.rb +0 -93
  495. data/lib/aws/simple_workflow/client.rb +0 -69
  496. data/lib/aws/simple_workflow/config.rb +0 -18
  497. data/lib/aws/simple_workflow/count.rb +0 -49
  498. data/lib/aws/simple_workflow/decision_task.rb +0 -603
  499. data/lib/aws/simple_workflow/decision_task_collection.rb +0 -225
  500. data/lib/aws/simple_workflow/domain.rb +0 -122
  501. data/lib/aws/simple_workflow/domain_collection.rb +0 -169
  502. data/lib/aws/simple_workflow/errors.rb +0 -20
  503. data/lib/aws/simple_workflow/history_event.rb +0 -276
  504. data/lib/aws/simple_workflow/history_event_collection.rb +0 -76
  505. data/lib/aws/simple_workflow/option_formatters.rb +0 -82
  506. data/lib/aws/simple_workflow/resource.rb +0 -94
  507. data/lib/aws/simple_workflow/type.rb +0 -89
  508. data/lib/aws/simple_workflow/type_collection.rb +0 -140
  509. data/lib/aws/simple_workflow/workflow_execution.rb +0 -384
  510. data/lib/aws/simple_workflow/workflow_execution_collection.rb +0 -617
  511. data/lib/aws/simple_workflow/workflow_type.rb +0 -179
  512. data/lib/aws/simple_workflow/workflow_type_collection.rb +0 -91
  513. data/lib/aws/sns.rb +0 -76
  514. data/lib/aws/sns/client.rb +0 -35
  515. data/lib/aws/sns/config.rb +0 -18
  516. data/lib/aws/sns/errors.rb +0 -22
  517. data/lib/aws/sns/has_delivery_policy.rb +0 -68
  518. data/lib/aws/sns/message.rb +0 -194
  519. data/lib/aws/sns/originators/from_auto_scaling.rb +0 -68
  520. data/lib/aws/sns/policy.rb +0 -47
  521. data/lib/aws/sns/subscription.rb +0 -165
  522. data/lib/aws/sns/subscription_collection.rb +0 -78
  523. data/lib/aws/sns/topic.rb +0 -403
  524. data/lib/aws/sns/topic_collection.rb +0 -62
  525. data/lib/aws/sns/topic_subscription_collection.rb +0 -54
  526. data/lib/aws/sqs.rb +0 -80
  527. data/lib/aws/sqs/client.rb +0 -53
  528. data/lib/aws/sqs/config.rb +0 -20
  529. data/lib/aws/sqs/errors.rb +0 -125
  530. data/lib/aws/sqs/policy.rb +0 -48
  531. data/lib/aws/sqs/queue.rb +0 -843
  532. data/lib/aws/sqs/queue_collection.rb +0 -182
  533. data/lib/aws/sqs/received_message.rb +0 -182
  534. data/lib/aws/sqs/received_sns_message.rb +0 -116
  535. data/lib/aws/storage_gateway.rb +0 -72
  536. data/lib/aws/storage_gateway/client.rb +0 -42
  537. data/lib/aws/storage_gateway/config.rb +0 -18
  538. data/lib/aws/storage_gateway/errors.rb +0 -22
  539. data/lib/aws/sts.rb +0 -164
  540. data/lib/aws/sts/client.rb +0 -46
  541. data/lib/aws/sts/config.rb +0 -18
  542. data/lib/aws/sts/errors.rb +0 -22
  543. data/lib/aws/sts/federated_session.rb +0 -56
  544. data/lib/aws/sts/policy.rb +0 -30
  545. data/lib/aws/sts/session.rb +0 -48
  546. data/lib/aws/support.rb +0 -29
  547. data/lib/aws/support/client.rb +0 -35
  548. data/lib/aws/support/config.rb +0 -18
  549. data/lib/aws/support/errors.rb +0 -20
  550. data/lib/aws/version.rb +0 -17
  551. data/rails/init.rb +0 -15
@@ -1,111 +0,0 @@
1
- # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- module AWS
15
- class S3
16
-
17
- # Manages tags for a single S3 {Bucket}.
18
- #
19
- # @example Setting a tag.
20
- #
21
- # bucket.tags['key'] = 'value'
22
- #
23
- # @example Getting a tag.
24
- #
25
- # bucket.tags['key']
26
- # #=> 'value'
27
- #
28
- # @example Getting all tags
29
- #
30
- # bucket.tags.to_h
31
- # #=> { 'key' => 'value', ... }
32
- #
33
- # @example Removing all tags
34
- #
35
- # bucket.tags.clear
36
- #
37
- class BucketTagCollection
38
-
39
- include Core::Model
40
-
41
- # @param [Bucket] bucket
42
- # @param [Hash] options
43
- def initialize bucket, options = {}
44
- @bucket = bucket
45
- super
46
- end
47
-
48
- # @return [Bucket]
49
- attr_reader :bucket
50
-
51
- # @param [String] key
52
- # @return [String,nil] Returns the tag for the given key. If there
53
- # Returns `nil` if the key does not exist.
54
- def [] key
55
- self.to_h[key]
56
- end
57
-
58
- # @param [String] key
59
- # @param [String] value
60
- def []= key, value
61
- self.set(self.to_h.merge(key => value))
62
- end
63
-
64
- # @param [Hash<String,String>] tags A hash of tag keys and values.
65
- # @return [nil]
66
- def set tags
67
- if tags.nil? or tags.empty?
68
- self.clear
69
- else
70
- client.put_bucket_tagging(:bucket_name => bucket.name, :tags => tags)
71
- end
72
- nil
73
- end
74
-
75
- # Removes all tags from the bucket.
76
- #
77
- # @example
78
- #
79
- # bucket.tags.clear
80
- # bucket.tags.to_h #=> {}
81
- #
82
- # @return [nil]
83
- def clear
84
- client.delete_bucket_tagging(:bucket_name => bucket.name)
85
- nil
86
- end
87
-
88
- # @return [Hash]
89
- def to_h
90
- client.get_bucket_tagging(:bucket_name => bucket.name).data[:tags]
91
- rescue AWS::S3::Errors::NoSuchTagSet
92
- {}
93
- end
94
- alias_method :to_hash, :to_h
95
-
96
- # @param [Hash] other
97
- # @return [Boolean] Returns `true` if the tags for this bucket match
98
- # the passed hash.
99
- def eql? other
100
- self.to_h == other
101
- end
102
- alias_method :==, :eql?
103
-
104
- # @api private
105
- def inspect
106
- self.to_h.inspect
107
- end
108
-
109
- end
110
- end
111
- end
@@ -1,79 +0,0 @@
1
- # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- module AWS
15
- class S3
16
-
17
- # A collection of versioned objects for the entire bucket.
18
- #
19
- # @see PrefixedCollection
20
- class BucketVersionCollection
21
-
22
- include PrefixAndDelimiterCollection
23
-
24
- # @param [Bucket] bucket
25
- def initialize bucket, options = {}
26
- @bucket = bucket
27
- super
28
- end
29
-
30
- # @return [Bucket] The bucket this collection belongs to.
31
- attr_reader :bucket
32
-
33
- # @return [ObjectVersion] Returns the most recently created object
34
- # version in the entire bucket.
35
- def latest
36
- first
37
- #self.find{|version| true }
38
- end
39
-
40
- # Yields once for each version in the bucket.
41
- #
42
- # @yield [object_version]
43
- #
44
- # @yieldparam [ObjectVersion] object_version
45
- #
46
- # @return nil
47
- #
48
- def each options = {}, &block; super; end
49
-
50
- # @api private
51
- protected
52
- def each_member_in_page(page, &block)
53
- super
54
- page.versions.each do |version|
55
- object_version = ObjectVersion.new(bucket.objects[version.key],
56
- version.version_id,
57
- :delete_marker => version.delete_marker?,
58
- :last_modified => version.last_modified)
59
- yield(object_version)
60
- end
61
- end
62
-
63
- # @api private
64
- protected
65
- def list_request(options)
66
- client.list_object_versions(options)
67
- end
68
-
69
- # @api private
70
- protected
71
- def limit_param; :max_keys; end
72
-
73
- # @api private
74
- protected
75
- def pagination_markers; super + [:version_id_marker]; end
76
-
77
- end
78
- end
79
- end
@@ -1,120 +0,0 @@
1
- # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- module AWS
15
- class S3
16
-
17
- # @api private
18
- class CipherIO
19
-
20
- def initialize cipher, stream, stream_size = nil
21
-
22
- @stream = stream
23
- @stream_size = stream_size
24
- @orig_cipher = cipher.clone
25
-
26
- reset_cipher
27
-
28
- # add a #rewind method if the original stream can be rewound
29
- if @stream.respond_to?(:rewind)
30
- Core::MetaUtils.extend_method(self, :rewind) do
31
- reset_cipher
32
- @stream.rewind
33
- end
34
- end
35
-
36
- # add a #size method if the stream size is known
37
- if stream_size
38
- Core::MetaUtils.extend_method(self, :size) do
39
- EncryptionUtils.get_encrypted_size(@stream_size)
40
- end
41
- end
42
-
43
- end
44
-
45
- # @return [String] Returns the requested number of bytes. If no byte
46
- # amount is given, it will return the entire body of encrypted data
47
- def read bytes = nil, output_buffer = nil
48
- data = if bytes
49
- (@eof) ? nil : read_chunk(bytes)
50
- else
51
- (@eof) ? "" : read_all
52
- end
53
- output_buffer ? output_buffer.replace(data || '') : data
54
- end
55
-
56
- # @return [Boolean] Returns `true` when the entire stream has been read.
57
- def eof?
58
- @eof
59
- end
60
-
61
- private
62
-
63
- attr_reader :cipher
64
-
65
- # Sets the CipherIO in a reset state without having to know anything
66
- # about the cipher
67
- def reset_cipher
68
- @cipher = @orig_cipher.clone
69
- @eof = false
70
- @final = nil
71
- end
72
-
73
- # @return [String] Returns an encrytped chunk
74
- def read_chunk bytes
75
- unless @final
76
- # If given a number of bytes, read it out and work out encryption
77
- # issues
78
- chunk = @stream.read(bytes)
79
-
80
- # If there is nothing, finish the encryption
81
- if chunk and chunk.length > 0
82
- handle_finish(bytes, cipher.update(chunk))
83
- else
84
- @eof = true
85
- cipher.final
86
- end
87
- # Read as much as possible if not given a byte size
88
- else
89
- @eof = true
90
- @final
91
- end
92
- end
93
-
94
- # @return [String] Returns the entire encrypted data
95
- def read_all
96
- @eof = true
97
- body = @stream.read()
98
- data = (body and body.length > 0) ? cipher.update(body) : ""
99
- data << cipher.final
100
- end
101
-
102
- # Figures out how much of the final block goes into the current chunk
103
- # and adds it.
104
- # @return [String] Returns the encrypted chunk with possible padding.
105
- def handle_finish(bytes, chunk)
106
- free_space = bytes - chunk.size
107
-
108
- if free_space > 0
109
- @final = cipher.final
110
- chunk << @final[0..free_space-1]
111
- @final = @final[free_space-1..@final.size-1]
112
- @eof = true unless @final and @final.size > 0
113
- end
114
-
115
- chunk
116
- end
117
-
118
- end
119
- end
120
- end
data/lib/aws/s3/client.rb DELETED
@@ -1,1919 +0,0 @@
1
- # Copyright 2011-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You
4
- # may not use this file except in compliance with the License. A copy of
5
- # the License is located at
6
- #
7
- # http://aws.amazon.com/apache2.0/
8
- #
9
- # or in the "license" file accompanying this file. This file is
10
- # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
- # ANY KIND, either express or implied. See the License for the specific
12
- # language governing permissions and limitations under the License.
13
-
14
- require 'rexml/document'
15
- require 'pathname'
16
- require 'stringio'
17
- require 'json'
18
- require 'digest/md5'
19
- require 'base64'
20
- require 'nokogiri'
21
-
22
- module AWS
23
- class S3
24
-
25
- # Client class for Amazon Simple Storage Service (S3).
26
- class Client < Core::Client
27
-
28
- signature_version :S3
29
-
30
- API_VERSION = '2006-03-01'
31
-
32
- XMLNS = "http://s3.amazonaws.com/doc/#{API_VERSION}/"
33
-
34
- autoload :XML, 'aws/s3/client/xml'
35
-
36
- # @api private
37
- EMPTY_BODY_ERRORS = {
38
- 304 => Errors::NotModified,
39
- 403 => Errors::Forbidden,
40
- 400 => Errors::BadRequest,
41
- 404 => Errors::NoSuchKey,
42
- }
43
-
44
- # @api private
45
- CACHEABLE_REQUESTS = Set[]
46
-
47
- include DataOptions
48
- include Core::UriEscape
49
-
50
- # @param [Core::Http::Request] request
51
- # @api private
52
- def sign_request request
53
- version = @config.s3_signature_version ?
54
- @config.s3_signature_version.to_sym :
55
- (@region =~ /cn-/ ? :v4 : :v3)
56
- case version
57
- when :v4 then v4_signer.sign_request(request)
58
- when :v3 then v3_signer.sign_request(request)
59
- else
60
- raise "invalid signature version #{version.inspect}"
61
- end
62
- end
63
-
64
- protected
65
-
66
- # @return [Core::Signers::S3]
67
- def v3_signer
68
- @v3_signer ||= Core::Signers::S3.new(credential_provider)
69
- end
70
-
71
- # @return [Core::Signers::Version4]
72
- def v4_signer
73
- @v4_signer ||= begin
74
- Core::Signers::Version4.new(credential_provider, 's3', @region)
75
- end
76
- end
77
-
78
- # @param [Http::Request] req
79
- # @return [Boolean]
80
- def chunk_sign? req
81
- req.http_method == 'PUT' &&
82
- req.headers['content-length'].to_i > 2 * 1024 * 1024 # 2MB
83
- end
84
-
85
- def self.bucket_method(method_name, verb, *args, &block)
86
-
87
- method_options = (args.pop if args.last.kind_of?(Hash)) || {}
88
- xml_grammar = (args.pop if args.last.respond_to?(:rules))
89
- verb = verb.to_s.upcase
90
- subresource = args.first
91
-
92
- add_client_request_method(method_name) do
93
-
94
- configure_request do |req, options|
95
-
96
- require_bucket_name!(options[:bucket_name])
97
-
98
- req.http_method = verb
99
- req.bucket = options[:bucket_name]
100
- req.add_param(subresource) if subresource
101
-
102
- if header_options = method_options[:header_options]
103
- header_options.each do |(opt, header)|
104
- if value = options[opt]
105
- # for backwards compatability we translate canned acls
106
- # header values from symbols to strings (e.g.
107
- # :public_read translates to 'public-read')
108
- value = (opt == :acl ? value.to_s.tr('_', '-') : value)
109
- req.headers[header] = value
110
- end
111
- end
112
- end
113
-
114
- end
115
-
116
- instance_eval(&block) if block
117
-
118
- if xml_grammar
119
-
120
- parser = Core::XML::Parser.new(xml_grammar.rules)
121
-
122
- process_response do |resp|
123
- resp.data = parser.parse(resp.http_response.body)
124
- super(resp)
125
- end
126
-
127
- simulate_response do |resp|
128
- resp.data = parser.simulate
129
- super(resp)
130
- end
131
-
132
- end
133
-
134
- end
135
- end
136
-
137
- protected
138
-
139
- def set_metadata request, options
140
- if metadata = options[:metadata]
141
- Array(metadata).each do |name, value|
142
- request.headers["x-amz-meta-#{name}"] = value
143
- end
144
- end
145
- end
146
-
147
- def set_storage_class request, options
148
- storage_class = options[:storage_class]
149
- if storage_class.kind_of?(Symbol)
150
- request.headers["x-amz-storage-class"] = storage_class.to_s.upcase
151
- elsif storage_class
152
- request.headers["x-amz-storage-class"] = storage_class
153
- end
154
- end
155
-
156
- def set_server_side_encryption request, options
157
- sse = options[:server_side_encryption]
158
- if sse.is_a?(Symbol)
159
- request.headers['x-amz-server-side-encryption'] = sse.to_s.upcase
160
- elsif sse
161
- request.headers['x-amz-server-side-encryption'] = sse
162
- end
163
- end
164
-
165
- def extract_error_details response
166
- if
167
- (response.http_response.status >= 300 ||
168
- response.request_type == :complete_multipart_upload) and
169
- body = response.http_response.body and
170
- error = Core::XML::Parser.parse(body) and
171
- error[:code]
172
- then
173
- [error[:code], error[:message]]
174
- end
175
- end
176
-
177
- def empty_response_body? response_body
178
- response_body.nil? or response_body == ''
179
- end
180
-
181
- # There are a few of s3 requests that can generate empty bodies and
182
- # yet still be errors. These return empty bodies to comply with the
183
- # HTTP spec. We have to detect these errors specially.
184
- def populate_error resp
185
- code = resp.http_response.status
186
- if EMPTY_BODY_ERRORS.include?(code) and empty_response_body?(resp.http_response.body)
187
- error_class = EMPTY_BODY_ERRORS[code]
188
- resp.error = error_class.new(resp.http_request, resp.http_response)
189
- else
190
- super
191
- end
192
- end
193
-
194
- def retryable_error? response
195
- super or
196
- failed_multipart_upload?(response) or
197
- response.error.is_a?(Errors::RequestTimeout)
198
- end
199
-
200
- # S3 may return a 200 response code in response to complete_multipart_upload
201
- # and then start streaming whitespace until it knows the final result.
202
- # At that time it sends an XML message with success or failure.
203
- def failed_multipart_upload? response
204
- response.request_type == :complete_multipart_upload &&
205
- extract_error_details(response)
206
- end
207
-
208
- def new_request
209
- req = S3::Request.new
210
- req.force_path_style = config.s3_force_path_style?
211
- req
212
- end
213
-
214
- # Previously the access control policy could be specified via :acl
215
- # as a string or an object that responds to #to_xml. The prefered
216
- # method now is to pass :access_control_policy an xml document.
217
- def move_access_control_policy options
218
- if acl = options[:acl]
219
- if acl.is_a?(String) and is_xml?(acl)
220
- options[:access_control_policy] = options.delete(:acl)
221
- elsif acl.respond_to?(:to_xml)
222
- options[:access_control_policy] = options.delete(:acl).to_xml
223
- end
224
- end
225
- end
226
-
227
- # @param [String] possible_xml
228
- # @return [Boolean] Returns `true` if the given string is a valid xml
229
- # document.
230
- def is_xml? possible_xml
231
- begin
232
- REXML::Document.new(possible_xml).has_elements?
233
- rescue
234
- false
235
- end
236
- end
237
-
238
- def md5 str
239
- Base64.encode64(Digest::MD5.digest(str)).strip
240
- end
241
-
242
- def parse_copy_part_response resp
243
- doc = REXML::Document.new(resp.http_response.body)
244
- resp[:etag] = doc.root.elements["ETag"].text
245
- resp[:last_modified] = doc.root.elements["LastModified"].text
246
- if header = resp.http_response.headers['x-amzn-requestid']
247
- data[:request_id] = [header].flatten.first
248
- end
249
- end
250
-
251
- def extract_object_headers resp
252
- meta = {}
253
- resp.http_response.headers.each_pair do |name,value|
254
- if name =~ /^x-amz-meta-(.+)$/i
255
- meta[$1] = [value].flatten.join
256
- end
257
- end
258
- resp.data[:meta] = meta
259
-
260
- if expiry = resp.http_response.headers['x-amz-expiration']
261
- expiry.first =~ /^expiry-date="(.+)", rule-id="(.+)"$/
262
- exp_date = DateTime.parse($1)
263
- exp_rule_id = $2
264
- else
265
- exp_date = nil
266
- exp_rule_id = nil
267
- end
268
- resp.data[:expiration_date] = exp_date if exp_date
269
- resp.data[:expiration_rule_id] = exp_rule_id if exp_rule_id
270
-
271
- restoring = false
272
- restore_date = nil
273
-
274
- if restore = resp.http_response.headers['x-amz-restore']
275
- if restore.first =~ /ongoing-request="(.+?)", expiry-date="(.+?)"/
276
- restoring = $1 == "true"
277
- restore_date = $2 && DateTime.parse($2)
278
- elsif restore.first =~ /ongoing-request="(.+?)"/
279
- restoring = $1 == "true"
280
- end
281
- end
282
- resp.data[:restore_in_progress] = restoring
283
- resp.data[:restore_expiration_date] = restore_date if restore_date
284
-
285
- {
286
- 'x-amz-version-id' => :version_id,
287
- 'content-type' => :content_type,
288
- 'content-encoding' => :content_encoding,
289
- 'cache-control' => :cache_control,
290
- 'expires' => :expires,
291
- 'etag' => :etag,
292
- 'x-amz-website-redirect-location' => :website_redirect_location,
293
- 'accept-ranges' => :accept_ranges,
294
- }.each_pair do |header,method|
295
- if value = resp.http_response.header(header)
296
- resp.data[method] = value
297
- end
298
- end
299
-
300
- if time = resp.http_response.header('Last-Modified')
301
- resp.data[:last_modified] = Time.parse(time)
302
- end
303
-
304
- if length = resp.http_response.header('content-length')
305
- resp.data[:content_length] = length.to_i
306
- end
307
-
308
- if sse = resp.http_response.header('x-amz-server-side-encryption')
309
- resp.data[:server_side_encryption] = sse.downcase.to_sym
310
- end
311
-
312
- end
313
-
314
- module Validators
315
-
316
- # @return [Boolean] Returns true if the given bucket name is valid.
317
- def valid_bucket_name?(bucket_name)
318
- validate_bucket_name!(bucket_name) rescue false
319
- end
320
-
321
- # Returns true if the given `bucket_name` is DNS compatible.
322
- #
323
- # DNS compatible bucket names may be accessed like:
324
- #
325
- # http://dns.compat.bucket.name.s3.amazonaws.com/
326
- #
327
- # Whereas non-dns compatible bucket names must place the bucket
328
- # name in the url path, like:
329
- #
330
- # http://s3.amazonaws.com/dns_incompat_bucket_name/
331
- #
332
- # @return [Boolean] Returns true if the given bucket name may be
333
- # is dns compatible.
334
- # this bucket n
335
- #
336
- def dns_compatible_bucket_name?(bucket_name)
337
- return false if
338
- !valid_bucket_name?(bucket_name) or
339
-
340
- # Bucket names should be between 3 and 63 characters long
341
- bucket_name.size > 63 or
342
-
343
- # Bucket names must only contain lowercase letters, numbers, dots, and dashes
344
- # and must start and end with a lowercase letter or a number
345
- bucket_name !~ /^[a-z0-9][a-z0-9.-]+[a-z0-9]$/ or
346
-
347
- # Bucket names should not be formatted like an IP address (e.g., 192.168.5.4)
348
- bucket_name =~ /(\d+\.){3}\d+/ or
349
-
350
- # Bucket names cannot contain two, adjacent periods
351
- bucket_name['..'] or
352
-
353
- # Bucket names cannot contain dashes next to periods
354
- # (e.g., "my-.bucket.com" and "my.-bucket" are invalid)
355
- (bucket_name['-.'] || bucket_name['.-'])
356
-
357
- true
358
- end
359
-
360
- # Returns true if the bucket name must be used in the request
361
- # path instead of as a sub-domain when making requests against
362
- # S3.
363
- #
364
- # This can be an issue if the bucket name is DNS compatible but
365
- # contains '.' (periods). These cause the SSL certificate to
366
- # become invalid when making authenticated requets over SSL to the
367
- # bucket name. The solution is to send this as a path argument
368
- # instead.
369
- #
370
- # @return [Boolean] Returns true if the bucket name should be used
371
- # as a path segement instead of dns prefix when making requests
372
- # against s3.
373
- #
374
- def path_style_bucket_name? bucket_name
375
- if dns_compatible_bucket_name?(bucket_name)
376
- bucket_name =~ /\./ ? true : false
377
- else
378
- true
379
- end
380
- end
381
-
382
- def validate! name, value, &block
383
- if error_msg = yield
384
- raise ArgumentError, "#{name} #{error_msg}"
385
- end
386
- value
387
- end
388
-
389
- def validate_key!(key)
390
- validate!('key', key) do
391
- case
392
- when key.nil? || key == ''
393
- 'may not be blank'
394
- end
395
- end
396
- end
397
-
398
- def require_bucket_name! bucket_name
399
- if [nil, ''].include?(bucket_name)
400
- raise ArgumentError, "bucket_name may not be blank"
401
- end
402
- end
403
-
404
- # Returns true if the given bucket name is valid. If the name
405
- # is invalid, an ArgumentError is raised.
406
- def validate_bucket_name!(bucket_name)
407
- validate!('bucket_name', bucket_name) do
408
- case
409
- when bucket_name.nil? || bucket_name == ''
410
- 'may not be blank'
411
- when bucket_name !~ /^[A-Za-z0-9._\-]+$/
412
- 'may only contain uppercase letters, lowercase letters, numbers, periods (.), ' +
413
- 'underscores (_), and dashes (-)'
414
- when !(3..255).include?(bucket_name.size)
415
- 'must be between 3 and 255 characters long'
416
- when bucket_name =~ /\n/
417
- 'must not contain a newline character'
418
- end
419
- end
420
- end
421
-
422
- def require_policy!(policy)
423
- validate!('policy', policy) do
424
- case
425
- when policy.nil? || policy == ''
426
- 'may not be blank'
427
- else
428
- json_validation_message(policy)
429
- end
430
- end
431
- end
432
-
433
- def require_acl! options
434
- acl_options = [
435
- :acl,
436
- :grant_read,
437
- :grant_write,
438
- :grant_read_acp,
439
- :grant_write_acp,
440
- :grant_full_control,
441
- :access_control_policy,
442
- ]
443
- unless options.keys.any?{|opt| acl_options.include?(opt) }
444
- msg = "missing a required ACL option, must provide an ACL " +
445
- "via :acl, :grant_* or :access_control_policy"
446
- raise ArgumentError, msg
447
- end
448
- end
449
-
450
- def set_body_stream_and_content_length request, options
451
-
452
- unless options[:content_length]
453
- msg = "S3 requires a content-length header, unable to determine "
454
- msg << "the content length of the data provided, please set "
455
- msg << ":content_length"
456
- raise ArgumentError, msg
457
- end
458
-
459
- request.headers['content-length'] = options[:content_length]
460
- request.body_stream = options[:data]
461
-
462
- end
463
-
464
- def require_upload_id!(upload_id)
465
- validate!("upload_id", upload_id) do
466
- "must not be blank" if upload_id.to_s.empty?
467
- end
468
- end
469
-
470
- def require_part_number! part_number
471
- validate!("part_number", part_number) do
472
- "must not be blank" if part_number.to_s.empty?
473
- end
474
- end
475
-
476
- def validate_parts!(parts)
477
- validate!("parts", parts) do
478
- if !parts.kind_of?(Array)
479
- "must not be blank"
480
- elsif parts.empty?
481
- "must contain at least one entry"
482
- elsif !parts.all? { |p| p.kind_of?(Hash) }
483
- "must be an array of hashes"
484
- elsif !parts.all? { |p| p[:part_number] }
485
- "must contain part_number for each part"
486
- elsif !parts.all? { |p| p[:etag] }
487
- "must contain etag for each part"
488
- elsif parts.any? { |p| p[:part_number].to_i < 1 }
489
- "must not have part numbers less than 1"
490
- end
491
- end
492
- end
493
-
494
- def json_validation_message(obj)
495
- if obj.respond_to?(:to_str)
496
- obj = obj.to_str
497
- elsif obj.respond_to?(:to_json)
498
- obj = obj.to_json
499
- end
500
-
501
- error = nil
502
- begin
503
- JSON.parse(obj)
504
- rescue => e
505
- error = e
506
- end
507
- "contains invalid JSON: #{error}" if error
508
- end
509
-
510
- def require_allowed_methods!(allowed_methods)
511
- validate!("allowed_methods", allowed_methods) do
512
- if !allowed_methods.kind_of?(Array)
513
- "must be an array"
514
- elsif !allowed_methods.all? { |x| x.kind_of?(String) }
515
- "must be an array of strings"
516
- end
517
- end
518
- end
519
-
520
- def require_allowed_origins!(allowed_origins)
521
- validate!("allowed_origins", allowed_origins) do
522
- if !allowed_origins.kind_of?(Array)
523
- "must be an array"
524
- elsif !allowed_origins.all? { |x| x.kind_of?(String) }
525
- "must be an array of strings"
526
- end
527
- end
528
- end
529
-
530
- end
531
-
532
- include Validators
533
- extend Validators
534
-
535
- end
536
-
537
- class Client::V20060301 < Client
538
-
539
- def self.object_method(method_name, verb, *args, &block)
540
- bucket_method(method_name, verb, *args) do
541
- configure_request do |req, options|
542
- validate_key!(options[:key])
543
- super(req, options)
544
- req.key = options[:key]
545
- end
546
-
547
- instance_eval(&block) if block
548
- end
549
- end
550
-
551
- public
552
-
553
- # Creates a bucket.
554
- # @overload create_bucket(options = {})
555
- # @param [Hash] options
556
- # @option options [required,String] :bucket_name
557
- # @option options [String] :acl A canned ACL (e.g. 'private',
558
- # 'public-read', etc). See the S3 API documentation for
559
- # a complete list of valid values.
560
- # @option options [String] :grant_read
561
- # @option options [String] :grant_write
562
- # @option options [String] :grant_read_acp
563
- # @option options [String] :grant_write_acp
564
- # @option options [String] :grant_full_control
565
- # @return [Core::Response]
566
- bucket_method(:create_bucket, :put, :header_options => {
567
- :acl => 'x-amz-acl',
568
- :grant_read => 'x-amz-grant-read',
569
- :grant_write => 'x-amz-grant-write',
570
- :grant_read_acp => 'x-amz-grant-read-acp',
571
- :grant_write_acp => 'x-amz-grant-write-acp',
572
- :grant_full_control => 'x-amz-grant-full-control',
573
- }) do
574
-
575
- configure_request do |req, options|
576
- validate_bucket_name!(options[:bucket_name])
577
- if location = options[:location_constraint]
578
- xmlns = "http://s3.amazonaws.com/doc/#{API_VERSION}/"
579
- req.body = <<-XML
580
- <CreateBucketConfiguration xmlns="#{xmlns}">
581
- <LocationConstraint>#{location}</LocationConstraint>
582
- </CreateBucketConfiguration>
583
- XML
584
- end
585
- super(req, options)
586
- end
587
-
588
- end
589
- alias_method :put_bucket, :create_bucket
590
-
591
- # @!method put_bucket_website(options = {})
592
- # @param [Hash] options
593
- # @option (see WebsiteConfiguration#initialize)
594
- # @option options [required,String] :bucket_name
595
- # @return [Core::Response]
596
- bucket_method(:put_bucket_website, :put, 'website') do
597
-
598
- configure_request do |req, options|
599
- req.body = Nokogiri::XML::Builder.new do |xml|
600
- xml.WebsiteConfiguration(:xmlns => XMLNS) do
601
-
602
- if redirect = options[:redirect_all_requests_to]
603
- xml.RedirectAllRequestsTo do
604
- xml.HostName(redirect[:host_name])
605
- xml.Protocol(redirect[:protocol]) if redirect[:protocol]
606
- end
607
- end
608
-
609
- if indx = options[:index_document]
610
- xml.IndexDocument do
611
- xml.Suffix(indx[:suffix])
612
- end
613
- end
614
-
615
- if err = options[:error_document]
616
- xml.ErrorDocument do
617
- xml.Key(err[:key])
618
- end
619
- end
620
-
621
- rules = options[:routing_rules]
622
- if rules.is_a?(Array) && !rules.empty?
623
- xml.RoutingRules do
624
- rules.each do |rule|
625
- xml.RoutingRule do
626
-
627
- redirect = rule[:redirect]
628
- xml.Redirect do
629
- xml.Protocol(redirect[:protocol]) if redirect[:protocol]
630
- xml.HostName(redirect[:host_name]) if redirect[:host_name]
631
- xml.ReplaceKeyPrefixWith(redirect[:replace_key_prefix_with]) if redirect[:replace_key_prefix_with]
632
- xml.ReplaceKeyWith(redirect[:replace_key_with]) if redirect[:replace_key_with]
633
- xml.HttpRedirectCode(redirect[:http_redirect_code]) if redirect[:http_redirect_code]
634
- end
635
-
636
- if condition = rule[:condition]
637
- xml.Condition do
638
- xml.KeyPrefixEquals(condition[:key_prefix_equals]) if condition[:key_prefix_equals]
639
- xml.HttpErrorCodeReturnedEquals(condition[:http_error_code_returned_equals]) if condition[:http_error_code_returned_equals]
640
- end
641
- end
642
-
643
- end
644
- end
645
- end
646
- end
647
-
648
- end
649
- end.doc.root.to_xml
650
- super(req, options)
651
- end
652
-
653
- end
654
-
655
- # @overload get_bucket_website(options = {})
656
- # @param [Hash] options
657
- # @option options [required,String] :bucket_name
658
- # @return [Core::Response]
659
- # * `:index_document` - (Hash)
660
- # * `:suffix` - (String)
661
- # * `:error_document` - (Hash)
662
- # * `:key` - (String)
663
- bucket_method(:get_bucket_website, :get, 'website', XML::GetBucketWebsite)
664
-
665
- # @overload delete_bucket_website(options = {})
666
- # @param [Hash] options
667
- # @option options [required,String] :bucket_name
668
- # @return [Core::Response]
669
- bucket_method(:delete_bucket_website, :delete, 'website')
670
-
671
- # Deletes an empty bucket.
672
- # @overload delete_bucket(options = {})
673
- # @param [Hash] options
674
- # @option options [required,String] :bucket_name
675
- # @return [Core::Response]
676
- bucket_method(:delete_bucket, :delete)
677
-
678
- # @overload set_bucket_lifecycle_configuration(options = {})
679
- # @param [Hash] options
680
- # @option options [required,String] :bucket_name
681
- # @option options [required,String] :lifecycle_configuration
682
- # @return [Core::Response]
683
- bucket_method(:set_bucket_lifecycle_configuration, :put) do
684
-
685
- configure_request do |req, options|
686
- xml = options[:lifecycle_configuration]
687
- req.add_param('lifecycle')
688
- req.body = xml
689
- req.headers['content-md5'] = md5(xml)
690
- super(req, options)
691
- end
692
-
693
- end
694
-
695
- # @overload get_bucket_lifecycle_configuration(options = {})
696
- # @param [Hash] options
697
- # @option options [required,String] :bucket_name
698
- # @return [Core::Response]
699
- bucket_method(:get_bucket_lifecycle_configuration, :get) do
700
-
701
- configure_request do |req, options|
702
- req.add_param('lifecycle')
703
- super(req, options)
704
- end
705
-
706
- process_response do |resp|
707
- xml = resp.http_response.body
708
- resp.data = XML::GetBucketLifecycleConfiguration.parse(xml)
709
- end
710
-
711
- end
712
-
713
- # @overload delete_bucket_lifecycle_configuration(options = {})
714
- # @param [Hash] options
715
- # @option options [required,String] :bucket_name
716
- # @return [Core::Response]
717
- bucket_method(:delete_bucket_lifecycle_configuration, :delete) do
718
-
719
- configure_request do |req, options|
720
- req.add_param('lifecycle')
721
- super(req, options)
722
- end
723
-
724
- end
725
-
726
- # @overload put_bucket_cors(options = {})
727
- # @param [Hash] options
728
- # @option options [required,String] :bucket_name
729
- # @option options [required,Array<Hash>] :rules An array of rule hashes.
730
- # * `:id` - (String) A unique identifier for the rule. The ID
731
- # value can be up to 255 characters long. The IDs help you find
732
- # a rule in the configuration.
733
- # * `:allowed_methods` - (required,Array<String>) A list of HTTP
734
- # methods that you want to allow the origin to execute.
735
- # Each rule must identify at least one method.
736
- # * `:allowed_origins` - (required,Array<String>) A list of origins
737
- # you want to allow cross-domain requests from. This can
738
- # contain at most one * wild character.
739
- # * `:allowed_headers` - (Array<String>) A list of headers allowed
740
- # in a pre-flight OPTIONS request via the
741
- # Access-Control-Request-Headers header. Each header name
742
- # specified in the Access-Control-Request-Headers header must
743
- # have a corresponding entry in the rule.
744
- # Amazon S3 will send only the allowed headers in a response
745
- # that were requested. This can contain at most one * wild
746
- # character.
747
- # * `:max_age_seconds` - (Integer) The time in seconds that your
748
- # browser is to cache the preflight response for the specified
749
- # resource.
750
- # * `:expose_headers` - (Array<String>) One or more headers in
751
- # the response that you want customers to be able to access
752
- # from their applications (for example, from a JavaScript
753
- # XMLHttpRequest object).
754
- # @return [Core::Response]
755
- bucket_method(:put_bucket_cors, :put) do
756
- configure_request do |req, options|
757
-
758
- req.add_param('cors')
759
-
760
- options[:rules].each do |rule|
761
- require_allowed_methods!(rule[:allowed_methods])
762
- require_allowed_origins!(rule[:allowed_origins])
763
- end
764
-
765
- xml = Nokogiri::XML::Builder.new do |xml|
766
- xml.CORSConfiguration do
767
- options[:rules].each do |rule|
768
- xml.CORSRule do
769
-
770
- xml.ID(rule[:id]) if rule[:id]
771
-
772
- (rule[:allowed_methods] || []).each do |method|
773
- xml.AllowedMethod(method)
774
- end
775
-
776
- (rule[:allowed_origins] || []).each do |origin|
777
- xml.AllowedOrigin(origin)
778
- end
779
-
780
- (rule[:allowed_headers] || []).each do |header|
781
- xml.AllowedHeader(header)
782
- end
783
-
784
- xml.MaxAgeSeconds(rule[:max_age_seconds]) if
785
- rule[:max_age_seconds]
786
-
787
- (rule[:expose_headers] || []).each do |header|
788
- xml.ExposeHeader(header)
789
- end
790
-
791
- end
792
- end
793
- end
794
- end.doc.root.to_xml
795
-
796
- req.body = xml
797
- req.headers['content-md5'] = md5(xml)
798
-
799
- super(req, options)
800
-
801
- end
802
- end
803
-
804
- # @overload get_bucket_cors(options = {})
805
- # @param [Hash] options
806
- # @option options [required,String] :bucket_name
807
- # @return [Core::Response]
808
- bucket_method(:get_bucket_cors, :get) do
809
-
810
- configure_request do |req, options|
811
- req.add_param('cors')
812
- super(req, options)
813
- end
814
-
815
- process_response do |resp|
816
- resp.data = XML::GetBucketCors.parse(resp.http_response.body)
817
- end
818
-
819
- end
820
-
821
- # @overload delete_bucket_cors(options = {})
822
- # @param [Hash] options
823
- # @option options [required,String] :bucket_name
824
- # @return [Core::Response]
825
- bucket_method(:delete_bucket_cors, :delete) do
826
- configure_request do |req, options|
827
- req.add_param('cors')
828
- super(req, options)
829
- end
830
- end
831
-
832
- # @overload put_bucket_tagging(options = {})
833
- # @param [Hash] options
834
- # @option options [required,String] :bucket_name
835
- # @option options [Hash] :tags
836
- # @return [Core::Response]
837
- bucket_method(:put_bucket_tagging, :put) do
838
- configure_request do |req, options|
839
-
840
- req.add_param('tagging')
841
-
842
- xml = Nokogiri::XML::Builder.new
843
- xml.Tagging do |xml|
844
- xml.TagSet do
845
- options[:tags].each_pair do |key,value|
846
- xml.Tag do
847
- xml.Key(key)
848
- xml.Value(value)
849
- end
850
- end
851
- end
852
- end
853
-
854
- xml = xml.doc.root.to_xml
855
- req.body = xml
856
- req.headers['content-md5'] = md5(xml)
857
-
858
- super(req, options)
859
-
860
- end
861
- end
862
-
863
- # @overload get_bucket_tagging(options = {})
864
- # @param [Hash] options
865
- # @option options [required,String] :bucket_name
866
- # @return [Core::Response]
867
- bucket_method(:get_bucket_tagging, :get) do
868
-
869
- configure_request do |req, options|
870
- req.add_param('tagging')
871
- super(req, options)
872
- end
873
-
874
- process_response do |resp|
875
- resp.data = XML::GetBucketTagging.parse(resp.http_response.body)
876
- end
877
-
878
- end
879
-
880
- # @overload delete_bucket_tagging(options = {})
881
- # @param [Hash] options
882
- # @option options [required,String] :bucket_name
883
- # @return [Core::Response]
884
- bucket_method(:delete_bucket_tagging, :delete) do
885
- configure_request do |req, options|
886
- req.add_param('tagging')
887
- super(req, options)
888
- end
889
- end
890
-
891
- # @overload list_buckets(options = {})
892
- # @param [Hash] options
893
- # @return [Core::Response]
894
- add_client_request_method(:list_buckets) do
895
-
896
- configure_request do |req, options|
897
- req.http_method = "GET"
898
- end
899
-
900
- process_response do |resp|
901
- resp.data = XML::ListBuckets.parse(resp.http_response.body)
902
- end
903
-
904
- simulate_response do |resp|
905
- resp.data = Core::XML::Parser.new(XML::ListBuckets.rules).simulate
906
- end
907
-
908
- end
909
-
910
- # Sets the access policy for a bucket.
911
- # @overload set_bucket_policy(options = {})
912
- # @param [Hash] options
913
- # @option options [required,String] :bucket_name
914
- # @option options [required,String] :policy This can be a String
915
- # or any object that responds to `#to_json`.
916
- # @return [Core::Response]
917
- bucket_method(:set_bucket_policy, :put, 'policy') do
918
-
919
- configure_request do |req, options|
920
- require_policy!(options[:policy])
921
- super(req, options)
922
- policy = options[:policy]
923
- policy = policy.to_json unless policy.respond_to?(:to_str)
924
- req.body = policy
925
- end
926
-
927
- end
928
-
929
- # Gets the access policy for a bucket.
930
- # @overload get_bucket_policy(options = {})
931
- # @param [Hash] options
932
- # @option options [required,String] :bucket_name
933
- # @return [Core::Response]
934
- bucket_method(:get_bucket_policy, :get, 'policy') do
935
-
936
- process_response do |resp|
937
- resp.data[:policy] = resp.http_response.body
938
- end
939
-
940
- end
941
-
942
- # Deletes the access policy for a bucket.
943
- # @overload delete_bucket_policy(options = {})
944
- # @param [Hash] options
945
- # @option options [required,String] :bucket_name
946
- # @return [Core::Response]
947
- bucket_method(:delete_bucket_policy, :delete, 'policy')
948
-
949
- # @overload set_bucket_versioning(options = {})
950
- # @param [Hash] options
951
- # @option options [required,String] :bucket_name
952
- # @option options [required,String] :state
953
- # @option options [String] :mfa_delete
954
- # @option options [String] :mfa
955
- # @return [Core::Response]
956
- bucket_method(:set_bucket_versioning, :put, 'versioning', :header_options => { :mfa => "x-amz-mfa" }) do
957
-
958
- configure_request do |req, options|
959
- state = options[:state].to_s.downcase.capitalize
960
- unless state =~ /^(Enabled|Suspended)$/
961
- raise ArgumentError, "invalid versioning state `#{state}`"
962
- end
963
-
964
- # Leave validation of MFA options to S3
965
- mfa_delete = options[:mfa_delete].to_s.downcase.capitalize if options[:mfa_delete]
966
-
967
- # Generate XML request for versioning
968
- req.body = Nokogiri::XML::Builder.new do |xml|
969
- xml.VersioningConfiguration('xmlns' => XMLNS) do
970
- xml.Status(state)
971
- xml.MfaDelete(mfa_delete) if mfa_delete
972
- end
973
- end.doc.root.to_xml
974
-
975
- super(req, options)
976
- end
977
-
978
- end
979
-
980
- # Gets the bucket's location constraint.
981
- # @overload get_bucket_location(options = {})
982
- # @param [Hash] options
983
- # @option options [required,String] :bucket_name
984
- # @return [Core::Response]
985
- bucket_method(:get_bucket_location, :get, 'location') do
986
-
987
- process_response do |response|
988
- regex = />(.*)<\/LocationConstraint>/
989
- matches = response.http_response.body.to_s.match(regex)
990
- response.data[:location_constraint] = matches ? matches[1] : nil
991
- end
992
-
993
- end
994
-
995
- # @overload put_bucket_logging(options = {})
996
- # @param [Hash] options
997
- # @option options [required,String] :bucket_name
998
- # @option options [Boolean] :logging_enabled Set to true if turning on
999
- # bucket logging. If not set or false, all of the following options
1000
- # will be ignored.
1001
- # @option options [String] :target_bucket The name of the bucket in
1002
- # which you want Amazon S3 to store server access logs. You can push
1003
- # logs to any bucket you own, including the bucket being logged.
1004
- # @option options [String] :target_prefix Allows you to specify a prefix
1005
- # for the keys that the log files will be stored under. Recommended
1006
- # if you will be writing logs from multiple buckets to the same target
1007
- # bucket.
1008
- # @option options [Array<Hash>] :grants An array of hashes specifying
1009
- # permission grantees. For each hash, specify ONLY ONE of :id, :uri,
1010
- # or :email_address.
1011
- # * `:email_address` - (String) E-mail address of the person being
1012
- # granted logging permissions.
1013
- # * `:id` - (String) The canonical user ID of the grantee.
1014
- # * `:uri` - (String) URI of the grantee group.
1015
- # * `:permission` - (String) Logging permissions given to the Grantee
1016
- # for the bucket. The bucket owner is automatically granted FULL_CONTROL
1017
- # to all logs delivered to the bucket. This optional element enables
1018
- # you grant access to others. Valid Values: FULL_CONTROL | READ | WRITE
1019
- # @return [Core::Response]
1020
- bucket_method(:put_bucket_logging, :put) do
1021
- configure_request do |req, options|
1022
-
1023
- req.add_param('logging')
1024
-
1025
- xml = Nokogiri::XML::Builder.new
1026
- xml.BucketLoggingStatus('xmlns' => XMLNS) do |xml|
1027
- if options[:logging_enabled] == true
1028
- xml.LoggingEnabled do
1029
- xml.TargetBucket(options[:target_bucket])
1030
- xml.TargetPrefix(options[:target_prefix])
1031
- unless options[:grants].nil?
1032
-
1033
- xml.TargetGrants do
1034
- options[:grants].each do |grant|
1035
- xml.Grant do
1036
- if !grant[:email_address].nil?
1037
- xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
1038
- 'xsi:type' => 'AmazonCustomerByEmail') do
1039
- xml.EmailAddress(grant[:email_address])
1040
- end
1041
- elsif !grant[:uri].nil?
1042
- xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
1043
- 'xsi:type' => 'Group') do
1044
- xml.URI(grant[:uri])
1045
- end
1046
- elsif !grant[:id].nil?
1047
- xml.Grantee('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
1048
- 'xsi:type' => 'CanonicalUser') do
1049
- xml.ID(grant[:id])
1050
- end
1051
- end
1052
-
1053
- xml.Permission(grant[:permission])
1054
- end
1055
- end
1056
- end
1057
- end
1058
- end
1059
- end
1060
- end
1061
-
1062
- xml = xml.doc.root.to_xml
1063
- req.body = xml
1064
- req.headers['content-md5'] = md5(xml)
1065
-
1066
- super(req, options)
1067
-
1068
- end
1069
- end
1070
-
1071
- # Gets the bucket's logging status.
1072
- # @overload get_bucket_logging(options = {})
1073
- # @param [Hash] options
1074
- # @option options [required,String] :bucket_name
1075
- # @return [Core::Response]
1076
- bucket_method(:get_bucket_logging, :get, 'logging',
1077
- XML::GetBucketLogging)
1078
-
1079
- # @overload get_bucket_versioning(options = {})
1080
- # @param [Hash] options
1081
- # @option options [required,String] :bucket_name
1082
- # @return [Core::Response]
1083
- bucket_method(:get_bucket_versioning, :get, 'versioning',
1084
- XML::GetBucketVersioning)
1085
-
1086
- # @overload list_object_versions(options = {})
1087
- # @param [Hash] options
1088
- # @option options [required,String] :bucket_name
1089
- # @option options [String] :prefix
1090
- # @option options [String] :delimiter
1091
- # @option options [String] :max_keys
1092
- # @option options [String] :key_marker
1093
- # @option options [String] :version_id_marker
1094
- # @return [Core::Response]
1095
- bucket_method(:list_object_versions, :get, 'versions',
1096
- XML::ListObjectVersions) do
1097
-
1098
- configure_request do |req, options|
1099
- super(req, options)
1100
- params = %w(delimiter key_marker max_keys prefix version_id_marker)
1101
- params.each do |param|
1102
- if options[param.to_sym]
1103
- req.add_param(param.gsub(/_/, '-'), options[param.to_sym])
1104
- end
1105
- end
1106
- end
1107
-
1108
- end
1109
-
1110
- # Sets the access control list for a bucket. You must specify an ACL
1111
- # via one of the following methods:
1112
- #
1113
- # * as a canned ACL (via `:acl`)
1114
- # * as a list of grants (via the `:grant_*` options)
1115
- # * as an access control policy document (via `:access_control_policy`)
1116
- #
1117
- # @example Using a canned acl
1118
- # s3_client.put_bucket_acl(
1119
- # :bucket_name => 'bucket-name',
1120
- # :acl => 'public-read')
1121
- #
1122
- # @example Using grants
1123
- # s3_client.put_bucket_acl(
1124
- # :bucket_name => 'bucket-name',
1125
- # :grant_read => 'uri="http://acs.amazonaws.com/groups/global/AllUsers"',
1126
- # :grant_full_control => 'emailAddress="xyz@amazon.com", id="8a9...fa7"')
1127
- #
1128
- # @example Using an access control policy document
1129
- # policy_xml = <<-XML
1130
- # <AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
1131
- # <Owner>
1132
- # <ID>852b113e7a2f25102679df27bb0ae12b3f85be6BucketOwnerCanonicalUserID</ID>
1133
- # <DisplayName>OwnerDisplayName</DisplayName>
1134
- # </Owner>
1135
- # <AccessControlList>
1136
- # <Grant>
1137
- # <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
1138
- # <ID>BucketOwnerCanonicalUserID</ID>
1139
- # <DisplayName>OwnerDisplayName</DisplayName>
1140
- # </Grantee>
1141
- # <Permission>FULL_CONTROL</Permission>
1142
- # </Grant>
1143
- # <Grant>
1144
- # <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
1145
- # <URI xmlns="">http://acs.amazonaws.com/groups/global/AllUsers</URI>
1146
- # </Grantee>
1147
- # <Permission xmlns="">READ</Permission>
1148
- # </Grant>
1149
- # </AccessControlList>
1150
- # </AccessControlPolicy>
1151
- #
1152
- # XML
1153
- # s3_client.put_bucket_acl(
1154
- # :bucket_name => 'bucket-name',
1155
- # :access_control_policy => policy_xml)
1156
- #
1157
- # @overload put_bucket_acl(options = {})
1158
- # @param [Hash] options
1159
- # @option options [required,String] :bucket_name
1160
- # @option options [String] :access_control_policy An access control
1161
- # policy description as a string of XML. See the S3 API
1162
- # documentation for a description.
1163
- # @option options [String] :acl A canned ACL (e.g. 'private',
1164
- # 'public-read', etc). See the S3 API documentation for
1165
- # a complete list of valid values.
1166
- # @option options [String] :grant_read
1167
- # @option options [String] :grant_write
1168
- # @option options [String] :grant_read_acp
1169
- # @option options [String] :grant_write_acp
1170
- # @option options [String] :grant_full_control
1171
- # @return [Core::Response]
1172
- bucket_method(:put_bucket_acl, :put, 'acl', :header_options => {
1173
- :acl => 'x-amz-acl',
1174
- :grant_read => 'x-amz-grant-read',
1175
- :grant_write => 'x-amz-grant-write',
1176
- :grant_read_acp => 'x-amz-grant-read-acp',
1177
- :grant_write_acp => 'x-amz-grant-write-acp',
1178
- :grant_full_control => 'x-amz-grant-full-control',
1179
- }) do
1180
-
1181
- configure_request do |req, options|
1182
- move_access_control_policy(options)
1183
- require_acl!(options)
1184
- super(req, options)
1185
- req.body = options[:access_control_policy] if
1186
- options[:access_control_policy]
1187
- end
1188
-
1189
- end
1190
- alias_method :set_bucket_acl, :put_bucket_acl
1191
-
1192
- # Gets the access control list for a bucket.
1193
- # @overload get_bucket_acl(options = {})
1194
- # @param [Hash] options
1195
- # @option options [required,String] :bucket_name
1196
- # @return [Core::Response]
1197
- bucket_method(:get_bucket_acl, :get, 'acl', XML::GetBucketAcl)
1198
-
1199
- # Sets the access control list for an object. You must specify an ACL
1200
- # via one of the following methods:
1201
- #
1202
- # * as a canned ACL (via `:acl`)
1203
- # * as a list of grants (via the `:grant_*` options)
1204
- # * as an access control policy document (via `:access_control_policy`)
1205
- #
1206
- # @example Using a canned acl
1207
- # s3_client.put_object_acl(
1208
- # :bucket_name => 'bucket-name',
1209
- # :key => 'object-key',
1210
- # :acl => 'public-read')
1211
- #
1212
- # @example Using grants
1213
- # s3_client.put_bucket_acl(
1214
- # :bucket_name => 'bucket-name',
1215
- # :key => 'object-key',
1216
- # :grant_read => 'uri="http://acs.amazonaws.com/groups/global/AllUsers"',
1217
- # :grant_full_control => 'emailAddress="xyz@amazon.com", id="8a9...fa7"')
1218
- #
1219
- # @example Using an access control policy document
1220
- # policy_xml = <<-XML
1221
- # <AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
1222
- # <Owner>
1223
- # <ID>852b113e7a2f25102679df27bb0ae12b3f85be6BucketOwnerCanonicalUserID</ID>
1224
- # <DisplayName>OwnerDisplayName</DisplayName>
1225
- # </Owner>
1226
- # <AccessControlList>
1227
- # <Grant>
1228
- # <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
1229
- # <ID>BucketOwnerCanonicalUserID</ID>
1230
- # <DisplayName>OwnerDisplayName</DisplayName>
1231
- # </Grantee>
1232
- # <Permission>FULL_CONTROL</Permission>
1233
- # </Grant>
1234
- # <Grant>
1235
- # <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Group">
1236
- # <URI xmlns="">http://acs.amazonaws.com/groups/global/AllUsers</URI>
1237
- # </Grantee>
1238
- # <Permission xmlns="">READ</Permission>
1239
- # </Grant>
1240
- # </AccessControlList>
1241
- # </AccessControlPolicy>
1242
- #
1243
- # XML
1244
- # s3_client.put_bucket_acl(
1245
- # :bucket_name => 'bucket-name',
1246
- # :key => 'object-key',
1247
- # :access_control_policy => policy_xml)
1248
- #
1249
- # @overload put_object_acl(options = {})
1250
- # @param [Hash] options
1251
- # @option options [required,String] :bucket_name
1252
- # @option options [required,String] :key
1253
- # @option options [String] :access_control_policy An access control
1254
- # policy description as a string of XML. See the S3 API
1255
- # documentation for a description.
1256
- # @option options [String] :acl A canned ACL (e.g. 'private',
1257
- # 'public-read', etc). See the S3 API documentation for
1258
- # a complete list of valid values.
1259
- # @option options [String] :grant_read
1260
- # @option options [String] :grant_write
1261
- # @option options [String] :grant_read_acp
1262
- # @option options [String] :grant_write_acp
1263
- # @option options [String] :grant_full_control
1264
- # @return [Core::Response]
1265
- object_method(:put_object_acl, :put, 'acl', :header_options => {
1266
- :acl => 'x-amz-acl',
1267
- :grant_read => 'x-amz-grant-read',
1268
- :grant_write => 'x-amz-grant-write',
1269
- :grant_read_acp => 'x-amz-grant-read-acp',
1270
- :grant_write_acp => 'x-amz-grant-write-acp',
1271
- :grant_full_control => 'x-amz-grant-full-control',
1272
- }) do
1273
-
1274
- configure_request do |req, options|
1275
- move_access_control_policy(options)
1276
- require_acl!(options)
1277
- super(req, options)
1278
- req.body = options[:access_control_policy] if
1279
- options[:access_control_policy]
1280
- end
1281
-
1282
- end
1283
- alias_method :set_object_acl, :put_object_acl
1284
-
1285
- # Gets the access control list for an object.
1286
- # @overload get_object_acl(options = {})
1287
- # @param [Hash] options
1288
- # @option options [required,String] :bucket_name
1289
- # @option options [required,String] :key
1290
- # @return [Core::Response]
1291
- object_method(:get_object_acl, :get, 'acl', XML::GetBucketAcl)
1292
-
1293
- # Puts data into an object, replacing the current contents.
1294
- #
1295
- # s3_client.put_object({
1296
- # :bucket_name => 'bucket-name',
1297
- # :key => 'readme.txt',
1298
- # :data => 'This is the readme for ...',
1299
- # })
1300
- #
1301
- # @overload put_object(options = {})
1302
- # @param [Hash] options
1303
- # @option options [required,String] :bucket_name
1304
- # @option options [required,String] :key
1305
- # @option options [required,String,Pathname,File,IO] :data
1306
- # The data to upload. This can be provided as a string,
1307
- # a Pathname object, or any object that responds to
1308
- # `#read` and `#eof?` (e.g. IO, File, Tempfile, StringIO, etc).
1309
- # @option options [Integer] :content_length
1310
- # Required if you are using block form to write data or if it is
1311
- # not possible to determine the size of `:data`. A best effort
1312
- # is made to determine the content length of strings, files,
1313
- # tempfiles, io objects, and any object that responds
1314
- # to `#length` or `#size`.
1315
- # @option options [String] :website_redirect_location If the bucket is
1316
- # configured as a website, redirects requests for this object to
1317
- # another object in the same bucket or to an external URL.
1318
- # @option options [Hash] :metadata
1319
- # A hash of metadata to be included with the
1320
- # object. These will be sent to S3 as headers prefixed with
1321
- # `x-amz-meta`.
1322
- # @option options [Symbol] :acl (:private) A canned access
1323
- # control policy. Accepted values include:
1324
- # * `:private`
1325
- # * `:public_read`
1326
- # * ...
1327
- # @option options [String] :storage_class+ ('STANDARD')
1328
- # Controls whether Reduced Redundancy Storage is enabled for
1329
- # the object. Valid values are 'STANDARD' and
1330
- # 'REDUCED_REDUNDANCY'.
1331
- # @option options [Symbol,String] :server_side_encryption (nil) The
1332
- # algorithm used to encrypt the object on the server side
1333
- # (e.g. :aes256).
1334
- # object on the server side, e.g. `:aes256`)
1335
- # @option options [String] :cache_control
1336
- # Can be used to specify caching behavior.
1337
- # @option options [String] :content_disposition
1338
- # Specifies presentational information.
1339
- # @option options [String] :content_encoding
1340
- # Specifies the content encoding.
1341
- # @option options [String] :content_md5
1342
- # The base64 encoded content md5 of the `:data`.
1343
- # @option options [String] :content_type
1344
- # Specifies the content type.
1345
- # @option options [String] :expires The date and time at which the
1346
- # object is no longer cacheable.
1347
- # @option options [String] :acl A canned ACL (e.g. 'private',
1348
- # 'public-read', etc). See the S3 API documentation for
1349
- # a complete list of valid values.
1350
- # @option options [String] :grant_read
1351
- # @option options [String] :grant_write
1352
- # @option options [String] :grant_read_acp
1353
- # @option options [String] :grant_write_acp
1354
- # @option options [String] :grant_full_control
1355
- # @return [Core::Response]
1356
- #
1357
- object_method(:put_object, :put, :header_options => {
1358
- :website_redirect_location => 'x-amz-website-redirect-location',
1359
- :acl => 'x-amz-acl',
1360
- :grant_read => 'x-amz-grant-read',
1361
- :grant_write => 'x-amz-grant-write',
1362
- :grant_read_acp => 'x-amz-grant-read-acp',
1363
- :grant_write_acp => 'x-amz-grant-write-acp',
1364
- :grant_full_control => 'x-amz-grant-full-control',
1365
- :content_md5 => 'Content-MD5',
1366
- :cache_control => 'Cache-Control',
1367
- :content_disposition => 'Content-Disposition',
1368
- :content_encoding => 'Content-Encoding',
1369
- :content_type => 'Content-Type',
1370
- :expires => 'Expires',
1371
- }) do
1372
-
1373
- configure_request do |request, options|
1374
-
1375
- options = compute_write_options(options)
1376
- set_body_stream_and_content_length(request, options)
1377
-
1378
- set_metadata(request, options)
1379
- set_storage_class(request, options)
1380
- set_server_side_encryption(request, options)
1381
-
1382
- super(request, options)
1383
-
1384
- end
1385
-
1386
- process_response do |resp|
1387
- extract_object_headers(resp)
1388
- end
1389
-
1390
- simulate_response do |response|
1391
- response.data[:etag] = 'abc123'
1392
- response.data[:version_id] = nil
1393
- end
1394
-
1395
- end
1396
-
1397
- # Gets the data for a key.
1398
- # @overload get_object(options = {})
1399
- # @param [Hash] options
1400
- # @option options [required,String] :bucket_name
1401
- # @option options [required,String] :key
1402
- # @option options [Time] :if_modified_since If specified, the
1403
- # response will contain an additional `:modified` value that
1404
- # returns true if the object was modified after the given
1405
- # time. If `:modified` is false, then the response
1406
- # `:data` value will be `nil`.
1407
- # @option options [Time] :if_unmodified_since If specified, the
1408
- # response will contain an additional `:unmodified` value
1409
- # that is true if the object was not modified after the
1410
- # given time. If `:unmodified` returns false, the `:data`
1411
- # value will be `nil`.
1412
- # @option options [String] :if_match If specified, the response
1413
- # will contain an additional `:matches` value that is true
1414
- # if the object ETag matches the value for this option. If
1415
- # `:matches` is false, the `:data` value of the
1416
- # response will be `nil`.
1417
- # @option options [String] :if_none_match If specified, the
1418
- # response will contain an additional `:matches` value that
1419
- # is true if and only if the object ETag matches the value for
1420
- # this option. If `:matches` is true, the `:data` value
1421
- # of the response will be `nil`.
1422
- # @option options [Range<Integer>] :range A byte range of data to request.
1423
- # @return [Core::Response]
1424
- #
1425
- object_method(:get_object, :get,
1426
- :header_options => {
1427
- :if_modified_since => "If-Modified-Since",
1428
- :if_unmodified_since => "If-Unmodified-Since",
1429
- :if_match => "If-Match",
1430
- :if_none_match => "If-None-Match"
1431
- }) do
1432
- configure_request do |req, options|
1433
-
1434
- super(req, options)
1435
-
1436
- if options[:version_id]
1437
- req.add_param('versionId', options[:version_id])
1438
- end
1439
-
1440
- ["If-Modified-Since",
1441
- "If-Unmodified-Since"].each do |date_header|
1442
- case value = req.headers[date_header]
1443
- when DateTime
1444
- req.headers[date_header] = Time.parse(value.to_s).rfc2822
1445
- when Time
1446
- req.headers[date_header] = value.rfc2822
1447
- end
1448
- end
1449
-
1450
- if options[:range]
1451
- range = options[:range]
1452
- if range.is_a?(Range)
1453
- offset = range.exclude_end? ? -1 : 0
1454
- range = "bytes=#{range.first}-#{range.last + offset}"
1455
- end
1456
- req.headers['Range'] = range
1457
- end
1458
-
1459
- end
1460
-
1461
- process_response do |resp|
1462
- extract_object_headers(resp)
1463
- resp.data[:data] = resp.http_response.body
1464
- end
1465
-
1466
- end
1467
-
1468
- # Gets the torrent for a key.
1469
- # @overload get_object_torrent(options = {})
1470
- # @param [Hash] options
1471
- # @option options [required,String] :bucket_name
1472
- # @option options [required,String] :key
1473
- # @return [Core::Response]
1474
- #
1475
- object_method(:get_object_torrent, :get, 'torrent') do
1476
- process_response do |resp|
1477
- extract_object_headers(resp)
1478
- resp.data[:data] = resp.http_response.body
1479
- end
1480
- end
1481
-
1482
- # @overload head_object(options = {})
1483
- # @param [Hash] options
1484
- # @option options [required,String] :bucket_name
1485
- # @option options [required,String] :key
1486
- # @option options [String] :version_id
1487
- # @return [Core::Response]
1488
- object_method(:head_object, :head) do
1489
-
1490
- configure_request do |req, options|
1491
- super(req, options)
1492
- if options[:version_id]
1493
- req.add_param('versionId', options[:version_id])
1494
- end
1495
- end
1496
-
1497
- process_response do |resp|
1498
- extract_object_headers(resp)
1499
- end
1500
-
1501
- end
1502
-
1503
- # @overload delete_object(options = {})
1504
- # @param [Hash] options
1505
- # @option options [required,String] :bucket_name
1506
- # @option options [required,String] :key
1507
- # @option options [String] :version_id
1508
- # @option options [String] :mfa
1509
- # @return [Core::Response]
1510
- object_method(:delete_object, :delete, :header_options => { :mfa => "x-amz-mfa" }) do
1511
-
1512
- configure_request do |req, options|
1513
- super(req, options)
1514
- if options[:version_id]
1515
- req.add_param('versionId', options[:version_id])
1516
- end
1517
- end
1518
-
1519
- process_response do |resp|
1520
- resp.data[:version_id] = resp.http_response.header('x-amz-version-id')
1521
- end
1522
-
1523
- end
1524
-
1525
- # @overload restore_object(options = {})
1526
- # Restores a temporary copy of an archived object.
1527
- # @param [Hash] options
1528
- # @option options [required,String] :bucket_name
1529
- # @option options [required,String] :key
1530
- # @option options [required,Integer] :days the number of days to keep
1531
- # the restored object.
1532
- # @return [Core::Response]
1533
- # @since 1.7.2
1534
- object_method(:restore_object, :post, 'restore',
1535
- :header_options => { :content_md5 => 'Content-MD5' }) do
1536
- configure_request do |req, options|
1537
- super(req, options)
1538
-
1539
- validate!(:days, options[:days]) do
1540
- "must be greater or equal to 1" if options[:days].to_i <= 0
1541
- end
1542
-
1543
- xml = Nokogiri::XML::Builder.new do |xml|
1544
- xml.RestoreRequest('xmlns' => XMLNS) do
1545
- xml.Days(options[:days].to_i) if options[:days]
1546
- end
1547
- end.doc.root.to_xml
1548
-
1549
- req.body = xml
1550
- req.headers['content-type'] = 'application/xml'
1551
- req.headers['content-md5'] = md5(xml)
1552
- end
1553
- end
1554
-
1555
-
1556
- # @overload list_objects(options = {})
1557
- # @param [Hash] options
1558
- # @option options [required,String] :bucket_name
1559
- # @option options [String] :delimiter
1560
- # @option options [String] :marker
1561
- # @option options [String] :max_keys
1562
- # @option options [String] :prefix
1563
- # @return [Core::Response]
1564
- bucket_method(:list_objects, :get, XML::ListObjects) do
1565
- configure_request do |req, options|
1566
- super(req, options)
1567
- params = %w(delimiter marker max_keys prefix)
1568
- params.each do |param|
1569
- if options[param.to_sym]
1570
- req.add_param(param.gsub(/_/, '-'), options[param.to_sym])
1571
- end
1572
- end
1573
- end
1574
- end
1575
-
1576
- alias_method :get_bucket, :list_objects
1577
-
1578
- # @overload initiate_multipart_upload(options = {})
1579
- # @param [Hash] options
1580
- # @option options [required,String] :bucket_name
1581
- # @option options [required,String] :key
1582
- # @option options [String] :website_redirect_location If the bucket is
1583
- # configured as a website, redirects requests for this object to
1584
- # another object in the same bucket or to an external URL.
1585
- # @option options [Hash] :metadata
1586
- # @option options [Symbol] :acl
1587
- # @option options [String] :cache_control
1588
- # @option options [String] :content_disposition
1589
- # @option options [String] :content_encoding
1590
- # @option options [String] :content_type
1591
- # @option options [String] :storage_class+ ('STANDARD')
1592
- # Controls whether Reduced Redundancy Storage is enabled for
1593
- # the object. Valid values are 'STANDARD' and
1594
- # 'REDUCED_REDUNDANCY'.
1595
- # @option options [Symbol,String] :server_side_encryption (nil) The
1596
- # algorithm used to encrypt the object on the server side
1597
- # (e.g. :aes256).
1598
- # @option options [String] :expires The date and time at which the
1599
- # object is no longer cacheable.
1600
- # @option options [String] :acl A canned ACL (e.g. 'private',
1601
- # 'public-read', etc). See the S3 API documentation for
1602
- # a complete list of valid values.
1603
- # @option options [String] :grant_read
1604
- # @option options [String] :grant_write
1605
- # @option options [String] :grant_read_acp
1606
- # @option options [String] :grant_write_acp
1607
- # @option options [String] :grant_full_control
1608
- # @return [Core::Response]
1609
- object_method(:initiate_multipart_upload, :post, 'uploads',
1610
- XML::InitiateMultipartUpload,
1611
- :header_options => {
1612
- :website_redirect_location => 'x-amz-website-redirect-location',
1613
- :acl => 'x-amz-acl',
1614
- :grant_read => 'x-amz-grant-read',
1615
- :grant_write => 'x-amz-grant-write',
1616
- :grant_read_acp => 'x-amz-grant-read-acp',
1617
- :grant_write_acp => 'x-amz-grant-write-acp',
1618
- :grant_full_control => 'x-amz-grant-full-control',
1619
- :cache_control => 'Cache-Control',
1620
- :content_disposition => 'Content-Disposition',
1621
- :content_encoding => 'Content-Encoding',
1622
- :content_type => 'Content-Type',
1623
- :expires => 'Expires',
1624
- }) do
1625
-
1626
- configure_request do |req, options|
1627
- set_metadata(req, options)
1628
- set_storage_class(req, options)
1629
- set_server_side_encryption(req, options)
1630
- super(req, options)
1631
- end
1632
-
1633
- process_response do |resp|
1634
- extract_object_headers(resp)
1635
- end
1636
-
1637
- end
1638
-
1639
- # @overload list_multipart_uploads(options = {})
1640
- # @param [Hash] options
1641
- # @option options [required,String] :bucket_name
1642
- # @option options [String] :delimiter
1643
- # @option options [String] :key_marker
1644
- # @option options [String] :max_keys
1645
- # @option options [String] :upload_id_marker
1646
- # @option options [String] :max_uploads
1647
- # @option options [String] :prefix
1648
- # @return [Core::Response]
1649
- bucket_method(:list_multipart_uploads,
1650
- :get, 'uploads',
1651
- XML::ListMultipartUploads) do
1652
- configure_request do |req, options|
1653
- super(req, options)
1654
- params = %w(delimiter key_marker max_keys) +
1655
- %w(upload_id_marker max_uploads prefix)
1656
- params.each do |param|
1657
- if options[param.to_sym]
1658
- req.add_param(param.gsub(/_/, '-'), options[param.to_sym])
1659
- end
1660
- end
1661
- end
1662
- end
1663
-
1664
- # @overload delete_objects(options = {})
1665
- # @param [Hash] options
1666
- # @option options [required,String] :bucket_name
1667
- # @option options [required,Array<Hash>] :objects Each entry should be
1668
- # a hash with the following keys:
1669
- # * `:key` - *required*
1670
- # * `:version_id`
1671
- # @option options [Boolean] :quiet (true)
1672
- # @option options [String] :mfa
1673
- # @return [Core::Response]
1674
- bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects,
1675
- :header_options => { :mfa => "x-amz-mfa" }
1676
- ) do
1677
-
1678
- configure_request do |req, options|
1679
-
1680
- super(req, options)
1681
-
1682
- req.body = Nokogiri::XML::Builder.new do |xml|
1683
- xml.Delete do
1684
- xml.Quiet(options.key?(:quiet) ? options[:quiet] : true)
1685
- (options[:objects] || options[:keys]).each do |obj|
1686
- xml.Object do
1687
- xml.Key(obj[:key])
1688
- xml.VersionId(obj[:version_id]) if obj[:version_id]
1689
- end
1690
- end
1691
- end
1692
- end.doc.root.to_xml
1693
-
1694
- req.headers['content-md5'] = md5(req.body)
1695
-
1696
- end
1697
- end
1698
-
1699
- # @overload upload_part(options = {})
1700
- # @param [Hash] options
1701
- # @option options [required,String] :bucket_name
1702
- # @option options [required,String] :key
1703
- # @option options [required,String] :upload_id
1704
- # @option options [required,Integer] :part_number
1705
- # @option options [required,String,Pathname,File,IO] :data
1706
- # The data to upload. This can be provided as a string,
1707
- # a Pathname object, or any object that responds to
1708
- # `#read` and `#eof?` (e.g. IO, File, Tempfile, StringIO, etc).
1709
- # @return [Core::Response]
1710
- object_method(:upload_part, :put,
1711
- :header_options => {
1712
- :content_md5 => 'Content-MD5'
1713
- }) do
1714
- configure_request do |request, options|
1715
-
1716
- options = compute_write_options(options)
1717
- set_body_stream_and_content_length(request, options)
1718
-
1719
- require_upload_id!(options[:upload_id])
1720
- request.add_param('uploadId', options[:upload_id])
1721
-
1722
- require_part_number!(options[:part_number])
1723
- request.add_param('partNumber', options[:part_number])
1724
-
1725
- super(request, options)
1726
-
1727
- end
1728
-
1729
- process_response do |resp|
1730
- extract_object_headers(resp)
1731
- end
1732
-
1733
- simulate_response do |response|
1734
- response.data[:etag] = 'abc123'
1735
- end
1736
- end
1737
-
1738
- # @overload complete_multipart_upload(options = {})
1739
- # @param [Hash] options
1740
- # @option options [required,String] :bucket_name
1741
- # @option options [required,String] :key
1742
- # @option options [required,String] :upload_id
1743
- # @option options [required,Array<Hash>] :parts An array of hashes
1744
- # with the following keys:
1745
- # * `:part_number` [Integer] - *required*
1746
- # * `:etag` [String] - *required*
1747
- # @return [Core::Response]
1748
- object_method(:complete_multipart_upload, :post,
1749
- XML::CompleteMultipartUpload) do
1750
- configure_request do |req, options|
1751
- require_upload_id!(options[:upload_id])
1752
- validate_parts!(options[:parts])
1753
- super(req, options)
1754
- req.add_param('uploadId', options[:upload_id])
1755
-
1756
- req.body = Nokogiri::XML::Builder.new do |xml|
1757
- xml.CompleteMultipartUpload do
1758
- options[:parts].each do |part|
1759
- xml.Part do
1760
- xml.PartNumber(part[:part_number])
1761
- xml.ETag(part[:etag])
1762
- end
1763
- end
1764
- end
1765
- end.doc.root.to_xml
1766
-
1767
- end
1768
-
1769
- process_response do |resp|
1770
- extract_object_headers(resp)
1771
- end
1772
-
1773
- simulate_response do |response|
1774
- response.data = {}
1775
- end
1776
-
1777
- end
1778
-
1779
- # @overload abort_multipart_upload(options = {})
1780
- # @param [Hash] options
1781
- # @option options [required,String] :bucket_name
1782
- # @option options [required,String] :key
1783
- # @option options [required,String] :upload_id
1784
- # @return [Core::Response]
1785
- object_method(:abort_multipart_upload, :delete) do
1786
- configure_request do |req, options|
1787
- require_upload_id!(options[:upload_id])
1788
- super(req, options)
1789
- req.add_param('uploadId', options[:upload_id])
1790
- end
1791
- end
1792
-
1793
- # @overload list_parts(options = {})
1794
- # @param [Hash] options
1795
- # @option options [required,String] :bucket_name
1796
- # @option options [required,String] :key
1797
- # @option options [required,String] :upload_id
1798
- # @option options [Integer] :max_parts
1799
- # @option options [Integer] :part_number_marker
1800
- # @return [Core::Response]
1801
- object_method(:list_parts, :get, XML::ListParts) do
1802
-
1803
- configure_request do |req, options|
1804
- require_upload_id!(options[:upload_id])
1805
- super(req, options)
1806
- req.add_param('uploadId', options[:upload_id])
1807
- req.add_param('max-parts', options[:max_parts])
1808
- req.add_param('part-number-marker', options[:part_number_marker])
1809
- end
1810
-
1811
- end
1812
-
1813
- # Copies an object from one key to another.
1814
- # @overload copy_object(options = {})
1815
- # @param [Hash] options
1816
- # @option options [required, String] :bucket_name Name of the bucket
1817
- # to copy a object into.
1818
- # @option options [required, String] :key Where (object key) in the
1819
- # bucket the object should be copied to.
1820
- # @option options [String] :website_redirect_location If the bucket is
1821
- # configured as a website, redirects requests for this object to
1822
- # another object in the same bucket or to an external URL.
1823
- # @option options [required, String] :copy_source The source
1824
- # bucket name and key, joined by a forward slash ('/').
1825
- # This string must be URL-encoded. Additionally, you must
1826
- # have read access to the source object.
1827
- # @option options [String] :acl A canned ACL (e.g. 'private',
1828
- # 'public-read', etc). See the S3 API documentation for
1829
- # a complete list of valid values.
1830
- # @option options [Symbol,String] :server_side_encryption (nil) The
1831
- # algorithm used to encrypt the object on the server side
1832
- # (e.g. :aes256).
1833
- # @option options [String] :storage_class+ ('STANDARD')
1834
- # Controls whether Reduced Redundancy Storage is enabled for
1835
- # the object. Valid values are 'STANDARD' and
1836
- # 'REDUCED_REDUNDANCY'.
1837
- # @option options [String] :expires The date and time at which the
1838
- # object is no longer cacheable.
1839
- # @option options [String] :grant_read
1840
- # @option options [String] :grant_write
1841
- # @option options [String] :grant_read_acp
1842
- # @option options [String] :grant_write_acp
1843
- # @option options [String] :grant_full_control
1844
- # @return [Core::Response]
1845
- object_method(:copy_object, :put, :header_options => {
1846
- :website_redirect_location => 'x-amz-website-redirect-location',
1847
- :acl => 'x-amz-acl',
1848
- :grant_read => 'x-amz-grant-read',
1849
- :grant_write => 'x-amz-grant-write',
1850
- :grant_read_acp => 'x-amz-grant-read-acp',
1851
- :grant_write_acp => 'x-amz-grant-write-acp',
1852
- :grant_full_control => 'x-amz-grant-full-control',
1853
- :copy_source => 'x-amz-copy-source',
1854
- :cache_control => 'Cache-Control',
1855
- :metadata_directive => 'x-amz-metadata-directive',
1856
- :content_type => 'Content-Type',
1857
- :content_disposition => 'Content-Disposition',
1858
- :expires => 'Expires',
1859
- }) do
1860
-
1861
- configure_request do |req, options|
1862
-
1863
- validate!(:copy_source, options[:copy_source]) do
1864
- "may not be blank" if options[:copy_source].to_s.empty?
1865
- end
1866
-
1867
- options = options.merge(:copy_source => escape_path(options[:copy_source]))
1868
- super(req, options)
1869
- set_metadata(req, options)
1870
- set_storage_class(req, options)
1871
- set_server_side_encryption(req, options)
1872
-
1873
- if options[:version_id]
1874
- req.headers['x-amz-copy-source'] += "?versionId=#{options[:version_id]}"
1875
- end
1876
- end
1877
-
1878
- process_response do |resp|
1879
- extract_object_headers(resp)
1880
- end
1881
-
1882
- end
1883
-
1884
- object_method(:copy_part, :put, XML::CopyPart, :header_options => {
1885
- :copy_source => 'x-amz-copy-source',
1886
- :copy_source_range => 'x-amz-copy-source-range',
1887
- }) do
1888
-
1889
- configure_request do |request, options|
1890
-
1891
- validate!(:copy_source, options[:copy_source]) do
1892
- "may not be blank" if options[:copy_source].to_s.empty?
1893
- end
1894
-
1895
- validate!(:copy_source_range, options[:copy_source_range]) do
1896
- "must start with bytes=" if options[:copy_source_range] && !options[:copy_source_range].start_with?("bytes=")
1897
- end
1898
-
1899
- options = options.merge(:copy_source => escape_path(options[:copy_source]))
1900
-
1901
- require_upload_id!(options[:upload_id])
1902
- request.add_param('uploadId', options[:upload_id])
1903
-
1904
- require_part_number!(options[:part_number])
1905
- request.add_param('partNumber', options[:part_number])
1906
-
1907
- super(request, options)
1908
-
1909
- if options[:version_id]
1910
- req.headers['x-amz-copy-source'] += "?versionId=#{options[:version_id]}"
1911
- end
1912
-
1913
- end
1914
-
1915
- end
1916
-
1917
- end
1918
- end
1919
- end