startMailboxExportJob method

Future<StartMailboxExportJobResponse> startMailboxExportJob({
  1. required String entityId,
  2. required String kmsKeyArn,
  3. required String organizationId,
  4. required String roleArn,
  5. required String s3BucketName,
  6. required String s3Prefix,
  7. String? clientToken,
  8. String? description,
})

Starts a mailbox export job to export MIME-format email messages and calendar items from the specified mailbox to the specified Amazon Simple Storage Service (Amazon S3) bucket. For more information, see Exporting mailbox content in the Amazon WorkMail Administrator Guide.

May throw InvalidParameterException. May throw OrganizationNotFoundException. May throw OrganizationStateException. May throw EntityNotFoundException. May throw LimitExceededException.

Parameter entityId : The identifier of the user or resource associated with the mailbox.

Parameter kmsKeyArn : The Amazon Resource Name (ARN) of the symmetric AWS Key Management Service (AWS KMS) key that encrypts the exported mailbox content.

Parameter organizationId : The identifier associated with the organization.

Parameter roleArn : The ARN of the AWS Identity and Access Management (IAM) role that grants write permission to the S3 bucket.

Parameter s3BucketName : The name of the S3 bucket.

Parameter s3Prefix : The S3 bucket prefix.

Parameter clientToken : The idempotency token for the client request.

Parameter description : The mailbox export job description.

Implementation

Future<StartMailboxExportJobResponse> startMailboxExportJob({
  required String entityId,
  required String kmsKeyArn,
  required String organizationId,
  required String roleArn,
  required String s3BucketName,
  required String s3Prefix,
  String? clientToken,
  String? description,
}) async {
  ArgumentError.checkNotNull(entityId, 'entityId');
  _s.validateStringLength(
    'entityId',
    entityId,
    12,
    256,
    isRequired: true,
  );
  ArgumentError.checkNotNull(kmsKeyArn, 'kmsKeyArn');
  _s.validateStringLength(
    'kmsKeyArn',
    kmsKeyArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(organizationId, 'organizationId');
  _s.validateStringLength(
    'organizationId',
    organizationId,
    34,
    34,
    isRequired: true,
  );
  ArgumentError.checkNotNull(roleArn, 'roleArn');
  _s.validateStringLength(
    'roleArn',
    roleArn,
    20,
    2048,
    isRequired: true,
  );
  ArgumentError.checkNotNull(s3BucketName, 's3BucketName');
  _s.validateStringLength(
    's3BucketName',
    s3BucketName,
    1,
    63,
    isRequired: true,
  );
  ArgumentError.checkNotNull(s3Prefix, 's3Prefix');
  _s.validateStringLength(
    's3Prefix',
    s3Prefix,
    1,
    1023,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    128,
  );
  _s.validateStringLength(
    'description',
    description,
    0,
    1023,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.StartMailboxExportJob'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'EntityId': entityId,
      'KmsKeyArn': kmsKeyArn,
      'OrganizationId': organizationId,
      'RoleArn': roleArn,
      'S3BucketName': s3BucketName,
      'S3Prefix': s3Prefix,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
    },
  );

  return StartMailboxExportJobResponse.fromJson(jsonResponse.body);
}