fog--fog/lib/fog/rackspace/requests/files/get_containers.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

module Fog
module Rackspace
module Files
class Real
2009-10-11 20:37:25 +00:00
# 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
2009-10-12 16:25:33 +00:00
#
2009-10-11 20:37:25 +00:00
# ==== Returns
# * response<~Excon::Response>:
2009-10-12 16:25:33 +00:00
# * body<~Array>:
# * container<~Hash>:
# * 'bytes'<~Integer>: - Number of bytes used by container
# * 'count'<~Integer>: - Number of items in container
# * 'name'<~String>: - Name of container
2009-10-11 20:37:25 +00:00
def get_containers(options = {})
options = { 'format' => 'json' }.merge!(options)
query = ''
2009-10-11 20:37:25 +00:00
for key, value in options
2009-10-27 00:56:08 +00:00
query << "#{key}=#{CGI.escape(value)}&"
2009-10-11 20:37:25 +00:00
end
2009-10-27 00:56:08 +00:00
query.chop!
2009-10-11 20:37:25 +00:00
response = storage_request(
:expects => [200, 204],
:method => 'GET',
:path => '',
2009-10-27 00:56:08 +00:00
:query => query
2009-10-11 20:37:25 +00:00
)
response
end
end
class Mock
2009-10-11 20:37:25 +00:00
def get_containers(options = {})
Fog::Mock.not_implemented
2009-10-11 20:37:25 +00:00
end
end
end
end
end