updateTable method

Future<UpdateTableOutput> updateTable({
  1. required String tableName,
  2. List<AttributeDefinition>? attributeDefinitions,
  3. BillingMode? billingMode,
  4. List<GlobalSecondaryIndexUpdate>? globalSecondaryIndexUpdates,
  5. ProvisionedThroughput? provisionedThroughput,
  6. List<ReplicationGroupUpdate>? replicaUpdates,
  7. SSESpecification? sSESpecification,
  8. StreamSpecification? streamSpecification,
})

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

You can only perform one of the following operations at once:

  • Modify the provisioned throughput settings of the table.
  • Enable or disable DynamoDB Streams on the table.
  • Remove a global secondary index from the table.
  • Create a new global secondary index on the table. After the index begins backfilling, you can use UpdateTable to perform other operations.
UpdateTable is an asynchronous operation; while it is executing, the table status changes from ACTIVE to UPDATING. While it is UPDATING, you cannot issue another UpdateTable request. When the table returns to the ACTIVE state, the UpdateTable operation is complete.

May throw ResourceInUseException. May throw ResourceNotFoundException. May throw LimitExceededException. May throw InternalServerError.

Parameter tableName : The name of the table to be updated.

Parameter attributeDefinitions : An array of attributes that describe the key schema for the table and indexes. If you are adding a new global secondary index to the table, AttributeDefinitions must include the key element(s) of the new index.

Parameter billingMode : Controls how you are charged for read and write throughput and how you manage capacity. When switching from pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The initial provisioned capacity values are estimated based on the consumed read and write capacity of your table and global secondary indexes over the past 30 minutes.

  • PROVISIONED - We recommend using PROVISIONED for predictable workloads. PROVISIONED sets the billing mode to Provisioned Mode.
  • PAY_PER_REQUEST - We recommend using PAY_PER_REQUEST for unpredictable workloads. PAY_PER_REQUEST sets the billing mode to On-Demand Mode.

Parameter globalSecondaryIndexUpdates : An array of one or more global secondary indexes for the table. For each index in the array, you can request one action:

  • Create - add a new global secondary index to the table.
  • Update - modify the provisioned throughput settings of an existing global secondary index.
  • Delete - remove a global secondary index from the table.
You can create or delete only one global secondary index per UpdateTable operation.

For more information, see Managing Global Secondary Indexes in the Amazon DynamoDB Developer Guide.

Parameter provisionedThroughput : The new provisioned throughput settings for the specified table or index.

Parameter replicaUpdates : A list of replica update actions (create, delete, or update) for the table.

Parameter sSESpecification : The new server-side encryption settings for the specified table.

Parameter streamSpecification : Represents the DynamoDB Streams configuration for the table.

Implementation

Future<UpdateTableOutput> updateTable({
  required String tableName,
  List<AttributeDefinition>? attributeDefinitions,
  BillingMode? billingMode,
  List<GlobalSecondaryIndexUpdate>? globalSecondaryIndexUpdates,
  ProvisionedThroughput? provisionedThroughput,
  List<ReplicationGroupUpdate>? replicaUpdates,
  SSESpecification? sSESpecification,
  StreamSpecification? streamSpecification,
}) async {
  ArgumentError.checkNotNull(tableName, 'tableName');
  _s.validateStringLength(
    'tableName',
    tableName,
    3,
    255,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.UpdateTable'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TableName': tableName,
      if (attributeDefinitions != null)
        'AttributeDefinitions': attributeDefinitions,
      if (billingMode != null) 'BillingMode': billingMode.toValue(),
      if (globalSecondaryIndexUpdates != null)
        'GlobalSecondaryIndexUpdates': globalSecondaryIndexUpdates,
      if (provisionedThroughput != null)
        'ProvisionedThroughput': provisionedThroughput,
      if (replicaUpdates != null) 'ReplicaUpdates': replicaUpdates,
      if (sSESpecification != null) 'SSESpecification': sSESpecification,
      if (streamSpecification != null)
        'StreamSpecification': streamSpecification,
    },
  );

  return UpdateTableOutput.fromJson(jsonResponse.body);
}