restoreTableToPointInTime method

Future<RestoreTableToPointInTimeOutput> restoreTableToPointInTime({
  1. required String targetTableName,
  2. BillingMode? billingModeOverride,
  3. List<GlobalSecondaryIndex>? globalSecondaryIndexOverride,
  4. List<LocalSecondaryIndex>? localSecondaryIndexOverride,
  5. ProvisionedThroughput? provisionedThroughputOverride,
  6. DateTime? restoreDateTime,
  7. SSESpecification? sSESpecificationOverride,
  8. String? sourceTableArn,
  9. String? sourceTableName,
  10. bool? useLatestRestorableTime,
})

Restores the specified table to the specified point in time within EarliestRestorableDateTime and LatestRestorableDateTime. You can restore your table to any point in time during the last 35 days. Any number of users can execute up to 4 concurrent restores (any type of restore) in a given account.

When you restore using point in time recovery, DynamoDB restores your table data to the state based on the selected date and time (day:hour:minute:second) to a new table.

Along with data, the following are also included on the new restored table using point in time recovery:

  • Global secondary indexes (GSIs)
  • Local secondary indexes (LSIs)
  • Provisioned read and write capacity
  • Encryption settings
You must manually set up the following on the restored table:
  • Auto scaling policies
  • IAM policies
  • Amazon CloudWatch metrics and alarms
  • Tags
  • Stream settings
  • Time to Live (TTL) settings
  • Point in time recovery settings

May throw TableAlreadyExistsException. May throw TableNotFoundException. May throw TableInUseException. May throw LimitExceededException. May throw InvalidRestoreTimeException. May throw PointInTimeRecoveryUnavailableException. May throw InternalServerError.

Parameter targetTableName : The name of the new table to which it must be restored to.

Parameter billingModeOverride : The billing mode of the restored table.

Parameter globalSecondaryIndexOverride : List of global secondary indexes for the restored table. The indexes provided should match existing secondary indexes. You can choose to exclude some or all of the indexes at the time of restore.

Parameter localSecondaryIndexOverride : List of local secondary indexes for the restored table. The indexes provided should match existing secondary indexes. You can choose to exclude some or all of the indexes at the time of restore.

Parameter provisionedThroughputOverride : Provisioned throughput settings for the restored table.

Parameter restoreDateTime : Time in the past to restore the table to.

Parameter sSESpecificationOverride : The new server-side encryption settings for the restored table.

Parameter sourceTableArn : The DynamoDB table that will be restored. This value is an Amazon Resource Name (ARN).

Parameter sourceTableName : Name of the source table that is being restored.

Parameter useLatestRestorableTime : Restore the table to the latest possible time. LatestRestorableDateTime is typically 5 minutes before the current time.

Implementation

Future<RestoreTableToPointInTimeOutput> restoreTableToPointInTime({
  required String targetTableName,
  BillingMode? billingModeOverride,
  List<GlobalSecondaryIndex>? globalSecondaryIndexOverride,
  List<LocalSecondaryIndex>? localSecondaryIndexOverride,
  ProvisionedThroughput? provisionedThroughputOverride,
  DateTime? restoreDateTime,
  SSESpecification? sSESpecificationOverride,
  String? sourceTableArn,
  String? sourceTableName,
  bool? useLatestRestorableTime,
}) async {
  ArgumentError.checkNotNull(targetTableName, 'targetTableName');
  _s.validateStringLength(
    'targetTableName',
    targetTableName,
    3,
    255,
    isRequired: true,
  );
  _s.validateStringLength(
    'sourceTableName',
    sourceTableName,
    3,
    255,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.RestoreTableToPointInTime'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'TargetTableName': targetTableName,
      if (billingModeOverride != null)
        'BillingModeOverride': billingModeOverride.toValue(),
      if (globalSecondaryIndexOverride != null)
        'GlobalSecondaryIndexOverride': globalSecondaryIndexOverride,
      if (localSecondaryIndexOverride != null)
        'LocalSecondaryIndexOverride': localSecondaryIndexOverride,
      if (provisionedThroughputOverride != null)
        'ProvisionedThroughputOverride': provisionedThroughputOverride,
      if (restoreDateTime != null)
        'RestoreDateTime': unixTimestampToJson(restoreDateTime),
      if (sSESpecificationOverride != null)
        'SSESpecificationOverride': sSESpecificationOverride,
      if (sourceTableArn != null) 'SourceTableArn': sourceTableArn,
      if (sourceTableName != null) 'SourceTableName': sourceTableName,
      if (useLatestRestorableTime != null)
        'UseLatestRestorableTime': useLatestRestorableTime,
    },
  );

  return RestoreTableToPointInTimeOutput.fromJson(jsonResponse.body);
}