Method: Aws::SdbInterface#get_attributes

Defined in:
lib/sdb/sdb_interface.rb

#get_attributes(domain_name, item_name, attribute_name = nil, consistent_read = nil) ⇒ Object

Retrieve SDB item’s attribute(s).

Returns a hash:

{ :box_usage  => string,
  :request_id => string,
  :attributes => { 'nameA' => [valueA1,..., valueAN],
                   ... ,
                   'nameZ' => [valueZ1,..., valueZN] } }

Example:

# request all attributes
sdb.get_attributes('family', 'toys') # => { :attributes => {"cat"    => ["clew", "Jons_socks", "mouse"] },
                                                            "Silvia" => ["beetle", "rolling_pin", "kids"],
                                                            "Jon"    => ["vacuum_cleaner", "hammer", "spade"]},
                                            :box_usage  => "0.0000093222",
                                            :request_id => "81273d21-000-1111-b3f9-512d91d29ac8" }

# request cat's attributes only
sdb.get_attributes('family', 'toys', 'cat') # => { :attributes => {"cat" => ["clew", "Jons_socks", "mouse"] },
                                                   :box_usage  => "0.0000093222",
                                                   :request_id => "81273d21-001-1111-b3f9-512d91d29ac8" }

see: docs.amazonwebservices.com/AmazonSimpleDB/2007-11-07/DeveloperGuide/SDB_API_GetAttributes.html



466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/sdb/sdb_interface.rb', line 466

def get_attributes(domain_name, item_name, attribute_name=nil, consistent_read = nil)
  link = generate_request("GetAttributes", 'DomainName' => domain_name,
                          'ItemName'                    => item_name,
                          'AttributeName'               => attribute_name,
                          'ConsistentRead'              => consistent_read)
  res  = request_info(link, QSdbGetAttributesParser.new)
  res[:attributes].each_value do |values|
    values.collect! { |e| sdb_to_ruby(e) }
  end
  res
rescue Exception
  on_exception
end