updateTimeToLive method

Future<UpdateTimeToLiveOutput> updateTimeToLive({
  1. required String tableName,
  2. required TimeToLiveSpecification timeToLiveSpecification,
})

The UpdateTimeToLive method enables or disables Time to Live (TTL) for the specified table. A successful UpdateTimeToLive call returns the current TimeToLiveSpecification. It can take up to one hour for the change to fully process. Any additional UpdateTimeToLive calls for the same table during this one hour duration result in a ValidationException.

TTL compares the current time in epoch time format to the time stored in the TTL attribute of an item. If the epoch time value stored in the attribute is less than the current time, the item is marked as expired and subsequently deleted. DynamoDB deletes expired items on a best-effort basis to ensure availability of throughput for other data operations. As items are deleted, they are removed from any local secondary index and global secondary index immediately in the same eventually consistent way as a standard delete operation.

For more information, see Time To Live in the Amazon DynamoDB Developer Guide.

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

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

Parameter timeToLiveSpecification : Represents the settings used to enable or disable Time to Live for the specified table.

Implementation

Future<UpdateTimeToLiveOutput> updateTimeToLive({
  required String tableName,
  required TimeToLiveSpecification timeToLiveSpecification,
}) async {
  ArgumentError.checkNotNull(tableName, 'tableName');
  _s.validateStringLength(
    'tableName',
    tableName,
    3,
    255,
    isRequired: true,
  );
  ArgumentError.checkNotNull(
      timeToLiveSpecification, 'timeToLiveSpecification');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.UpdateTimeToLive'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TableName': tableName,
      'TimeToLiveSpecification': timeToLiveSpecification,
    },
  );

  return UpdateTimeToLiveOutput.fromJson(jsonResponse.body);
}