2010-09-18 13:40:48 -04:00
|
|
|
module Fog
|
2011-06-15 17:26:43 -04:00
|
|
|
module Storage
|
|
|
|
class Google
|
2010-09-18 13:40:48 -04:00
|
|
|
class Real
|
|
|
|
|
2010-09-24 09:43:34 -04:00
|
|
|
# Delete an object from Google Storage
|
2010-09-18 13:40:48 -04:00
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * bucket_name<~String> - Name of bucket containing object to delete
|
|
|
|
# * object_name<~String> - Name of object to delete
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * status<~Integer> - 204
|
|
|
|
def delete_object(bucket_name, object_name)
|
|
|
|
request({
|
|
|
|
:expects => 204,
|
|
|
|
:headers => {},
|
|
|
|
:host => "#{bucket_name}.#{@host}",
|
|
|
|
:idempotent => true,
|
|
|
|
:method => 'DELETE',
|
|
|
|
:path => CGI.escape(object_name)
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
class Mock
|
|
|
|
|
|
|
|
def delete_object(bucket_name, object_name)
|
|
|
|
response = Excon::Response.new
|
2011-05-19 18:35:33 -04:00
|
|
|
if bucket = self.data[:buckets][bucket_name]
|
2010-09-20 18:33:34 -04:00
|
|
|
if object = bucket[:objects][object_name]
|
|
|
|
response.status = 204
|
|
|
|
bucket[:objects].delete(object_name)
|
|
|
|
else
|
|
|
|
response.status = 404
|
|
|
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
|
|
|
end
|
2010-09-18 13:40:48 -04:00
|
|
|
else
|
|
|
|
response.status = 404
|
|
|
|
raise(Excon::Errors.status_error({:expects => 204}, response))
|
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|