/**
  * @param                 $tableName
  * @param DynamoDbIndex   $primaryIndex
  * @param DynamoDbIndex[] $localSecondaryIndices
  * @param DynamoDbIndex[] $globalSecondaryIndices
  * @param int             $readCapacity
  * @param int             $writeCapacity
  *
  * @return bool
  * @internal param DynamoDbIndex $primaryKey
  */
 public function createTable($tableName, DynamoDbIndex $primaryIndex, array $localSecondaryIndices = [], array $globalSecondaryIndices = [], $readCapacity = 5, $writeCapacity = 5)
 {
     $attrDef = $primaryIndex->getAttributeDefinitions();
     foreach ($globalSecondaryIndices as $gsi) {
         $gsiDef = $gsi->getAttributeDefinitions();
         $attrDef = array_merge($attrDef, $gsiDef);
     }
     foreach ($localSecondaryIndices as $lsi) {
         $lsiDef = $lsi->getAttributeDefinitions();
         $attrDef = array_merge($attrDef, $lsiDef);
     }
     $attrDef = array_values($attrDef);
     $keySchema = $primaryIndex->getKeySchema();
     $gsiDef = [];
     foreach ($globalSecondaryIndices as $globalSecondaryIndex) {
         $gsiDef[] = ["IndexName" => $globalSecondaryIndex->getName(), "KeySchema" => $globalSecondaryIndex->getKeySchema(), "Projection" => $globalSecondaryIndex->getProjection(), "ProvisionedThroughput" => ["ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity]];
     }
     $lsiDef = [];
     foreach ($localSecondaryIndices as $localSecondaryIndex) {
         $lsiDef[] = ["IndexName" => $localSecondaryIndex->getName(), "KeySchema" => $localSecondaryIndex->getKeySchema(), "Projection" => $localSecondaryIndex->getProjection()];
     }
     $args = ["TableName" => $tableName, "ProvisionedThroughput" => ["ReadCapacityUnits" => $readCapacity, "WriteCapacityUnits" => $writeCapacity], "AttributeDefinitions" => $attrDef, "KeySchema" => $keySchema];
     if ($gsiDef) {
         $args["GlobalSecondaryIndexes"] = $gsiDef;
     }
     if ($lsiDef) {
         $args["LocalSecondaryIndexes"] = $lsiDef;
     }
     $result = $this->db->createTable($args);
     if (isset($result['TableDescription']) && $result['TableDescription']) {
         return true;
     } else {
         return false;
     }
 }
 public function addGlobalSecondaryIndex(DynamoDbIndex $gsi, $readCapacity = 5, $writeCapacity = 5)
 {
     if ($this->getGlobalSecondaryIndices(sprintf("/%s/", preg_quote($gsi->getName(), "/")))) {
         throw new \RuntimeException("Global Secondary Index exists, name = " . $gsi->getName());
     }
     $args = ['AttributeDefinitions' => $gsi->getAttributeDefinitions(false), 'GlobalSecondaryIndexUpdates' => [['Create' => ['IndexName' => $gsi->getName(), 'KeySchema' => $gsi->getKeySchema(), 'Projection' => $gsi->getProjection(), 'ProvisionedThroughput' => ['ReadCapacityUnits' => $readCapacity, 'WriteCapacityUnits' => $writeCapacity]]]], 'TableName' => $this->tableName];
     $this->dbClient->updateTable($args);
 }