Amazon::SimpleDB::Domain - a class representing a domain in SimpleDB


Amazon-SimpleDB documentation Contained in the Amazon-SimpleDB distribution.

Index


Code Index:

NAME

Top

Amazon::SimpleDB::Domain - a class representing a domain in SimpleDB

DESCRIPTION

Top

This is code is in the early stages of development. Do not consider it stable. Feedback and patches welcome.

METHODS

Top

Amazon::SimpleDB::Domain->new($args)

Constructor for a domain. Takes a required HASHREF with two required keys:

account

An Amazon::SimpleDB account object the item is to be associated.

name

The name of the domain for the constructed object.

Typically this method will not be called directly by a developer, but rather other parts of the Amazon::SimpleDB package.

This method does not check if an domain exists and is accessible.

$domain->account

Returns a reference to the Amazon::SimpleDB account object.

$domain->name

Returns the domain name of the object.

$domain->delete

Deletes the domain from SimpleDB that this object represents.

This is an alias $domain-account->delete_bucket($domain->name)>.

$domain->query([$args])

Queries the item in the domain and returns matching items according to the optional arguments HASHREF. If nothing is passed in all items in the domain are returned.

The arguments HASHREF can have these three keys:

query

A SimpleDB query expression string.

limit

A number between 1 and 250 that defines the maximum number of items to return in a single request. The SimpleDB default is 100.

next

A "next token" from a previous request that can be used to retrieve more items when the results of a query exceeds the limit.

SEE ALSO

Top

Amazon::SimpleDB, Amazon::SimpleDB::ListDomainsResponse

AUTHOR & COPYRIGHT

Top


Amazon-SimpleDB documentation Contained in the Amazon-SimpleDB distribution.

package Amazon::SimpleDB::Domain;
use strict;
use warnings;

use Amazon::SimpleDB::Response;
use Carp qw( croak );

sub new {
    my $class = shift;
    my $args  = shift || {};
    my $self  = bless $args, $class;
    croak "No account"       unless $self->{account};
    croak "No (domain) name" unless $self->{name};
    return $self;
}

sub account { return $_[0]->{account} }
sub name    { return $_[0]->{name} }
sub delete  { return $_[0]->{account}->delete_domain($_[0]->{name}) }

# note: limit can be between 1 and 250. default is 100.
# note: cannot run longer then 5 seconds or times out.
sub query {
    my $self   = shift;
    my $args   = shift || {};
    my $params = {DomainName => $self->{'name'}};
    $params->{MaxNumberOfItems} = $args->{'limit'} if $args->{'limit'};
    $params->{NextToken}        = $args->{'next'}  if $args->{'next'};
    $params->{QueryExpression}  = $args->{'query'} if $args->{'query'};
    my $account = $self->{account};
    return
      Amazon::SimpleDB::Response->new(
                           http_response => $account->request('Query', $params),
                           domain        => $self,
                           account       => $self->{account},
      );
}

1;

__END__