Пример #1
0
 /**
  * Create the table
  */
 protected static function createTable($wait = false)
 {
     $tables = self::$dynamodb->listTables();
     if (in_array(self::TABLE_NAME, $tables['TableNames'])) {
         self::deleteTable(true);
     }
     self::$dynamodb->createTable(['TableName' => self::TABLE_NAME, 'AttributeDefinitions' => [['AttributeName' => 'key', 'AttributeType' => 'S']], 'KeySchema' => [['AttributeName' => 'key', 'KeyType' => 'HASH']], 'ProvisionedThroughput' => ['ReadCapacityUnits' => 1, 'WriteCapacityUnits' => 1]]);
     if (!$wait) {
         return;
     }
     self::$dynamodb->waitUntil('TableExists', ['TableName' => self::TABLE_NAME, 'waiter.interval' => 1, 'waiter.max_attempts' => 5]);
 }
Пример #2
0
 /**
  * List tables via the list_tables call
  * @param integer $limit
  * @param string $exclusiveStartTableName
  * @return Table\TableCollection
  */
 public function listTables($limit = null, $exclusiveStartTableName = null)
 {
     if (null !== $this->logger) {
         $this->log('List tables');
     }
     $parameters = array();
     if (null !== $limit) {
         $parameters['Limit'] = $limit;
     }
     if (null !== $exclusiveStartTableName) {
         $parameters['ExclusiveStartTableName'] = $exclusiveStartTableName;
     }
     if (null !== $this->logger) {
         $this->log('ListTable request paramaters : ' . print_r($parameters, true), Logger::DEBUG);
     }
     $response = $this->connector->listTables($parameters);
     if (null !== $this->logger) {
         $this->log('ListTable request response : ' . print_r($response, true), Logger::DEBUG);
     }
     $tables = new Table\TableCollection(isset($response['LastEvaluatedTableName']) ? $response['LastEvaluatedTableName'] : null);
     if (!empty($response['TableNames'])) {
         foreach ($response['TableNames'] as $table) {
             $tables->add($table);
         }
     }
     return $tables;
 }
Пример #3
0
 /**
  * @return array
  */
 public function getTables()
 {
     $out = [];
     do {
         $result = $this->dbConn->listTables(['Limit' => 100, 'ExclusiveStartTableName' => isset($result) ? $result['LastEvaluatedTableName'] : null]);
         $out = array_merge($out, $result['TableNames']);
     } while ($result['LastEvaluatedTableName']);
     return $out;
 }
Пример #4
0
 /**
  * Returns an array of all the tables associated with the current account and endpoint.
  *
  * @param string  $exclusiveStartTableName Name of the table that starts the list.
  * @param integer $limit                   A maximum number of tables to return.
  *
  * @return  Guzzle\Service\Resource\Model
  *
  * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.DynamoDb.DynamoDbClient.html#_listTables
  */
 public function listTables($exclusiveStartTableName = null, $limit = null)
 {
     $params = [];
     if (is_string($exclusiveStartTableName)) {
         $params['ExclusiveStartTableName'] = $exclusiveStartTableName;
     }
     if (is_numeric($limit)) {
         $params['Limit'] = $limit;
     }
     return $this->client->listTables($params);
 }
Пример #5
0
 /**
  * @depends testCreatesTable
  */
 public function testListsTables()
 {
     $result = $this->client->listTables();
     $this->assertContains($this->table, $result['TableNames']);
 }