deleteSnapshot static method

Future<void> deleteSnapshot(
  1. Client cloudApiClient, {
  2. required CommandLogger logger,
  3. required String projectId,
  4. required String snapshotId,
  5. bool skipConfirmation = false,
})

Deletes a single snapshot of the project's database.

Implementation

static Future<void> deleteSnapshot(
  final Client cloudApiClient, {
  required final CommandLogger logger,
  required final String projectId,
  required final String snapshotId,
  final bool skipConfirmation = false,
}) async {
  if (!skipConfirmation) {
    final confirmed = await logger.confirm(
      'Permanently delete snapshot "$snapshotId" for project "$projectId"? '
      'This action cannot be undone.',
      defaultValue: false,
    );
    if (!confirmed) {
      throw UserAbortException();
    }
  }

  try {
    await cloudApiClient.database.deleteSnapshot(
      cloudCapsuleId: projectId,
      snapshotId: snapshotId,
    );
  } on Exception catch (e, s) {
    throw FailureException.nested(e, s, 'Failed to delete snapshot');
  }

  logger.success('Snapshot "$snapshotId" deleted.', newParagraph: true);
}