aws-sdk 1.6.9 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/aws.rb +8 -0
  3. data/lib/aws/api_config/CloudSearch-2011-02-01.yml +681 -0
  4. data/lib/aws/api_config/DynamoDB-2011-12-05.yml +4 -0
  5. data/lib/aws/api_config/EMR-2009-03-31.yml +18 -0
  6. data/lib/aws/api_config/ElastiCache-2012-03-09.yml +777 -0
  7. data/lib/aws/api_config/ElasticBeanstalk-2010-12-01.yml +823 -0
  8. data/lib/aws/api_config/RDS-2012-07-31.yml +1621 -0
  9. data/lib/aws/cloud_search.rb +31 -0
  10. data/lib/aws/cloud_search/client.rb +558 -0
  11. data/lib/aws/cloud_search/config.rb +18 -0
  12. data/lib/aws/cloud_search/errors.rb +22 -0
  13. data/lib/aws/cloud_search/request.rb +23 -0
  14. data/lib/aws/cloud_watch/alarm.rb +1 -1
  15. data/lib/aws/cloud_watch/metric.rb +3 -3
  16. data/lib/aws/core.rb +18 -3
  17. data/lib/aws/core/configuration.rb +11 -0
  18. data/lib/aws/core/inflection.rb +1 -0
  19. data/lib/aws/core/service_interface.rb +1 -1
  20. data/lib/aws/dynamo_db/batch_get.rb +19 -12
  21. data/lib/aws/dynamo_db/client.rb +27 -1
  22. data/lib/aws/dynamo_db/config.rb +2 -0
  23. data/lib/aws/dynamo_db/item_collection.rb +2 -2
  24. data/lib/aws/dynamo_db/table.rb +8 -2
  25. data/lib/aws/ec2/reserved_instances.rb +3 -0
  26. data/lib/aws/ec2/reserved_instances_offering.rb +3 -1
  27. data/lib/aws/elastic_beanstalk.rb +48 -0
  28. data/lib/aws/elastic_beanstalk/client.rb +867 -0
  29. data/lib/aws/elastic_beanstalk/config.rb +18 -0
  30. data/lib/aws/elastic_beanstalk/errors.rb +22 -0
  31. data/lib/aws/elastic_beanstalk/request.rb +23 -0
  32. data/lib/aws/elasticache.rb +48 -0
  33. data/lib/aws/elasticache/client.rb +758 -0
  34. data/lib/aws/elasticache/config.rb +18 -0
  35. data/lib/aws/elasticache/errors.rb +22 -0
  36. data/lib/aws/elasticache/request.rb +23 -0
  37. data/lib/aws/emr/client.rb +30 -6
  38. data/lib/aws/emr/job_flow.rb +10 -0
  39. data/lib/aws/rds.rb +69 -0
  40. data/lib/aws/rds/client.rb +1592 -0
  41. data/lib/aws/rds/config.rb +18 -0
  42. data/lib/aws/rds/db_instance.rb +201 -0
  43. data/lib/aws/rds/db_instance_collection.rb +75 -0
  44. data/lib/aws/rds/db_snapshot.rb +163 -0
  45. data/lib/aws/rds/db_snapshot_collection.rb +89 -0
  46. data/lib/aws/rds/errors.rb +22 -0
  47. data/lib/aws/rds/request.rb +23 -0
  48. data/lib/aws/s3/bucket_tag_collection.rb +1 -1
  49. data/lib/aws/s3/client.rb +4 -2
  50. data/lib/aws/s3/errors.rb +0 -1
  51. data/lib/aws/s3/object_collection.rb +40 -22
  52. data/lib/aws/s3/object_version.rb +7 -2
  53. data/lib/aws/s3/request.rb +1 -1
  54. data/lib/aws/s3/s3_object.rb +35 -11
  55. data/lib/aws/version.rb +1 -1
  56. metadata +33 -2
