2010-03-14 23:11:43 -04:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-03 04:11:45 -04:00
|
|
|
class SimpleDB
|
2010-03-14 23:11:43 -04:00
|
|
|
class Real
|
2009-09-08 22:57:53 -04:00
|
|
|
|
2010-06-12 18:31:17 -04:00
|
|
|
require 'fog/aws/parsers/simpledb/domain_metadata'
|
|
|
|
|
2009-09-08 22:57:53 -04:00
|
|
|
# List metadata for SimpleDB domain
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * domain_name<~String> - Name of domain. Must be between 3 and 255 of the
|
|
|
|
# following characters: a-z, A-Z, 0-9, '_', '-' and '.'.
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-09-08 22:57:53 -04:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'AttributeNameCount' - number of unique attribute names in domain
|
|
|
|
# * 'AttributeNamesSizeBytes' - total size of unique attribute names, in bytes
|
|
|
|
# * 'AttributeValueCount' - number of all name/value pairs in domain
|
|
|
|
# * 'AttributeValuesSizeBytes' - total size of attributes, in bytes
|
|
|
|
# * 'BoxUsage'
|
|
|
|
# * 'ItemCount' - number of items in domain
|
|
|
|
# * 'ItemNameSizeBytes' - total size of item names in domain, in bytes
|
|
|
|
# * 'RequestId'
|
|
|
|
# * 'Timestamp' - last update time for metadata.
|
|
|
|
def domain_metadata(domain_name)
|
2010-03-16 00:58:57 -04:00
|
|
|
request(
|
|
|
|
'Action' => 'DomainMetadata',
|
|
|
|
'DomainName' => domain_name,
|
2011-01-03 21:55:24 -05:00
|
|
|
:idempotent => true,
|
2010-03-16 00:58:57 -04:00
|
|
|
:parser => Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string)
|
|
|
|
)
|
2009-09-08 22:57:53 -04:00
|
|
|
end
|
|
|
|
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
|
2010-03-14 23:11:43 -04:00
|
|
|
class Mock
|
2009-09-08 22:57:53 -04:00
|
|
|
|
|
|
|
def domain_metadata(domain_name)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2010-03-14 23:11:43 -04:00
|
|
|
if domain = @data[:domains][domain_name]
|
2009-09-08 22:57:53 -04:00
|
|
|
response.status = 200
|
2010-03-14 23:11:43 -04:00
|
|
|
|
2009-09-08 22:57:53 -04:00
|
|
|
attribute_names = []
|
|
|
|
attribute_values = []
|
|
|
|
for item in domain.values
|
|
|
|
for key, values in item
|
|
|
|
attribute_names << key
|
|
|
|
for value in values
|
|
|
|
attribute_values << value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2010-03-14 23:11:43 -04:00
|
|
|
|
2009-09-08 22:57:53 -04:00
|
|
|
response.body = {
|
|
|
|
'AttributeNameCount' => attribute_names.length,
|
|
|
|
'AttributeNamesSizeBytes' => attribute_names.join('').length,
|
|
|
|
'AttributeValueCount' => attribute_values.length,
|
|
|
|
'AttributeValuesSizeBytes' => attribute_values.join('').length,
|
|
|
|
'BoxUsage' => Fog::AWS::Mock.box_usage,
|
|
|
|
'ItemCount' => domain.keys.length,
|
|
|
|
'ItemNamesSizeBytes' => domain.keys.join('').length,
|
|
|
|
'RequestId' => Fog::AWS::Mock.request_id,
|
|
|
|
'Timestamp' => Time.now
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response.status = 400
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 200}, response))
|
2009-09-08 22:57:53 -04:00
|
|
|
end
|
|
|
|
response
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 22:14:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|