1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/requests/simpledb/list_domains.rb
Josh Lane d48d376e9c initial import
* take the liberty of correcting Aws naming
2014-12-31 09:17:51 -08:00

55 lines
1.7 KiB
Ruby

module Fog
module AWS
class SimpleDB
class Real
require 'fog/aws/parsers/simpledb/list_domains'
# List SimpleDB domains
#
# ==== Parameters
# * options<~Hash> - options, defaults to {}
# * 'MaxNumberOfDomains'<~Integer> - number of domains to return
# between 1 and 100, defaults to 100
# * 'NextToken'<~String> - Offset token to start listing, defaults to nil
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'BoxUsage'
# * 'Domains' - array of domain names.
# * 'NextToken' - offset to start with if there are are more domains to list
# * 'RequestId'
def list_domains(options = {})
request({
'Action' => 'ListDomains',
:idempotent => true,
:parser => Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string)
}.merge!(options))
end
end
class Mock
def list_domains(options = {})
response = Excon::Response.new
keys = self.data[:domains].keys
max = options['MaxNumberOfDomains'] || keys.size
offset = options['NextToken'] || 0
domains = []
for key, value in self.data[:domains].keys[offset...max]
domains << key
end
response.status = 200
response.body = {
'BoxUsage' => Fog::AWS::Mock.box_usage,
'Domains' => domains,
'RequestId' => Fog::AWS::Mock.request_id
}
if max < keys.size
response.body['NextToken'] = max + 1
end
response
end
end
end
end
end