@@ -0,0 +1,89 @@
1
+ # Copyright 2011-2012 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 RDS
16
+ class DBSnapshotCollection
17
+
18
+ include Core::Collection::WithLimitAndNextToken
19
+
20
+ # @private
21
+ def initialize options = {}
22
+ @filters = options[:filters] || {}
23
+ super
24
+ end
25
+
26
+ # @param [String] db_snapshot_id
27
+ # @return [DBSnapshot] Returns a {DBSnapshot} with the given ID.
28
+ def [] db_snapshot_id
29
+ DBSnapshot.new(db_snapshot_id, :config => config)
30
+ end
31
+
32
+ # Filters the DB snapshots to those beloning to a single db instance.
33
+ # You may pass the ID of a db instance or a {DBInstance} object.
34
+ #
35
+ # @param [String,DBInstance] db_instance A db instance identifier
36
+ # string or a {DBInstance} object.
37
+ #
38
+ # @return [DBSnapshotCollection]
39
+ #
40
+ def db_instance db_instance
41
+ id = db_instance.is_a?(Core::Model) ? db_instance.id : db_instance
42
+ filter(:db_instance_identifier, id.to_s.downcase)
43
+ end
44
+
45
+ # Filters the DB snapshots to those of a given snapshot type.
46
+ # @param [String] snapshot_type
47
+ # @return [DBSnapshotCollection]
48
+ def with_type snapshot_type
49
+ filter(:snapshot_type, snapshot_type)
50
+ end
51
+ alias_method :type, :with_type
52
+
53
+ # @param [String,Symbol] name
54
+ # @param [Mixed] value
55
+ # @return [DBSnapshotCollection]
56
+ def filter name, value
57
+ options = {}
58
+ options[:filters] = @filters.merge(name.to_s.to_sym => value)
59
+ options[:config] = config
60
+ DBSnapshotCollection.new(options)
61
+ end
62
+
63
+ protected
64
+
65
+ def _each_item marker, max_records, options = {}, &block
66
+
67
+ options = @filters.merge(options)
68
+ options[:marker] = marker if marker
69
+ options[:max_records] = [[20,max_records].max,100].min if max_records
70
+
71
+ response = client.describe_db_snapshots(options)
72
+ response.data[:db_snapshots].each do |details|
73
+
74
+ db_snapshot = DBSnapshot.new_from(
75
+ :describe_db_snapshots,
76
+ details,
77
+ details[:db_snapshot_identifier],
78
+ :config => config)
79
+
80
+ yield(db_snapshot)
81
+
82
+ end
83
+
84
+ response.data[:marker]
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2011-2012 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 RDS
16
+ module Errors
17
+
18
+ extend Core::LazyErrorClasses
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright 2011-2012 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 RDS
16
+
17
+ # @private
18
+ class Request < Core::Http::Request
19
+ include Core::Signature::Version2
20
+ end
21
+
22
+ end
23
+ end
@@ -20,7 +20,7 @@ module AWS
20
20
  #
21
21
  # bucket.tags['key'] = 'value'
22
22
  #
23
- # @exapmle Getting a tag.
23
+ # @example Getting a tag.
24
24
  #
25
25
  # bucket.tags['key']
26
26
  # #=> 'value'
@@ -953,8 +953,9 @@ module AWS
953
953
  # @option options [required,String] :bucket_name
954
954
  # @option options [required,String] :key
955
955
  # @option options [String] :version_id
956
+ # @option options [String] :mfa
956
957
  # @return [Core::Response]
957
- object_method(:delete_object, :delete) do
958
+ object_method(:delete_object, :delete, :header_options => { :mfa => "x-amz-mfa" }) do
958
959
 
959
960
  configure_request do |req, options|
960
961
  super(req, options)
@@ -1077,8 +1078,9 @@ module AWS
1077
1078
  # @option options [required,String] :bucket_name
1078
1079
  # @option options [required,Array<String>] :keys
1079
1080
  # @option options [Boolean] :quiet (true)
1081
+ # @option options [String] :mfa
1080
1082
  # @return [Core::Response]
1081
- bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects) do
1083
+ bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects, :header_options => { :mfa => "x-amz-mfa" }) do
1082
1084
  configure_request do |req, options|
1083
1085
 
1084
1086
  super(req, options)
@@ -28,7 +28,6 @@ module AWS
28
28
  #
29
29
  # All errors raised as a result of error responses from the
30
30
  # service are instances of either {ClientError} or {ServerError}.
31
- # @private
32
31
  module Errors
33
32
 
34
33
  # @private
@@ -23,7 +23,7 @@ module AWS
23
23
  # # this will not make any requests against S3
24
24
  # object = bucket.objects['foo.jpg']
25
25
  # object.key #=> 'foo.jpg'
26
- #
26
+ #
27
27
  # == Finding objects with a Prefix
28
28
  #
29
29
  # Given a bucket with the following keys:
@@ -38,7 +38,7 @@ module AWS
38
38
  #
