list_tables ( $opt )

Retrieves a paginated list of table names created by the AWS Account of the caller in the AWS Region (e.g. us-east-1).

Access

public

Parameters

Parameter

Type

Required

Description

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • ExclusiveStartTableName - string - Optional - The name of the table that starts the list. If you already ran a ListTables operation and received a LastEvaluatedTableName value in the response, use that value here to continue the list. [Constraints: The value must be between 3 and 255 characters, and must match the following regular expression pattern: [a-zA-Z0-9_.-]+]
  • Limit - integer - Optional - A number of maximum table names to return.
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create a new table with a Hash Key.

// Instantiate the class
$dynamodb = new AmazonDynamoDB();

$table_name = 'my-table' . time();

####################################################################
# Create a new DynamoDB table

$response = $dynamodb->create_table(array(
	'TableName' => $table_name,
	'KeySchema' => array(
		'HashKeyElement' => array(
			'AttributeName' => 'ID',
			'AttributeType' => AmazonDynamoDB::TYPE_NUMBER
		),
		'RangeKeyElement' => array(
			'AttributeName' => 'Date',
			'AttributeType' => AmazonDynamoDB::TYPE_NUMBER
		)
	),
	'ProvisionedThroughput' => array(
		'ReadCapacityUnits' => 50,
		'WriteCapacityUnits' => 50
	)
));

// Check for success...
if ($response->isOK())
{
	echo '# Kicked off the creation of the DynamoDB table...' . PHP_EOL;
}
else
{
	print_r($response);
}

####################################################################
# Sleep and poll until the table has been created

$count = 0;
do {
	sleep(1);
	$count++;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');

echo "The table \"${table_name}\" has been created (slept ${count} seconds)." . PHP_EOL;

####################################################################
# Collect all table names in the account

echo PHP_EOL . PHP_EOL;
echo '# Collecting a complete list of tables in the account...' . PHP_EOL;

$response = $dynamodb->list_tables();
print_r($response->body->TableNames->to_array()->getArrayCopy());

####################################################################
# Describe a specific table

echo PHP_EOL . PHP_EOL;
echo "# Describing the \"${table_name}\" table..." . PHP_EOL;

$response = $dynamodb->describe_table(array(
	'TableName' => $table_name
));

print_r($response->body);

####################################################################
# Updating the table

echo PHP_EOL . PHP_EOL;
echo "# Updating the \"${table_name}\" table..." . PHP_EOL;

$dynamodb->update_table(array(
	'TableName' => $table_name,
	'ProvisionedThroughput' => array(
		'ReadCapacityUnits' => 400,
		'WriteCapacityUnits' => 400
	)
));

$table_status = $dynamodb->describe_table(array(
	'TableName' => $table_name
));

// Check for success...
if ($table_status->isOK())
{
	print_r($table_status->body->Table->ProvisionedThroughput->to_array()->getArrayCopy());
}
else
{
	print_r($table_status);
}

####################################################################
# Sleep and poll until the table has been updated.

$count = 0;
do {
	sleep(5);
	$count += 5;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((string) $response->body->Table->TableStatus !== 'ACTIVE');

echo "The table \"${table_name}\" has been updated (slept ${count} seconds)." . PHP_EOL;

####################################################################
# Deleting the table

echo PHP_EOL . PHP_EOL;
echo "# Deleting the \"${table_name}\" table..." . PHP_EOL;

$response = $dynamodb->delete_table(array(
	'TableName' => $table_name
));

// Check for success...
if ($response->isOK())
{
	echo 'The table is in the process of deleting...' . PHP_EOL;
}
else
{
	print_r($response);
}

####################################################################
# Sleep and poll until the table has been deleted.

$count = 0;
do {
	sleep(1);
	$count++;

	$response = $dynamodb->describe_table(array(
		'TableName' => $table_name
	));
}
while ((integer) $response->status !== 400);

echo "The table \"${table_name}\" has been deleted (slept ${count} seconds)." . PHP_EOL;

Source

Method defined in services/dynamodb.class.php | Toggle source view (6 lines) | View on GitHub

public function list_tables($opt = null)
{
    if (!$opt) $opt = array();
    
    return $this->authenticate('ListTables', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback