restoreTableFromBackup method

Future<RestoreTableFromBackupOutput> restoreTableFromBackup({
  1. required String backupArn,
  2. required String targetTableName,
  3. BillingMode? billingModeOverride,
  4. List<GlobalSecondaryIndex>? globalSecondaryIndexOverride,
  5. List<LocalSecondaryIndex>? localSecondaryIndexOverride,
  6. ProvisionedThroughput? provisionedThroughputOverride,
  7. SSESpecification? sSESpecificationOverride,
})

Creates a new table from an existing backup. Any number of users can execute up to 4 concurrent restores (any type of restore) in a given account.

You can call RestoreTableFromBackup at a maximum rate of 10 times per second.

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

May throw TableAlreadyExistsException. May throw TableInUseException. May throw BackupNotFoundException. May throw BackupInUseException. May throw LimitExceededException. May throw InternalServerError.

Parameter backupArn : The Amazon Resource Name (ARN) associated with the backup.

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

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 sSESpecificationOverride : The new server-side encryption settings for the restored table.

Implementation

Future<RestoreTableFromBackupOutput> restoreTableFromBackup({
  required String backupArn,
  required String targetTableName,
  BillingMode? billingModeOverride,
  List<GlobalSecondaryIndex>? globalSecondaryIndexOverride,
  List<LocalSecondaryIndex>? localSecondaryIndexOverride,
  ProvisionedThroughput? provisionedThroughputOverride,
  SSESpecification? sSESpecificationOverride,
}) async {
  ArgumentError.checkNotNull(backupArn, 'backupArn');
  _s.validateStringLength(
    'backupArn',
    backupArn,
    37,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(targetTableName, 'targetTableName');
  _s.validateStringLength(
    'targetTableName',
    targetTableName,
    3,
    255,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'DynamoDB_20120810.RestoreTableFromBackup'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'BackupArn': backupArn,
      'TargetTableName': targetTableName,
      if (billingModeOverride != null)
        'BillingModeOverride': billingModeOverride.toValue(),
      if (globalSecondaryIndexOverride != null)
        'GlobalSecondaryIndexOverride': globalSecondaryIndexOverride,
      if (localSecondaryIndexOverride != null)
        'LocalSecondaryIndexOverride': localSecondaryIndexOverride,
      if (provisionedThroughputOverride != null)
        'ProvisionedThroughputOverride': provisionedThroughputOverride,
      if (sSESpecificationOverride != null)
        'SSESpecificationOverride': sSESpecificationOverride,
    },
  );

  return RestoreTableFromBackupOutput.fromJson(jsonResponse.body);
}