39
39
  # bucket.objects.with_prefix('videos').collect(&:key)
40
40
  # #=> ['videos/comedy.mpg', 'videos/dancing.mpg']
41
- #
41
+ #
42
42
  # == Exploring Objects with a Tree Interface
43
43
  #
44
44
  # Given a bucket with the following keys:
@@ -88,7 +88,7 @@ module AWS
88
88
  # Returns an S3Object given its name. For example:
89
89
  #
90
90
  # @example
91
- #
91
+ #
92
92
  # object = bucket.objects['file.txt']
93
93
  # object.class #=> S3Object
94
94
  #
@@ -116,28 +116,47 @@ module AWS
116
116
  #
117
117
  # bucket.objects.delete(to_delete)
118
118
  #
119
- # @param [Mixed] objects One or more objects to delete. Each object
120
- # can be one of the following:
119
+ # @overload delete(objects)
120
+ # @param [Mixed] objects One or more objects to delete. Each object
121
+ # can be one of the following:
121
122
  #
122
- # * An object key (string)
123
- # * A hash with :key and :version_id (for versioned objects)
124
- # * An {S3Object} instance
125
- # * An {ObjectVersion} instance
123
+ # * An object key (string)
124
+ # * A hash with :key and :version_id (for versioned objects)
125
+ # * An {S3Object} instance
126
+ # * An {ObjectVersion} instance
126
127
  #
127
- # @raise [BatchDeleteError] If any of the objects failed to delete,
128
+ # @overload delete(objects, options)
129
+ # Deletes multiple objects, with additional options. The array can
130
+ # contain any of the types of objects the first method invocation style
131
+ # accepts.
132
+ # @param [Array] objects One or more objects to delete.
133
+ # @param [Hash] options Optional headers to pass on.
134
+ #
135
+ # @raise [BatchDeleteError] If any of the objects failed to delete,
128
136
  # a BatchDeleteError will be raised with a summary of the errors.
129
137
  #
130
138
  # @return [nil]
131
139
  #
132
140
  def delete *objects
133
141
 
142
+ # Detect and retrieve options from the end of the splat.
143
+ if
144
+ objects.size == 2 and
145
+ objects[0].is_a?(Array) and
146
+ objects[1].is_a?(Hash)
147
+ then
148
+ client_opts = objects.pop
149
+ else
150
+ client_opts = {}
151
+ end
152
+
134
153
  objects = objects.flatten.collect do |obj|
135
154
  case obj
136
155
  when String then { :key => obj }
137
156
  when Hash then obj
138
157
  when S3Object then { :key => obj.key }
139
158
  when ObjectVersion then { :key => obj.key, :version_id => obj.version_id }
140
- else
159
+ else
141
160
  msg = "objects must be keys (strings or hashes with :key and " +
142
161
  ":version_id), S3Objects or ObjectVersions, got " +
143
162
  object.class.name
@@ -146,7 +165,6 @@ module AWS
146
165
  end
147
166
 
148
167
  batch_helper = BatchHelper.new(1000) do |batch|
149
- client_opts = {}
150
168
  client_opts[:bucket_name] = bucket.name
151
169
  client_opts[:quiet] = true
152
170
  client_opts[:objects] = batch
@@ -167,14 +185,14 @@ module AWS
167
185
 
168
186
  batch_helper.complete!
169
187
 
170
- raise Errors::BatchDeleteError.new(error_counts) unless
188
+ raise Errors::BatchDeleteError.new(error_counts) unless
171
189
  error_counts.empty?
172
190
 
173
191
  nil
174
192
 
175
193
  end
176
194
 
177
- # Deletes each object in the collection that returns a true value
195
+ # Deletes each object in the collection that returns a true value
178
196
  # from block passed to this method. Deletes are batched for efficiency.
179
197
  #
180
198
  # # delete text files in the 2009 "folder"
@@ -182,14 +200,14 @@ module AWS
182
200
  #
183
201
  # @yieldparam [S3Object] object
184
202
  #
185
- # @raise [BatchDeleteError] If any of the objects failed to delete,
203
+ # @raise [BatchDeleteError] If any of the objects failed to delete,
186
204
  # a BatchDeleteError will be raised with a summary of the errors.
187
205
  #
188
206
  def delete_if &block
189
207
 
190
208
  error_counts = {}
191
209
 
192
- batch_helper = BatchHelper.new(1000) do |objects|
210
+ batch_helper = BatchHelper.new(1000) do |objects|
193
211
  begin
