createRelationalDatabaseSnapshot method

Future<CreateRelationalDatabaseSnapshotResult> createRelationalDatabaseSnapshot({
  1. required String relationalDatabaseName,
  2. required String relationalDatabaseSnapshotName,
  3. List<Tag>? tags,
})

Creates a snapshot of your database in Amazon Lightsail. You can use snapshots for backups, to make copies of a database, and to save data before deleting a database.

The create relational database snapshot operation supports tag-based access control via request tags. For more information, see the Lightsail Dev Guide.

May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw AccountSetupInProgressException. May throw UnauthenticatedException.

Parameter relationalDatabaseName : The name of the database on which to base your new snapshot.

Parameter relationalDatabaseSnapshotName : The name for your new database snapshot.

Constraints:

  • Must contain from 2 to 255 alphanumeric characters, or hyphens.
  • The first and last character must be a letter or number.

Parameter tags : The tag keys and optional values to add to the resource during create.

Use the TagResource action to tag a resource after it's created.

Implementation

Future<CreateRelationalDatabaseSnapshotResult>
    createRelationalDatabaseSnapshot({
  required String relationalDatabaseName,
  required String relationalDatabaseSnapshotName,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(
      relationalDatabaseName, 'relationalDatabaseName');
  ArgumentError.checkNotNull(
      relationalDatabaseSnapshotName, 'relationalDatabaseSnapshotName');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Lightsail_20161128.CreateRelationalDatabaseSnapshot'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'relationalDatabaseName': relationalDatabaseName,
      'relationalDatabaseSnapshotName': relationalDatabaseSnapshotName,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateRelationalDatabaseSnapshotResult.fromJson(jsonResponse.body);
}