createArchive method

Future<CreateArchiveResponse> createArchive({
  1. required String archiveName,
  2. String? clientToken,
  3. String? kmsKeyArn,
  4. ArchiveRetention? retention,
  5. List<Tag>? tags,
})

Creates a new email archive resource for storing and retaining emails.

May throw AccessDeniedException. May throw ConflictException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter archiveName : A unique name for the new archive.

Parameter clientToken : A unique token Amazon SES uses to recognize retries of this request.

Parameter kmsKeyArn : The Amazon Resource Name (ARN) of the KMS key for encrypting emails in the archive.

Parameter retention : The period for retaining emails in the archive before automatic deletion.

Parameter tags : The tags used to organize, track, or control access for the resource. For example, { "tags": {"key1":"value1", "key2":"value2"} }.

Implementation

Future<CreateArchiveResponse> createArchive({
  required String archiveName,
  String? clientToken,
  String? kmsKeyArn,
  ArchiveRetention? retention,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'MailManagerSvc.CreateArchive'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'ArchiveName': archiveName,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (kmsKeyArn != null) 'KmsKeyArn': kmsKeyArn,
      if (retention != null) 'Retention': retention,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreateArchiveResponse.fromJson(jsonResponse.body);
}