createBackupSelection method

Future<CreateBackupSelectionOutput> createBackupSelection({
  1. required String backupPlanId,
  2. required BackupSelection backupSelection,
  3. String? creatorRequestId,
})

Creates a JSON document that specifies a set of resources to assign to a backup plan. Resources can be included by specifying patterns for a ListOfTags and selected Resources.

For example, consider the following patterns:

  • Resources: "arn:aws:ec2:region:account-id:volume/volume-id"
  • ConditionKey:"department"

    ConditionValue:"finance"

    ConditionType:"StringEquals"

  • ConditionKey:"importance"

    ConditionValue:"critical"

    ConditionType:"StringEquals"

Using these patterns would back up all Amazon Elastic Block Store (Amazon EBS) volumes that are tagged as "department=finance", "importance=critical", in addition to an EBS volume with the specified volume ID.

Resources and conditions are additive in that all resources that match the pattern are selected. This shouldn't be confused with a logical AND, where all conditions must match. The matching patterns are logically put together using the OR operator. In other words, all patterns that match are selected for backup.

May throw LimitExceededException. May throw AlreadyExistsException. May throw InvalidParameterValueException. May throw MissingParameterValueException. May throw ServiceUnavailableException.

Parameter backupPlanId : Uniquely identifies the backup plan to be associated with the selection of resources.

Parameter backupSelection : Specifies the body of a request to assign a set of resources to a backup plan.

Parameter creatorRequestId : A unique string that identifies the request and allows failed requests to be retried without the risk of running the operation twice.

Implementation

Future<CreateBackupSelectionOutput> createBackupSelection({
  required String backupPlanId,
  required BackupSelection backupSelection,
  String? creatorRequestId,
}) async {
  ArgumentError.checkNotNull(backupPlanId, 'backupPlanId');
  ArgumentError.checkNotNull(backupSelection, 'backupSelection');
  final $payload = <String, dynamic>{
    'BackupSelection': backupSelection,
    if (creatorRequestId != null) 'CreatorRequestId': creatorRequestId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/backup/plans/${Uri.encodeComponent(backupPlanId)}/selections/',
    exceptionFnMap: _exceptionFns,
  );
  return CreateBackupSelectionOutput.fromJson(response);
}