Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:amazonwebservices/aws-sdk-for-ruby

  • Loading branch information...
commit 2be3f56ab7f859e2abc87633b0c2abd1822e24ec 2 parents b48e8d6 + ec015d5
@trevorrowe trevorrowe authored
View
1  lib/aws/ec2/reserved_instances.rb
@@ -28,6 +28,7 @@ class ReservedInstances < Resource
:currency_code,
:recurring_charges,
:offering_type,
+ :state,
]
include TaggedItem
View
3  lib/aws/s3/client.rb
@@ -1078,8 +1078,9 @@ def self.object_method(method_name, verb, *args, &block)
# @option options [required,String] :bucket_name
# @option options [required,Array<String>] :keys
# @option options [Boolean] :quiet (true)
+ # @option options [String] :mfa
# @return [Core::Response]
- bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects) do
+ bucket_method(:delete_objects, :post, 'delete', XML::DeleteObjects, :header_options => { :mfa => "x-amz-mfa" }) do
configure_request do |req, options|
super(req, options)
View
32 lib/aws/s3/object_collection.rb
@@ -116,13 +116,21 @@ def with_prefix prefix, mode = :replace
#
# bucket.objects.delete(to_delete)
#
- # @param [Mixed] objects One or more objects to delete. Each object
- # can be one of the following:
+ # @overload delete(objects)
+ # @param [Mixed] objects One or more objects to delete. Each object
+ # can be one of the following:
#
- # * An object key (string)
- # * A hash with :key and :version_id (for versioned objects)
- # * An {S3Object} instance
- # * An {ObjectVersion} instance
+ # * An object key (string)
+ # * A hash with :key and :version_id (for versioned objects)
+ # * An {S3Object} instance
+ # * An {ObjectVersion} instance
+ #
+ # @overload delete(objects, options)
+ # Deletes multiple objects, with additional options. The array can
+ # contain any of the types of objects the first method invocation style
+ # accepts.
+ # @param [Array] objects One or more objects to delete.
+ # @param [Hash] options Optional headers to pass on.
#
# @raise [BatchDeleteError] If any of the objects failed to delete,
# a BatchDeleteError will be raised with a summary of the errors.
@@ -131,6 +139,17 @@ def with_prefix prefix, mode = :replace
#
def delete *objects
+ # Detect and retrieve options from the end of the splat.
+ if
+ objects.size == 2 and
+ objects[0].is_a?(Array) and
+ objects[1].is_a?(Hash)
+ then
+ client_opts = objects.pop
+ else
+ client_opts = {}
+ end
+
objects = objects.flatten.collect do |obj|
case obj
when String then { :key => obj }
@@ -146,7 +165,6 @@ def delete *objects
end
batch_helper = BatchHelper.new(1000) do |batch|
- client_opts = {}
client_opts[:bucket_name] = bucket.name
client_opts[:quiet] = true
client_opts[:objects] = batch
View
2  spec/aws/s3/client_spec.rb
@@ -1568,6 +1568,8 @@ def should_determine_content_length_for data, length
it_should_behave_like "requires bucket_name"
+ it_should_behave_like "accepts mfa credentials"
+
#it_should_behave_like "an s3 http request", 'POST'
end
View
16 spec/aws/s3/object_collection_spec.rb
@@ -228,6 +228,22 @@ def stub_members(resp, quantity)
end
+ it 'uses an array of objects and hash of options when present' do
+
+ objects = ['key1','key2']
+ mfa = '123456 7890'
+
+ client.should_receive(:delete_objects).with(
+ :bucket_name => bucket.name,
+ :quiet => true,
+ :objects => [{:key => 'key1'}, {:key => 'key2'}],
+ :mfa => mfa).
+ and_return(delete_response)
+
+ collection.delete(objects, {:mfa => mfa})
+
+ end
+
end
context '#delete_if' do
Please sign in to comment.
Something went wrong with that request. Please try again.