File Coverage

lib/Amazon/DynamoDB.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Amazon::DynamoDB;
2             $Amazon::DynamoDB::VERSION = '0.33';
3             # ABSTRACT: API support for Amazon DynamoDB
4 9     9   511753 use strict;
  9         16  
  9         256  
5 9     9   34 use warnings;
  9         10  
  9         212  
6              
7              
8 9     9   3500 use Amazon::DynamoDB::20120810;
  0            
  0            
9             use Module::Load;
10              
11              
12             sub new {
13             my $class = shift;
14             my %args = @_;
15             $args{implementation} //= __PACKAGE__ . '::LWP';
16             unless (ref $args{implementation}) {
17             Module::Load::load($args{implementation});
18             $args{implementation} = $args{implementation}->new(%args);
19             }
20             my $version = delete $args{version} || '20120810';
21             my $pkg = __PACKAGE__ . '::' . $version;
22             if (my $code = $pkg->can('new')) {
23             $class = $pkg if $class eq __PACKAGE__;
24             return $code->($class, %args)
25             }
26             die "No support for version $version";
27             }
28              
29             1;
30              
31             __END__
32              
33             =pod
34              
35             =encoding UTF-8
36              
37             =head1 NAME
38              
39             Amazon::DynamoDB - API support for Amazon DynamoDB
40              
41             =head1 VERSION
42              
43             version 0.33
44              
45             =head1 SYNOPSIS
46              
47             my $ddb = Amazon::DynamoDB->new(
48             implementation => 'Amazon::DynamoDB::LWP',
49             version => '20120810',
50              
51             access_key => 'access_key',
52             secret_key => 'secret_key',
53             # or you specify to use an IAM role
54             use_iam_role => 1,
55              
56             host => 'dynamodb.us-east-1.amazonaws.com',
57             scope => 'us-east-1/dynamodb/aws4_request',
58             ssl => 1,
59             debug => 1);
60              
61             $ddb->batch_get_item(
62             sub {
63             my $tbl = shift;
64             my $data = shift;
65             print "Batch get: $tbl had " . join(',', %$data) . "\n";
66             },
67             RequestItems => {
68             $table_name => {
69             Keys => [
70             {
71             name => 'some test name here',
72             }
73             ],
74             AttributesToGet => [qw(name age)],
75             }
76             })->get;
77              
78             =head1 DESCRIPTION
79              
80             Provides a L<Future>-based API for Amazon's DynamoDB REST API.
81             See L<Amazon::DynamoDB::20120810> for available methods.
82              
83             Current implementations for issuing the HTTP requests:
84              
85             =over 4
86              
87             =item * L<Amazon::DynamoDB::NaHTTP> - use L<Net::Async::HTTP>
88             for applications based on L<IO::Async> (this gives nonblocking behaviour)
89              
90             =item * L<Amazon::DynamoDB::LWP> - use L<LWP::UserAgent> (will
91             block, timeouts are unlikely to work)
92              
93             =item * L<Amazon::DynamoDB::MojoUA> - use L<Mojo::UserAgent>,
94             should be suitable for integration into a L<Mojolicious> application. (not well tested)
95              
96             =back
97              
98             =head1 NAME
99              
100             Amazon::DynamoDB - support for the AWS DynamoDB API
101              
102             =head1 METHODS
103              
104             =head1 SEE ALSO
105              
106             =over 4
107              
108             =item * L<Net::Amazon::DynamoDB> - supports the older (2011) API with v2 signing, so it doesn't work with L<DynamoDB Local|http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.html>.
109              
110             =item * L<AWS::CLIWrapper> - alternative approach using wrappers around AWS commandline tools
111              
112             =item * L<WebService::Amazon::DynamoDB> - this module was based off of this initial code.
113              
114             =back
115              
116             =head1 IMPLEMENTATION PHILOSOPHY
117              
118             This module attempts to stick as close to Amazon's API as possible
119             while making some inconvenient limits easy to work with.
120              
121             Parameters are named the same, return values are as described.
122             Documentation for each method is commonly found at:
123              
124             L<http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Operations.html>
125              
126             For examples see the test cases, most functionality is well exercised
127             via tests.
128              
129             =head1 AUTHORS
130              
131             =over 4
132              
133             =item *
134              
135             Rusty Conover <rusty@luckydinosaur.com>
136              
137             =item *
138              
139             Tom Molesworth <cpan@entitymodel.com>
140              
141             =back
142              
143             =head1 COPYRIGHT AND LICENSE
144              
145             This software is copyright (c) 2013 by Tom Molesworth, copyright (c) 2014 Lucky Dinosaur LLC. L<http://www.luckydinosaur.com>.
146              
147             This is free software; you can redistribute it and/or modify it under
148             the same terms as the Perl 5 programming language system itself.
149              
150             =cut