Skip to content

hungryblank/aws_sdb_bare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws_sdb_bare

AwsSdb Bare is a ruby gem intended to provide a basic modular interface to use the SimpleDB service provided by Amazon.

Concept

The aim of the project is to not commit to any http handling strategy and to not enforce any response parsing solution by default.

The idea behind this project is to provide a basic layer on top of which more high level libraries can be built.

The library provides XML response parsing through Hpricot or Nokogiri to run the test against a specific parser

rake nokogiri test

Or

rake hpricot test

Project sources

the project is hosted on github github.com/hungryblank/aws_sdb_bare

blog posts explaining the usage can be found on assertbuggy.blogspot.com

Support and bug tracking

issues can be posted on github github.com/hungryblank/aws_sdb_bare forking and patch proposal throguh github are encouraged

Installation

sudo gem install hungryblank-aws_sdb_bare -s http://gems.github.com

Usage - Requests

The most basic primitive is the request, as a sample here’s how a ListDomains request is generated

require 'rubygems'
require 'aws_sdb_bare'

ENV['AMAZON_ACCESS_KEY_ID'] = 'your_amazon_access_key'
ENV['AMAZON_SECRET_ACCESS_KEY'] = 'your_amazon_secret'

#create the request object
request = AwsSdb::Request::Base.new('GET', 'Action' => 'ListDomains')

#using curl we can send the request as http get and print out the xml
#response with the domains under your account
puts `curl #{request.uri}`

The gem provides classes to create directly all the requests listed in Amazon’s 2007 11 07 specs so you can do

request = AwsSdb::Request::ListDomains.new

Instead of using the Base class like the previous example.

Please refer to the gem rdocs and to the amazon documentation to see a list of all the available requests and their parameters

Usage - Responses

To parse a response you simply call AwsSdb::Response.parse(xml_doc) example:

require 'open-uri'
require 'aws_sdb_bare'
#the following line could require nokogiri instead
require 'hpricot'

request = AwsSdb::Request::ListDomains.new
xml_response = open request.uri
response = AwsSdb::Response.parse(xml_response)
puts response.domains
puts response.metadata.box_usage

Contributors

* Michael Gorsuch

Copyright © 2009 Paolo Negri. See LICENSE for details.