2010-03-13 16:37:24 -05:00
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class AWS
|
2010-03-13 16:37:24 -05:00
|
|
|
class Real
|
2009-08-07 22:55:11 -04:00
|
|
|
|
|
|
|
# Delete an S3 bucket
|
|
|
|
#
|
2012-12-31 21:33:14 -05:00
|
|
|
# @param bucket_name [String] name of bucket to delete
|
2009-08-07 22:55:11 -04:00
|
|
|
#
|
2012-12-31 21:33:14 -05:00
|
|
|
# @return [Excon::Response] response:
|
|
|
|
# * status [Integer] - 204
|
2010-10-29 21:05:59 -04:00
|
|
|
#
|
2012-12-31 21:33:14 -05:00
|
|
|
# @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETE.html
|
2010-10-29 21:05:59 -04:00
|
|
|
|
2009-08-07 22:55:11 -04:00
|
|
|
def delete_bucket(bucket_name)
|
|
|
|
request({
|
2009-08-16 14:44:50 -04:00
|
|
|
:expects => 204,
|
|
|
|
:headers => {},
|
2013-04-12 06:31:10 -04:00
|
|
|
:bucket_name => bucket_name,
|
2009-08-16 14:44:50 -04:00
|
|
|
:method => 'DELETE'
|
2009-08-07 22:55:11 -04:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
|
2010-10-29 21:16:36 -04:00
|
|
|
class Mock # :nodoc:all
|
2009-08-07 22:55:11 -04:00
|
|
|
|
|
|
|
def delete_bucket(bucket_name)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2011-05-19 18:35:33 -04:00
|
|
|
if self.data[:buckets][bucket_name].nil?
|
2009-08-16 14:45:52 -04:00
|
|
|
response.status = 404
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
2011-05-19 18:35:33 -04:00
|
|
|
elsif self.data[:buckets][bucket_name] && !self.data[:buckets][bucket_name][:objects].empty?
|
2009-09-02 23:09:06 -04:00
|
|
|
response.status = 409
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
2009-09-02 23:09:06 -04:00
|
|
|
else
|
2011-05-19 18:35:33 -04:00
|
|
|
self.data[:buckets].delete(bucket_name)
|
2009-09-02 23:09:06 -04:00
|
|
|
response.status = 204
|
2009-08-08 15:31:32 -04:00
|
|
|
end
|
2009-08-07 22:55:11 -04:00
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-03-13 16:37:24 -05:00
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|