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:
parent
64d319d40f
commit
86622a5c2a
5 changed files with 44 additions and 46 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
38
lib/fog/hp/requests/storage/delete_shared_object.rb
Normal file
38
lib/fog/hp/requests/storage/delete_shared_object.rb
Normal 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
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue