NAME

Amazon::DynamoDB::20120810

VERSION

version 0.35

DESCRIPTION

new

Instantiates the API object.

Expects the following named parameters:

  • implementation - the object which provides a Future-returning request method, see Amazon::DynamoDB::NaHTTP for example.

  • host - the host (IP or hostname) to communicate with

  • port - the port to use for HTTP(S) requests

  • ssl - true for HTTPS, false for HTTP

  • algorithm - which signing algorithm to use, default AWS4-HMAC-SHA256

  • scope - the scope for requests, typically region/host/aws4_request

  • access_key - the access key for signing requests

  • secret_key - the secret key for signing requests

  • debug_failures - print errors if they occur

  • max_retries - maximum number of retries for a request

create_table

Creates a new table. It may take some time before the table is marked as active - use "wait_for_table_status" to poll until the status changes.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html

  $ddb->create_table(
     TableName => $table_name,
     ReadCapacityUnits => 2,
     WriteCapacityUnits => 2,
     AttributeDefinitions => {
         user_id => 'N',
         date => 'N',
     },
     KeySchema => ['user_id', 'date'],
     LocalSecondaryIndexes => [
         {
             IndexName => 'UserDateIndex',
             KeySchema => ['user_id', 'date'],
             Projection => {
                 ProjectionType => 'KEYS_ONLY',
             },
             ProvisionedThroughput => {
                 ReadCapacityUnits => 2,
                 WriteCapacityUnits => 2,
             }
         }
     ]
  );

describe_table

Describes the given table.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html

  $ddb->describe_table(TableName => $table_name);

delete_table

Delete a table.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteTable.html

  $ddb->delete_table(TableName => $table_name)

wait_for_table_status

Waits for the given table to be marked as active.

  • TableName - the table name

  • WaitInterval - default wait interval in seconds.

  • DesiredStatus - status to expect before completing. Defaults to ACTIVE

  $ddb->wait_for_table_status(TableName => $table_name);

each_table

Run code for all current tables.

Takes a coderef as the first parameter, will call this for each table found.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html

  my @all_tables;    
  $ddb->each_table(
        sub {
            my $table_name =shift;
            push @all_tables, $table_name;
        });

put_item

Writes a single item to the table.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html

  $ddb->put_item(
     TableName => $table_name,
     Item => {
       name => 'Test Name'
     },
     ReturnValues => 'ALL_OLD');

update_item

Updates a single item in the table.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateItem.html

  $ddb->update_item(
        TableName => $table_name,
        Key => {
            user_id => 2
        },
        AttributeUpdates => {
            name => {
                Action => 'PUT',
                Value => "Rusty Conover-3",
            },
            favorite_color => {
                Action => 'DELETE'
            },
            test_numbers => {
                Action => 'DELETE',
                Value => [500]
            },
            added_number => {
                Action => 'ADD',
                Value => 5,
            },
            subtracted_number => {
                Action => 'ADD',
                Value => -5,
            },
        });

delete_item

Deletes a single item from the table.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DeleteItem.html

  $ddb->delete_item(
    TableName => $table_name,
    Key => {
      user_id => 5
  });

get_item

Retrieve an items from one tables.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html

  my $found_item;
  my $get = $ddb->get_item(
    sub {
      $found_item = shift;
    },
    TableName => $table_name,
    Key => {
      user_id => 6
    });

batch_write_item

Put or delete a collection of items.

Has no restriction on the number of items able to be processed at one time.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html

  $ddb->batch_write_item(
    RequestItems => {
       books => [
            {
                DeleteRequest => {
                    book_id => 3000,
                }
            },
       ],
       users => [
            {
                PutRequest => {
                    user_id => 3000,
                    name => "Test batch write",
                }
            },
            {
                PutRequest => {
                    user_id => 3001,
                    name => "Test batch write",
                }
            }
        ]
    });

batch_get_item

Retrieve a batch of items from one or more tables.

Takes a coderef which will be called for each found item.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html

Additional Parameters:

  • ResultLimit - limit on the total number of results to return.

  $ddb->batch_get_item(
    sub {
        my ($table, $item) = @_;
    },
    RequestItems => {
        $table_name => {
            ConsistentRead => 'true',
            AttributesToGet => ['user_id', 'name'],
            Keys => [
                {
                    user_id => 1,
                },
            ],
        }
    })

scan

Scan a table for values with an optional filter expression.

Amazon Documentation:

http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html

Additional parameters:

  $ddb->scan(
    sub {
      my $item = shift;
      push @found_items, $item;
    },
    TableName => $table_name,
    ScanFilter => {
      user_id => {
        ComparisonOperator => 'NOT_NULL',
      }
    });

NAME

Amazon::DynamoDB::20120810 - interact with DynamoDB using API version 20120810

METHODS - Internal

The following methods are intended for internal use and are documented purely for completeness - for normal operations see "METHODS" instead.

make_request

Generates an HTTP::Request.

FUNCTIONS - Internal

_encode_type_and_value

Returns an appropriate type (N, S, SS etc.) and stringified/encoded value for the given value.

DynamoDB only uses strings even if there is a Numeric value specified, so while the type will be expressed as a Number the value will be stringified.

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html

AUTHORS

  • Rusty Conover <rusty@luckydinosaur.com>

  • Tom Molesworth <cpan@entitymodel.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Tom Molesworth, copyright (c) 2014 Lucky Dinosaur LLC. http://www.luckydinosaur.com.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 1096:

=back without =over

Around line 1312:

=back without =over