SimpleDB::Client - The network interface to the SimpleDB service.
version 1.0500
use SimpleDB::Client; my $sdb = SimpleDB::Client->new(secret_key=>'abc', access_key=>'123'); # create a domain my $hashref = $sdb->send_request('CreateDomain', {DomainName => 'my_things'}); # insert attributes my $hashref = $sdb->send_request('PutAttributes', { DomainName => 'my_things', ItemName => 'car', 'Attribute.1.Name' => 'color', 'Attribute.1.Value' => 'red', 'Attribute.1.Replace' => 'true', }); # get attributes my $hashref = $sdb->send_request('GetAttributes', { DomainName => 'my_things', ItemName => 'car', }); # search attributes my $hashref = $sdb->send_request('Select', { SelectExpression => q{select * from my_things where color = 'red'}, });
This class will let you quickly and easily inteface with AWS SimpleDB. It throws exceptions from SimpleDB::Client::Exception. It's very light weight. Although we haven't run any benchmarks on the other modules, it should outperform any of the other Perl modules that exist today.
The following methods are available from this class.
A hash containing the parameters to pass in to this method.
The access key given to you from Amazon when you sign up for the SimpleDB service at this URL: http://aws.amazon.com/simpledb/
The secret access key given to you from Amazon.
The constructor that SimpleDB::Client will connect to. Defaults to:
URI->new('https://sdb.amazonaws.com/')
Returns the access key passed to the constructor.
Returns the secret key passed to the constructor.
Returns the URI object passed into the constructor that SimpleDB::Client will connect to. Defaults to:
Returns the LWP::UserAgent object that is used to connect to SimpleDB. It's cached here so it doesn't have to be created each time.
Returns a string that contains the HTTP post data ready to make a request to SimpleDB. Normally this is only called by send_request(), but if you want to debug a SimpleDB interaction, then having access to this method is critical.
The action to perform on SimpleDB. See the "Operations" section of the guide located at http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/.
Any extra prameters required by the operation. The normal parameters of Action, AWSAccessKeyId, Version, Timestamp, SignatureMethod, SignatureVersion, and Signature are all automatically provided by this method.
Creates a request, and then sends it to SimpleDB. The response is returned as a hash reference of the raw XML document returned by SimpleDB. Automatically attempts 5 cascading retries on connection failure.
Throws SimpleDB::Client::Exception::Response and SimpleDB::Client::Exception::Connection.
See create_request() for details.
Returns a hashref containing the response from SimpleDB.
Throws SimpleDB::Client::Exception::Response.
The HTTP::Response object created by the send_request method.
send_request
This package requires the following modules:
XML::Fast LWP Time::HiRes Crypt::SSLeay Moose Digest::SHA URI Exception::Class
http://github.com/rizen/SimpleDB-Client
http://rt.cpan.org/Public/Dist/Display.html?Name=SimpleDB-Client
There are other packages you can use to access SimpleDB. I chose not to use them because I wanted something a bit more lightweight that I could build SimpleDB::Class on top of so I could easily map objects to SimpleDB Domain Items. If you're looking for a low level SimpleDB accessor and for some reason this module doesn't cut the mustard, then you should check out these:
A complete and nicely functional low level library made by Amazon itself.
A low level SimpleDB accessor that's in its infancy and may be abandoned, but appears to be pretty functional, and of the same scope as Amazon's own module.
In addition to clients, there is at least one other API compatible server out there that basically lets you host your own SimpleDB if you don't want to put it in Amazon's cloud. It's called M/DB. You can read more about it here: http://gradvs1.mgateway.com/main/index.html?path=mdb. Though I haven't tested it, since it's API compatible, you should be able to use it with both this module and SimpleDB::Class.
JT Smith <jt_at_plainblack_com>
I have to give credit where credit is due: SimpleDB::Client is heavily inspired by the Amazon::SimpleDB class distributed by Amazon itself (not to be confused with Amazon::SimpleDB written by Timothy Appnel).
SimpleDB::Client is Copyright 2009-2010 Plain Black Corporation (http://www.plainblack.com/) and is licensed under the same terms as Perl itself.
To install SimpleDB::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SimpleDB::Client
CPAN shell
perl -MCPAN -e shell install SimpleDB::Client
For more information on module installation, please visit the detailed CPAN module installation guide.