restoreTableFromClusterSnapshot method

Future<RestoreTableFromClusterSnapshotResult> restoreTableFromClusterSnapshot({
  1. required String clusterIdentifier,
  2. required String newTableName,
  3. required String snapshotIdentifier,
  4. required String sourceDatabaseName,
  5. required String sourceTableName,
  6. String? sourceSchemaName,
  7. String? targetDatabaseName,
  8. String? targetSchemaName,
})

Creates a new table from a table in an Amazon Redshift cluster snapshot. You must create the new table within the Amazon Redshift cluster that the snapshot was taken from.

You cannot use RestoreTableFromClusterSnapshot to restore a table with the same name as an existing table in an Amazon Redshift cluster. That is, you cannot overwrite an existing table in a cluster with a restored table. If you want to replace your original table with a new, restored table, then rename or drop your original table before you call RestoreTableFromClusterSnapshot. When you have renamed your original table, then you can pass the original name of the table as the NewTableName parameter value in the call to RestoreTableFromClusterSnapshot. This way, you can replace the original table with the table created from the snapshot.

May throw ClusterSnapshotNotFoundFault. May throw InProgressTableRestoreQuotaExceededFault. May throw InvalidClusterSnapshotStateFault. May throw InvalidTableRestoreArgumentFault. May throw ClusterNotFoundFault. May throw InvalidClusterStateFault. May throw UnsupportedOperationFault.

Parameter clusterIdentifier : The identifier of the Amazon Redshift cluster to restore the table to.

Parameter newTableName : The name of the table to create as a result of the current request.

Parameter snapshotIdentifier : The identifier of the snapshot to restore the table from. This snapshot must have been created from the Amazon Redshift cluster specified by the ClusterIdentifier parameter.

Parameter sourceDatabaseName : The name of the source database that contains the table to restore from.

Parameter sourceTableName : The name of the source table to restore from.

Parameter sourceSchemaName : The name of the source schema that contains the table to restore from. If you do not specify a SourceSchemaName value, the default is public.

Parameter targetDatabaseName : The name of the database to restore the table to.

Parameter targetSchemaName : The name of the schema to restore the table to.

Implementation

Future<RestoreTableFromClusterSnapshotResult>
    restoreTableFromClusterSnapshot({
  required String clusterIdentifier,
  required String newTableName,
  required String snapshotIdentifier,
  required String sourceDatabaseName,
  required String sourceTableName,
  String? sourceSchemaName,
  String? targetDatabaseName,
  String? targetSchemaName,
}) async {
  ArgumentError.checkNotNull(clusterIdentifier, 'clusterIdentifier');
  _s.validateStringLength(
    'clusterIdentifier',
    clusterIdentifier,
    0,
    2147483647,
    isRequired: true,
  );
  ArgumentError.checkNotNull(newTableName, 'newTableName');
  _s.validateStringLength(
    'newTableName',
    newTableName,
    0,
    2147483647,
    isRequired: true,
  );
  ArgumentError.checkNotNull(snapshotIdentifier, 'snapshotIdentifier');
  _s.validateStringLength(
    'snapshotIdentifier',
    snapshotIdentifier,
    0,
    2147483647,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sourceDatabaseName, 'sourceDatabaseName');
  _s.validateStringLength(
    'sourceDatabaseName',
    sourceDatabaseName,
    0,
    2147483647,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sourceTableName, 'sourceTableName');
  _s.validateStringLength(
    'sourceTableName',
    sourceTableName,
    0,
    2147483647,
    isRequired: true,
  );
  _s.validateStringLength(
    'sourceSchemaName',
    sourceSchemaName,
    0,
    2147483647,
  );
  _s.validateStringLength(
    'targetDatabaseName',
    targetDatabaseName,
    0,
    2147483647,
  );
  _s.validateStringLength(
    'targetSchemaName',
    targetSchemaName,
    0,
    2147483647,
  );
  final $request = <String, dynamic>{};
  $request['ClusterIdentifier'] = clusterIdentifier;
  $request['NewTableName'] = newTableName;
  $request['SnapshotIdentifier'] = snapshotIdentifier;
  $request['SourceDatabaseName'] = sourceDatabaseName;
  $request['SourceTableName'] = sourceTableName;
  sourceSchemaName?.also((arg) => $request['SourceSchemaName'] = arg);
  targetDatabaseName?.also((arg) => $request['TargetDatabaseName'] = arg);
  targetSchemaName?.also((arg) => $request['TargetSchemaName'] = arg);
  final $result = await _protocol.send(
    $request,
    action: 'RestoreTableFromClusterSnapshot',
    version: '2012-12-01',
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    shape: shapes['RestoreTableFromClusterSnapshotMessage'],
    shapes: shapes,
    resultWrapper: 'RestoreTableFromClusterSnapshotResult',
  );
  return RestoreTableFromClusterSnapshotResult.fromXml($result);
}