Class: Fog::AWS::SimpleDB::Real
- Inherits:
-
Object
- Object
- Fog::AWS::SimpleDB::Real
- Defined in:
- lib/fog/aws/simpledb.rb,
lib/fog/aws/requests/simpledb/select.rb,
lib/fog/aws/requests/simpledb/list_domains.rb,
lib/fog/aws/requests/simpledb/create_domain.rb,
lib/fog/aws/requests/simpledb/delete_domain.rb,
lib/fog/aws/requests/simpledb/get_attributes.rb,
lib/fog/aws/requests/simpledb/put_attributes.rb,
lib/fog/aws/requests/simpledb/domain_metadata.rb,
lib/fog/aws/requests/simpledb/delete_attributes.rb,
lib/fog/aws/requests/simpledb/batch_put_attributes.rb
Instance Method Summary collapse
-
#batch_put_attributes(domain_name, items, replace_attributes = Hash.new([])) ⇒ Object
Put items attributes into a SimpleDB domain.
-
#create_domain(domain_name) ⇒ Object
Create a SimpleDB domain.
-
#delete_attributes(domain_name, item_name, attributes = nil) ⇒ Object
List metadata for SimpleDB domain.
-
#delete_domain(domain_name) ⇒ Object
Delete a SimpleDB domain.
-
#domain_metadata(domain_name) ⇒ Object
List metadata for SimpleDB domain.
-
#get_attributes(domain_name, item_name, options = {}) ⇒ Object
List metadata for SimpleDB domain.
-
#initialize(options = {}) ⇒ Real
constructor
Initialize connection to SimpleDB.
-
#list_domains(options = {}) ⇒ Object
List SimpleDB domains.
-
#put_attributes(domain_name, item_name, attributes, options = {}) ⇒ Object
Put item attributes into a SimpleDB domain.
-
#select(select_expression, options = {}) ⇒ Object
Select item data from SimpleDB.
Constructor Details
#initialize(options = {}) ⇒ Real
Initialize connection to SimpleDB
Notes
options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection
Examples
sdb = SimpleDB.new(
:aws_access_key_id => your_aws_access_key_id,
:aws_secret_access_key => your_aws_secret_access_key
)
Parameters
-
options<~Hash> - config arguments for connection. Defaults to {}.
Returns
-
SimpleDB object with connection to aws.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fog/aws/simpledb.rb', line 68 def initialize(={}) require 'fog/core/parser' @aws_access_key_id = [:aws_access_key_id] @aws_secret_access_key = [:aws_secret_access_key] @aws_session_token = [:aws_session_token] @connection_options = [:connection_options] || {} @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key) @nil_string = [:nil_string]|| 'nil' [:region] ||= 'us-east-1' @host = [:host] || "sdb.#{[:region]}.amazonaws.com" @path = [:path] || '/' @persistent = [:persistent] || false @port = [:port] || 443 @scheme = [:scheme] || 'https' @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options) end |
Instance Method Details
#batch_put_attributes(domain_name, items, replace_attributes = Hash.new([])) ⇒ Object
Put items attributes into a 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 ‘.’.
-
items<~Hash> - Keys are the items names and may use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Can be up to 1024 bytes long. Values are the attributes to add to the given item and may use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Each name and value can be up to 1024 bytes long.
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’
-
‘RequestId’
-
-
23 24 25 26 27 28 29 |
# File 'lib/fog/aws/requests/simpledb/batch_put_attributes.rb', line 23 def batch_put_attributes(domain_name, items, replace_attributes = Hash.new([])) request({ 'Action' => 'BatchPutAttributes', 'DomainName' => domain_name, :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string) }.merge!(encode_batch_attributes(items, replace_attributes))) end |
#create_domain(domain_name) ⇒ Object
Create a 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
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’
-
‘RequestId’
-
-
17 18 19 20 21 22 23 24 |
# File 'lib/fog/aws/requests/simpledb/create_domain.rb', line 17 def create_domain(domain_name) request( 'Action' => 'CreateDomain', 'DomainName' => domain_name, :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string) ) end |
#delete_attributes(domain_name, item_name, attributes = nil) ⇒ Object
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 ‘.’.
-
item_name<~String> - Name of the item. May use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Can be up to 1024 bytes long.
-
attributes<~Hash> - Name/value pairs to remove from the item. Defaults to nil, which will delete the entire item. Attribute names and values may use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Each name and value can be up to 1024 bytes long.
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’
-
‘RequestId’
-
-
25 26 27 28 29 30 31 32 |
# File 'lib/fog/aws/requests/simpledb/delete_attributes.rb', line 25 def delete_attributes(domain_name, item_name, attributes = nil) request({ 'Action' => 'DeleteAttributes', 'DomainName' => domain_name, 'ItemName' => item_name, :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string) }.merge!(encode_attributes(attributes))) end |
#delete_domain(domain_name) ⇒ Object
Delete a 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
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’
-
‘RequestId’
-
-
17 18 19 20 21 22 23 24 |
# File 'lib/fog/aws/requests/simpledb/delete_domain.rb', line 17 def delete_domain(domain_name) request( 'Action' => 'DeleteDomain', 'DomainName' => domain_name, :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string) ) end |
#domain_metadata(domain_name) ⇒ Object
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
-
response<~Excon::Response>:
-
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.
-
-
26 27 28 29 30 31 32 33 |
# File 'lib/fog/aws/requests/simpledb/domain_metadata.rb', line 26 def (domain_name) request( 'Action' => 'DomainMetadata', 'DomainName' => domain_name, :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::DomainMetadata.new(@nil_string) ) end |
#get_attributes(domain_name, item_name, options = {}) ⇒ Object
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 ‘.’.
-
item_name<~String> - Name of the item. May use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Can be up to 1024 bytes long.
-
options<~Hash>:
-
AttributeName<~Array> - Attributes to return from the item. Defaults to {}, which will return all attributes. Attribute names and values may use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Each name and value can be up to 1024 bytes long.
-
ConsistentRead<~Boolean> - When set to true, ensures most recent data is returned. Defaults to false.
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘Attributes’ - list of attribute name/values for the item
-
‘BoxUsage’
-
‘RequestId’
-
-
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fog/aws/requests/simpledb/get_attributes.rb', line 30 def get_attributes(domain_name, item_name, = {}) if .is_a?(Array) Fog::Logger.deprecation("get_attributes with array attributes param is deprecated, use 'AttributeName' => attributes) instead [light_black](#{caller.first})[/]") = {'AttributeName' => } end ['AttributeName'] ||= [] request({ 'Action' => 'GetAttributes', 'ConsistentRead' => !!['ConsistentRead'], 'DomainName' => domain_name, 'ItemName' => item_name, :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::GetAttributes.new(@nil_string) }.merge!(encode_attribute_names(['AttributeName']))) end |
#list_domains(options = {}) ⇒ Object
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’
-
-
23 24 25 26 27 28 29 |
# File 'lib/fog/aws/requests/simpledb/list_domains.rb', line 23 def list_domains( = {}) request({ 'Action' => 'ListDomains', :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::ListDomains.new(@nil_string) }.merge!()) end |
#put_attributes(domain_name, item_name, attributes, options = {}) ⇒ Object
Put item attributes into a 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 ‘.’.
-
item_name<~String> - Name of the item. May use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Can be up to 1024 bytes long.
-
attributes<~Hash> - Name/value pairs to add to the item. Attribute names and values may use any UTF-8 characters valid in xml. Control characters and sequences not allowed in xml are not valid. Each name and value can be up to 1024 bytes long.
-
options<~Hash> - Accepts the following keys. :replace => [Array of keys to replace] :expect => pairs for performing conditional put
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’
-
‘RequestId’
-
-
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/aws/requests/simpledb/put_attributes.rb', line 27 def put_attributes(domain_name, item_name, attributes, = {}) [:expect] = {} unless [:expect] [:replace] = [] unless [:replace] request({ 'Action' => 'PutAttributes', 'DomainName' => domain_name, 'ItemName' => item_name, :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string) }.merge!(encode_attributes(attributes, [:replace], [:expect]))) end |
#select(select_expression, options = {}) ⇒ Object
Select item data from SimpleDB
Parameters
-
select_expression<~String> - Expression to query domain with.
-
options<~Hash>:
-
ConsistentRead<~Boolean> - When set to true, ensures most recent data is returned. Defaults to false.
-
NextToken<~String> - Offset token to start list, defaults to nil.
-
Returns
-
response<~Excon::Response>:
-
body<~Hash>:
-
‘BoxUsage’<~Float>
-
‘RequestId’<~String>
-
‘Items’<~Hash> - list of attribute name/values for the items formatted as { ‘item_name’ => { ‘attribute_name’ => [‘attribute_value’] }}
-
‘NextToken’<~String> - offset to start with if there are are more domains to list
-
-
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/aws/requests/simpledb/select.rb', line 24 def select(select_expression, = {}) if .is_a?(String) Fog::Logger.deprecation("get_attributes with string next_token param is deprecated, use 'AttributeName' => attributes) instead [light_black](#{caller.first})[/]") = {'NextToken' => } end ['NextToken'] ||= nil request( 'Action' => 'Select', 'ConsistentRead' => !!['ConsistentRead'], 'NextToken' => ['NextToken'], 'SelectExpression' => select_expression, :idempotent => true, :parser => Fog::Parsers::AWS::SimpleDB::Select.new(@nil_string) ) end |