194
212
  delete(objects)
195
213
  rescue Errors::BatchDeleteError => error
@@ -206,7 +224,7 @@ module AWS
206
224
 
207
225
  batch_helper.complete!
208
226
 
209
- raise Errors::BatchDeleteError.new(error_counts) unless
227
+ raise Errors::BatchDeleteError.new(error_counts) unless
210
228
  error_counts.empty?
211
229
 
212
230
  nil
@@ -223,7 +241,7 @@ module AWS
223
241
  #
224
242
  # bucket.objects.with_prefix('2009/').delete_all
225
243
  #
226
- # @raise [BatchDeleteError] If any of the objects failed to delete,
244
+ # @raise [BatchDeleteError] If any of the objects failed to delete,
227
245
  # a BatchDeleteError will be raised with a summary of the errors.
228
246
  #
229
247
  # @return [Array] Returns an array of results
@@ -243,7 +261,7 @@ module AWS
243
261
  end
244
262
  end
245
263
 
246
- raise Errors::BatchDeleteError.new(error_counts) unless
264
+ raise Errors::BatchDeleteError.new(error_counts) unless
247
265
  error_counts.empty?
248
266
 
249
267
  nil
@@ -255,10 +273,10 @@ module AWS
255
273
  # Use break or raise an exception to terminate the enumeration.
256
274
  #
257
275
  # @param [Hash] options
258
- # @option options [Integer] :limit (nil) The maximum number of
276
+ # @option options [Integer] :limit (nil) The maximum number of
259
277
  # objects to yield.
260
278
  # @option options [Integer] :batch_size (1000) The number of objects to
261
- # fetch each request to S3. Maximum is 1000 keys at time.
279
+ # fetch each request to S3. Maximum is 1000 keys at time.
262
280
  # @return [nil]
263
281
  def each options = {}, &block
264
282
  super
@@ -299,7 +317,7 @@ module AWS
299
317
  # processes items in batches of 1k items
300
318
  # @private
301
319
  class BatchHelper
302
-
320
+
303
321
  def initialize batch_size, &block
304
322
  @batch_size = batch_size
305
323
  @block = block
@@ -94,9 +94,14 @@ module AWS
94
94
  end
95
95
 
96
96
  # Deletes this object version from S3.
97
+ # @option options [String] :mfa The serial number and current token code of
98
+ # the Multi-Factor Authentication (MFA) device for the user. Format
99
+ # is "SERIAL TOKEN" - with a space between the serial and token.
97
100
  # @return (see S3Object#delete)
98
- def delete
99
- object.delete(:version_id => @version_id)
101
+ def delete(options = {})
102
+ object.delete(:version_id => @version_id,
103
+ :mfa => options[:mfa]
104
+ )
100
105
  end
101
106
 
102
107
  # @return [Boolean] Returns this if this is the latest version of
@@ -152,7 +152,7 @@ module AWS
152
152
  x_amz = headers.select{|name, value| name.to_s =~ /^x-amz-/i }
153
153
  x_amz = x_amz.collect{|name, value| [name.downcase, value] }
154
154
  x_amz = x_amz.sort_by{|name, value| name }
155
- x_amz = x_amz.collect{|name, value| "#{name}:#{value}" }.join("\n")
155
+ x_amz = x_amz.collect{|name, value| "#{name}:#{value.to_s.strip}" }.join("\n")
156
156
  x_amz == '' ? nil : x_amz
157
157
  end
158
158
 
@@ -120,7 +120,7 @@ module AWS
120
120
  # Amazon S3 provides server side encryption for an additional cost.
121
121
  # You can specify to use server side encryption when writing an object.
122
122
  #
123
- # obj.write('data', :server_size_encryption => :aes256)
123
+ # obj.write('data', :server_side_encryption => :aes256)
124
124
  #
125
125
  # You can also make this the default behavior.
126
126
  #
@@ -361,9 +361,12 @@ module AWS
361
361
  # if you use client-side encryption and the encryption materials
362
362
  # were stored in a separate object in S3 (key.instruction).
363
363
  #
364
+ # @option [String] :mfa The serial number and current token code of
365
+ # the Multi-Factor Authentication (MFA) device for the user. Format
366
+ # is "SERIAL TOKEN" - with a space between the serial and token.
367
+ #
364
368
  # @return [nil]
365
369
  def delete options = {}
