startMetadataModelExportAsScript method

Future<StartMetadataModelExportAsScriptResponse> startMetadataModelExportAsScript({
  1. required String migrationProjectIdentifier,
  2. required OriginTypeValue origin,
  3. required String selectionRules,
  4. String? fileName,
})

Queues an export of metadata models (database objects such as tables, views, and procedures) as a data definition language (DDL) script. The script is stored as a ZIP archive in the Amazon S3 bucket associated with the migration project. If other requests created by Start* operations are already in the migration project's queue, the export begins after they complete.

When exporting from the target metadata tree, the export applies only to metadata models created by conversion. Metadata models imported from the database are skipped.

To check the status of the export request, call DescribeMetadataModelExportsAsScript using the returned RequestIdentifier as a filter.

Required permissions: dms:StartMetadataModelExportAsScripts. For more information, see Actions, resources, and condition keys for Database Migration Service.

May throw AccessDeniedFault. May throw InvalidResourceStateFault. May throw KMSKeyNotAccessibleFault. May throw ResourceAlreadyExistsFault. May throw ResourceNotFoundFault. May throw ResourceQuotaExceededFault. May throw S3AccessDeniedFault. May throw S3ResourceNotFoundFault.

Parameter migrationProjectIdentifier : The migration project name or Amazon Resource Name (ARN).

Parameter origin : Specifies the metadata tree to export from.

Parameter selectionRules : A JSON string that identifies the metadata models to export as a SQL script. For the selection rule format and examples, see Selection rules in DMS Schema Conversion.

Usage:

  • Accepts source or target selection rules depending on the Origin parameter. The server-name in the object locator must match the corresponding data provider.
  • Supports explicit, include, and exclude rule actions.

Parameter fileName : The name for the exported file. When you omit this parameter, the service generates a name from the data provider engine name and an export timestamp.

Implementation

Future<StartMetadataModelExportAsScriptResponse>
    startMetadataModelExportAsScript({
  required String migrationProjectIdentifier,
  required OriginTypeValue origin,
  required String selectionRules,
  String? fileName,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonDMSv20160101.StartMetadataModelExportAsScript'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'MigrationProjectIdentifier': migrationProjectIdentifier,
      'Origin': origin.value,
      'SelectionRules': selectionRules,
      if (fileName != null) 'FileName': fileName,
    },
  );

  return StartMetadataModelExportAsScriptResponse.fromJson(jsonResponse.body);
}