createOrganization method

Future<CreateOrganizationResponse> createOrganization({
  1. required String alias,
  2. String? clientToken,
  3. String? directoryId,
  4. List<Domain>? domains,
  5. bool? enableInteroperability,
  6. String? kmsKeyArn,
})

Creates a new WorkMail organization. Optionally, you can choose to associate an existing AWS Directory Service directory with your organization. If an AWS Directory Service directory ID is specified, the organization alias must match the directory alias. If you choose not to associate an existing directory with your organization, then we create a new WorkMail directory for you. For more information, see Adding an organization in the WorkMail Administrator Guide.

You can associate multiple email domains with an organization, then choose your default email domain from the WorkMail console. You can also associate a domain that is managed in an Amazon Route 53 public hosted zone. For more information, see Adding a domain and Choosing the default domain in the WorkMail Administrator Guide.

Optionally, you can use a customer managed key from AWS Key Management Service (AWS KMS) to encrypt email for your organization. If you don't associate an AWS KMS key, WorkMail creates a default, AWS managed key for you.

May throw DirectoryInUseException. May throw DirectoryUnavailableException. May throw InvalidParameterException. May throw LimitExceededException. May throw NameAvailabilityException.

Parameter alias : The organization alias.

Parameter clientToken : The idempotency token associated with the request.

Parameter directoryId : The AWS Directory Service directory ID.

Parameter domains : The email domains to associate with the organization.

Parameter enableInteroperability : When true, allows organization interoperability between WorkMail and Microsoft Exchange. If true, you must include a AD Connector directory ID in the request.

Parameter kmsKeyArn : The Amazon Resource Name (ARN) of a customer managed key from AWS KMS.

Implementation

Future<CreateOrganizationResponse> createOrganization({
  required String alias,
  String? clientToken,
  String? directoryId,
  List<Domain>? domains,
  bool? enableInteroperability,
  String? kmsKeyArn,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'WorkMailService.CreateOrganization'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Alias': alias,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (directoryId != null) 'DirectoryId': directoryId,
      if (domains != null) 'Domains': domains,
      if (enableInteroperability != null)
        'EnableInteroperability': enableInteroperability,
      if (kmsKeyArn != null) 'KmsKeyArn': kmsKeyArn,
    },
  );

  return CreateOrganizationResponse.fromJson(jsonResponse.body);
}