1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[simpledb] simplify request method signature

This commit is contained in:
geemus (Wesley Beary) 2010-03-15 21:58:57 -07:00
parent 293811ad42
commit 3ffa8b153a
10 changed files with 51 additions and 33 deletions

View file

@ -22,9 +22,10 @@ module Fog
# * 'RequestId'
def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([]))
request({
'Action' => 'BatchPutAttributes',
'DomainName' => domain_name
}.merge!(encode_batch_attributes(items, replace_attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
'Action' => 'BatchPutAttributes',
'DomainName' => domain_name,
:parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string)
}.merge!(encode_batch_attributes(items, replace_attributes)))
end
end

View file

@ -15,10 +15,11 @@ module Fog
# * 'BoxUsage'
# * 'RequestId'
def create_domain(domain_name)
request({
'Action' => 'CreateDomain',
'DomainName' => domain_name
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
request(
'Action' => 'CreateDomain',
'DomainName' => domain_name,
:parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string)
)
end
end

View file

@ -24,10 +24,11 @@ module Fog
# * 'RequestId'
def delete_attributes(domain_name, item_name, attributes = nil)
request({
'Action' => 'DeleteAttributes',
'DomainName' => domain_name,
'ItemName' => item_name
}.merge!(encode_attributes(attributes)), Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
'Action' => 'DeleteAttributes',
'DomainName' => domain_name,
'ItemName' => item_name,
:parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string)
}.merge!(encode_attributes(attributes)))
end
end

View file

@ -15,10 +15,11 @@ module Fog
# * 'BoxUsage'
# * 'RequestId'
def delete_domain(domain_name)
request({
'Action' => 'DeleteDomain',
'DomainName' => domain_name
}, Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string))
request(
'Action' => 'DeleteDomain',
'DomainName' => domain_name,
:parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string)
)
end
end

View file

@ -24,10 +24,11 @@ module Fog
# * 'RequestId'
# * 'Timestamp' - last update time for metadata.
def domain_metadata(domain_name)
request({
'Action' => 'DomainMetadata',
'DomainName' => domain_name
}, Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string))
request(
'Action' => 'DomainMetadata',
'DomainName' => domain_name,
:parser => Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string)
)
end
end

View file

@ -28,10 +28,11 @@ module Fog
def get_attributes(domain_name, item_name, attributes = {})
request({
'Action' => 'GetAttributes',
'DomainName' => domain_name,
'ItemName' => item_name,
}.merge!(encode_attribute_names(attributes)), Fog::Parsers::AWS::SimpleDB::GetAttributes.new(@nil_string))
'Action' => 'GetAttributes',
'DomainName' => domain_name,
'ItemName' => item_name,
:parser => Fog::Parsers::AWS::SimpleDB::GetAttributes.new(@nil_string)
}.merge!(encode_attribute_names(attributes)))
end
end

View file

@ -22,8 +22,9 @@ module Fog
# * 'RequestId'
def list_domains(options = {})
request({
'Action' => 'ListDomains'
}.merge!(options), Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string))
'Action' => 'ListDomains',
:parser => Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string)
}.merge!(options))
end
end

View file

@ -22,7 +22,11 @@ module Fog
# * 'BoxUsage'
# * 'RequestId'
def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
batch_put_attributes(domain_name, { item_name => attributes }, { item_name => replace_attributes })
batch_put_attributes(
domain_name,
{ item_name => attributes },
{ item_name => replace_attributes }
)
end
end
@ -30,7 +34,11 @@ module Fog
class Mock
def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
batch_put_attributes(domain_name, { item_name => attributes }, { item_name => replace_attributes })
batch_put_attributes(
domain_name,
{ item_name => attributes },
{ item_name => replace_attributes }
)
end
end

View file

@ -20,11 +20,12 @@ module Fog
# { 'item_name' => { 'attribute_name' => ['attribute_value'] }}
# * 'NextToken'<~String> - offset to start with if there are are more domains to list
def select(select_expression, next_token = nil)
request({
'Action' => 'Select',
'NextToken' => next_token,
'SelectExpression' => select_expression
}, Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string))
request(
'Action' => 'Select',
'NextToken' => next_token,
'SelectExpression' => select_expression,
:parser => Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string)
)
end
end

View file

@ -108,8 +108,10 @@ module Fog
encoded_attributes
end
def request(params, parser)
def request(params)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
parser = params.delete(:parser)
params.merge!({
'AWSAccessKeyId' => @aws_access_key_id,
'SignatureMethod' => 'HmacSHA256',