2010-03-13 16:37:24 -05:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-08 17:40:02 -04:00
|
|
|
class Storage
|
2010-03-13 16:37:24 -05:00
|
|
|
class Real
|
2009-08-07 22:55:11 -04:00
|
|
|
|
|
|
|
# Delete an S3 bucket
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * bucket_name<~String> - name of bucket to delete
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-07 22:55:11 -04:00
|
|
|
# * status<~Integer> - 204
|
|
|
|
def delete_bucket(bucket_name)
|
|
|
|
request({
|
2009-08-16 14:44:50 -04:00
|
|
|
:expects => 204,
|
|
|
|
:headers => {},
|
|
|
|
:host => "#{bucket_name}.#{@host}",
|
|
|
|
:method => 'DELETE'
|
2009-08-07 22:55:11 -04:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
|
2010-03-13 16:37:24 -05:00
|
|
|
class Mock
|
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
|
2010-03-13 16:37:24 -05:00
|
|
|
if @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))
|
2010-03-13 16:37:24 -05:00
|
|
|
elsif @data[:buckets][bucket_name] && !@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
|
2010-03-13 16:37:24 -05:00
|
|
|
@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
|