1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/aws/requests/simpledb/list_domains.rb

58 lines
1.6 KiB
Ruby
Raw Normal View History

module Fog
module AWS
module SimpleDB
class Real
2009-09-08 00:25:50 -04:00
require 'fog/aws/parsers/simpledb/list_domains'
2009-09-08 00:25:50 -04:00
# 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>:
2009-09-08 00:25:50 -04:00
# * 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'
}.merge!(options), Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
end
end
class Mock
2009-09-08 00:25:50 -04:00
def list_domains(options = {})
2009-11-20 14:08:08 -05:00
response = Excon::Response.new
keys = @data[:domains].keys
2009-09-08 00:25:50 -04:00
max = options['MaxNumberOfDomains'] || keys.size
offset = options['NextToken'] || 0
domains = []
for key, value in @data[:domains].keys[offset...max]
2009-09-08 00:25:50 -04:00
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