1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Add delete_shared_object and corresponding model support.

This commit is contained in:
Rupak Ganguly 2012-10-30 17:47:17 -04:00
parent 64d319d40f
commit 86622a5c2a
5 changed files with 44 additions and 46 deletions

View file

@ -29,10 +29,7 @@ module Fog
def save(options = {})
requires :url
data = connection.put_shared_container(url, options)
merge_attributes(data.headers)
true
rescue Fog::Storage::HP::NotFound, Fog::HP::Errors::Forbidden
# put is not allowed
false
end
end

View file

@ -32,7 +32,10 @@ module Fog
def destroy
requires :shared_directory, :key
# delete is not allowed
connection.delete_shared_object(self.url)
true
# throws exception Fog::HP::Errors::Forbidden if insufficient access
rescue Fog::Storage::HP::NotFound
false
end

View file

@ -0,0 +1,38 @@
module Fog
module Storage
class HP
class Real
# Delete a shared object
#
# ==== Parameters
# * shared_object_url<~String> - Url of the shared object
#
def delete_shared_object(shared_object_url)
# split up the shared object url
uri = URI.parse(shared_object_url)
path = uri.path
response = shared_request(
:expects => 204,
:method => 'DELETE',
:path => path
)
response
end
end
class Mock # :nodoc:all
def delete_shared_object(shared_object_url)
response = Excon::Response.new
response.status = 204
response
end
end
end
end
end

View file

@ -1,40 +0,0 @@
module Fog
module Storage
class HP
class Real
# Update a shared container
#
# ==== Parameters
# * shared_container_url<~String> - Shared url for the container
# * options<~Hash> - header options
#
def put_shared_container(shared_container_url, options = {})
# split up the shared container url
uri = URI.parse(shared_container_url)
path = uri.path
response = shared_request(
:expects => [201, 202],
:headers => options,
:method => 'PUT',
:path => path
)
response
end
end
class Mock # :nodoc:all
def put_shared_container(shared_container_url, options = {})
response = Excon::Response.new
response.status = 201
response.headers.merge!(options)
response
end
end
end
end
end

View file

@ -21,6 +21,7 @@ module Fog
request_path 'fog/hp/requests/storage'
request :delete_container
request :delete_object
request :delete_shared_object
request :get_container
request :get_containers
request :get_object
@ -33,7 +34,6 @@ module Fog
request :head_shared_container
request :head_shared_object
request :put_container
request :put_shared_container
request :put_object
request :put_shared_object