本文整理汇总了PHP中Aws\DynamoDb\DynamoDbClient::updateTable方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamoDbClient::updateTable方法的具体用法?PHP DynamoDbClient::updateTable怎么用?PHP DynamoDbClient::updateTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\DynamoDb\DynamoDbClient
的用法示例。
在下文中一共展示了DynamoDbClient::updateTable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->dynamoDbClient = $this->getContainer()->get('queue.dynamodb_client');
$this->tableName = $this->getContainer()->getParameter('container_stats_dynamodb.table_name');
$tableName = $this->tableName;
$updateTableJson = <<<JSON
{
"TableName": "{$tableName}",
"GlobalSecondaryIndexUpdates": [
{
"Create": {
"IndexName": "sapiProjectId-sapiCreatedTime-index",
"KeySchema": [
{
"AttributeName": "sapiProjectId",
"KeyType": "HASH"
},
{
"AttributeName": "sapiCreatedTime",
"KeyType": "RANGE"
}
],
"Projection": {
"ProjectionType": "ALL"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 3,
"WriteCapacityUnits": 7
}
}
}
],
"AttributeDefinitions": [
{
"AttributeName": "sapiCreatedTime",
"AttributeType": "S"
},
{
"AttributeName": "sapiProjectId",
"AttributeType": "S"
}
]
}
JSON;
$updateTableArgs = \json_decode($updateTableJson, true);
try {
$this->dynamoDbClient->updateTable($updateTableArgs);
echo 'Index has been created' . "\n";
} catch (DynamoDbException $e) {
if (strpos($e->getMessage(), 'Attempting to create an index which already exists') !== false) {
echo 'Index already exists' . "\n";
} else {
throw $e;
}
}
}
示例2: updateTable
/**
* Executes the UpdateTable operation.
*
* @param string $tableName The name of the table to be updated.
* @param array $provisionedThroughput Represents the provisioned throughput settings for a specified table or index.
* @param array $globalSecondaryIndexes An array of one or more global secondary indexes on the table, together with provisioned throughput settings for each index.
*
* @return Guzzle\Service\Resource\Model
*
* @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_updateTable
*/
public function updateTable($tableName, array $provisionedThroughput = null, array $globalSecondaryIndexes = null)
{
$args = ['TableName' => $tableName];
if ($provisionedThroughput !== null) {
$args['ProvisionedThroughput'] = $provisionedThroughput;
}
if ($globalSecondaryIndexes !== null) {
$args['GlobalSecondaryIndexes'] = $globalSecondaryIndexes;
}
return $this->client->updateTable($args);
}
示例3: updateTable
/**
* Update table via the update_table call
* @param string $table The name of the table
* @param Table\ProvisionedThroughput $provisionedThroughput
* @return Table\TableDescription
*/
public function updateTable($table, Table\ProvisionedThroughput $provisionedThroughput)
{
if (null !== $this->logger) {
$this->log('Update table ' . $table);
}
$parameters = array('TableName' => $table, 'ProvisionedThroughput' => $provisionedThroughput->getForDynamoDB());
if (null !== $this->logger) {
$this->log('UpdateTable request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
}
$response = $this->connector->updateTable($parameters);
if (null !== $this->logger) {
$this->log('UpdateTable request response : ' . print_r($response, true), Logger::DEBUG);
}
}
示例4: testUpdatesTable
/**
* @depends testCreatesTable
*/
public function testUpdatesTable()
{
self::log('Updating table');
// Need to wait until the table is active
$this->client->waitUntil('TableExists', $this->table, array('status' => 'active'));
$this->client->updateTable(array('TableName' => $this->table, 'ProvisionedThroughput' => array('ReadCapacityUnits' => 20, 'WriteCapacityUnits' => 20)));
// Wait until the table is active
self::log('Waiting for the table to become active after updating');
$this->client->waitUntil('table_exists', $this->table, array('status' => 'ACTIVE'));
// Ensure the table is updated
$result = $this->client->describeTable(array('TableName' => $this->table));
// Ensure that the updates took effect
$this->assertEquals(20, $result['Table']['ProvisionedThroughput']['ReadCapacityUnits']);
$this->assertEquals(20, $result['Table']['ProvisionedThroughput']['WriteCapacityUnits']);
}
示例5: setThroughput
public function setThroughput($read, $write, $indexName = self::PRIMARY_INDEX)
{
$requestArgs = ["TableName" => $this->tableName];
$updateObject = ['ReadCapacityUnits' => $read, 'WriteCapacityUnits' => $write];
if ($indexName == self::PRIMARY_INDEX) {
$requestArgs['ProvisionedThroughput'] = $updateObject;
} else {
$requestArgs['GlobalSecondaryIndexUpdates'] = [['Update' => ['IndexName' => $indexName, 'ProvisionedThroughput' => $updateObject]]];
}
try {
$this->dbClient->updateTable($requestArgs);
} catch (DynamoDbException $e) {
if ($e->getAwsErrorCode() == "ValidationException" && $e->getAwsErrorType() == "client" && !$e->isConnectionError()) {
mwarning("Throughput not updated, because new value is identical to old value!");
} else {
throw $e;
}
}
}