366
-
367
370
  client.delete_object(options.merge(
368
371
  :bucket_name => bucket.name,
369
372
  :key => key))
@@ -1114,6 +1117,16 @@ module AWS
1114
1117
  # @option options [Boolean] :secure (true) Whether to generate a
1115
1118
  # secure (HTTPS) URL or a plain HTTP url.
1116
1119
  #
1120
+ # @option options [String] :endpoint Sets the hostname of the
1121
+ # endpoint (overrides config.s3_endpoint).
1122
+ #
1123
+ # @option options [Integer] :port Sets the port of the
1124
+ # endpoint (overrides config.s3_port).
1125
+ #
1126
+ # @option options [Boolean] :force_path_style (false) Indicates
1127
+ # whether the generated URL should place the bucket name in
1128
+ # the path (true) or as a subdomain (false).
1129
+ #
1117
1130
  # @option options [String] :response_content_type Sets the
1118
1131
  # Content-Type header of the response when performing an
1119
1132
  # HTTP GET on the returned URL.
@@ -1139,6 +1152,9 @@ module AWS
1139
1152
  # HTTP GET on the returned URL.
1140
1153
  # @return [URI::HTTP, URI::HTTPS]
1141
1154
  def url_for(method, options = {})
1155
+
1156
+ options[:secure] = config.use_ssl? unless options.key?(:secure)
1157
+
1142
1158
  req = request_for_signing(options)
1143
1159
 
1144
1160
  method = http_method(method)
@@ -1152,7 +1168,8 @@ module AWS
1152
1168
  config.credential_provider.session_token) if
1153
1169
  config.credential_provider.session_token
1154
1170
 
1155
- build_uri(options[:secure] != false, req)
1171
+ secure = options.fetch(:secure, config.use_ssl?)
1172
+ build_uri(req, options)
1156
1173
  end
1157
1174
 
1158
1175
  # Generates a public (not authenticated) URL for the object.
@@ -1165,8 +1182,8 @@ module AWS
1165
1182
  # @return [URI::HTTP, URI::HTTPS]
1166
1183
  #
1167
1184
  def public_url(options = {})
1168
- req = request_for_signing(options)
1169
- build_uri(options[:secure] != false, req)
1185
+ options[:secure] = config.use_ssl? unless options.key?(:secure)
1186
+ build_uri(request_for_signing(options), options)
1170
1187
  end
1171
1188
 
1172
1189
  # Generates fields for a presigned POST to this object. This
@@ -1265,9 +1282,10 @@ module AWS
1265
1282
  estimate
1266
1283
  end
1267
1284
 
1268
- def build_uri(secure, request)
1269
- uri_class = secure ? URI::HTTPS : URI::HTTP
1285
+ def build_uri(request, options)
1286
+ uri_class = options[:secure] ? URI::HTTPS : URI::HTTP
1270
1287
  uri_class.build(:host => request.host,
1288
+ :port => request.port,
1271
1289
  :path => request.path,
1272
1290
  :query => request.querystring)
1273
1291
  end
@@ -1279,9 +1297,8 @@ module AWS
1279
1297
  parts << ""
1280
1298
  parts << ""
1281
1299
  parts << expires
1282
- if config.credential_provider.session_token
1283
- parts << "x-amz-security-token:"
1284
- parts << "#{config.credential_provider.session_token}"
1300
+ if token = config.credential_provider.session_token
1301
+ parts << "x-amz-security-token:#{token}"
1285
1302
  end
1286
1303
  parts << request.canonicalized_resource
1287
1304
 
@@ -1318,11 +1335,18 @@ module AWS
1318
1335
  end
1319
1336
 
1320
1337
  def request_for_signing(options)
1338
+
1339
+ port = [443, 80].include?(config.s3_port) ?
1340
+ (options[:secure] ? 443 : 80) :
1341
+ config.s3_port
1342
+
1321
1343
  req = Request.new
1322
1344
 
1323
1345
  req.bucket = bucket.name
1324
1346
  req.key = key
1325
- req.host = config.s3_endpoint
1347
+ req.host = options.fetch(:endpoint, config.s3_endpoint)
1348
+ req.port = options.fetch(:port, port)
1349
+ req.force_path_style = options.fetch(:force_path_style, config.s3_force_path_style)
1326
1350
 
1327
1351
  REQUEST_PARAMETERS.each do |param|
1328
1352
  req.add_param(param.to_s.tr("_","-"),