mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add #get_containers, #get_container, #put_container and #delete_container methods to the storage service.
This commit is contained in:
parent
a519d2ef85
commit
0210723e1e
4 changed files with 125 additions and 0 deletions
23
lib/fog/storage/requests/hp/delete_container.rb
Normal file
23
lib/fog/storage/requests/hp/delete_container.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
# Delete an existing container
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - Name of container to delete
|
||||
#
|
||||
def delete_container(name)
|
||||
response = request(
|
||||
:expects => 204,
|
||||
:method => 'DELETE',
|
||||
:path => URI.escape(name)
|
||||
)
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
45
lib/fog/storage/requests/hp/get_container.rb
Normal file
45
lib/fog/storage/requests/hp/get_container.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
# Get details for container and total bytes stored
|
||||
#
|
||||
# ==== Parameters
|
||||
# * container<~String> - Name of container to retrieve info for
|
||||
# * options<~String>:
|
||||
# * 'limit'<~String> - Maximum number of objects to return
|
||||
# * 'marker'<~String> - Only return objects whose name is greater than marker
|
||||
# * 'prefix'<~String> - Limits results to those starting with prefix
|
||||
# * 'path'<~String> - Return objects nested in the pseudo path
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * headers<~Hash>:
|
||||
# * 'X-Account-Container-Count'<~String> - Count of containers
|
||||
# * 'X-Account-Bytes-Used'<~String> - Bytes used
|
||||
# * body<~Array>:
|
||||
# * 'bytes'<~Integer> - Number of bytes used by container
|
||||
# * 'count'<~Integer> - Number of items in container
|
||||
# * 'name'<~String> - Name of container
|
||||
# * item<~Hash>:
|
||||
# * 'bytes'<~String> - Size of object
|
||||
# * 'content_type'<~String> Content-Type of object
|
||||
# * 'hash'<~String> - Hash of object (etag?)
|
||||
# * 'last_modified'<~String> - Last modified timestamp
|
||||
# * 'name'<~String> - Name of object
|
||||
def get_container(container, options = {})
|
||||
options = options.reject {|key, value| value.nil?}
|
||||
response = request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => URI.escape(container),
|
||||
:query => {'format' => 'json'}.merge!(options)
|
||||
)
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
lib/fog/storage/requests/hp/get_containers.rb
Normal file
34
lib/fog/storage/requests/hp/get_containers.rb
Normal file
|
@ -0,0 +1,34 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
# List existing storage containers
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'limit'<~Integer> - Upper limit to number of results returned
|
||||
# * 'marker'<~String> - Only return objects with name greater than this value
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * container<~Hash>:
|
||||
# * 'bytes'<~Integer>: - Number of bytes used by container
|
||||
# * 'count'<~Integer>: - Number of items in container
|
||||
# * 'name'<~String>: - Name of container
|
||||
def get_containers(options = {})
|
||||
options = options.reject {|key, value| value.nil?}
|
||||
response = request(
|
||||
:expects => [200, 204],
|
||||
:method => 'GET',
|
||||
:path => '',
|
||||
:query => {'format' => 'json'}.merge!(options)
|
||||
)
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/storage/requests/hp/put_container.rb
Normal file
23
lib/fog/storage/requests/hp/put_container.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Storage
|
||||
class Real
|
||||
|
||||
# Create a new container
|
||||
#
|
||||
# ==== Parameters
|
||||
# * name<~String> - Name for container, should be < 256 bytes and must not contain '/'
|
||||
#
|
||||
def put_container(name)
|
||||
response = request(
|
||||
:expects => [201, 202],
|
||||
:method => 'PUT',
|
||||
:path => URI.escape(name)
|
||||
)
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue