Skip to content

create_organization

create_organization(
    alias: OrganizationName,
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    directory_id: Optional[DirectoryId] = None,
    client_token: Optional[IdempotencyClientToken] = None,
    domains: Optional[Domains] = None,
    kms_key_arn: Optional[KmsKeyArn] = None,
    enable_interoperability: Optional[Boolean] = None,
) -> CreateOrganizationResponse

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.

Parameters:

  • directory_id (Optional[DirectoryId], default: None ) –

    The AWS Directory Service directory ID.

  • alias (OrganizationName) –

    The organization alias.

  • client_token (Optional[IdempotencyClientToken], default: None ) –

    The idempotency token associated with the request.

  • domains (Optional[Domains], default: None ) –

    The email domains to associate with the organization.

  • kms_key_arn (Optional[KmsKeyArn], default: None ) –

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

  • enable_interoperability (Optional[Boolean], default: None ) –

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

Raises:

Source code in docs_src/capo_workmail/_services/work_mail.py
def create_organization(
    self,
    alias: "capo_workmail.types.organization_name.OrganizationName",
    *,
    config_overrides: Optional[WorkMailClientConfig] = None,
    directory_id: Optional["capo_workmail.types.directory_id.DirectoryId"] = None,
    client_token: Optional[
        "capo_workmail.types.idempotency_client_token.IdempotencyClientToken"
    ] = None,
    domains: Optional["capo_workmail.types.domains.Domains"] = None,
    kms_key_arn: Optional["capo_workmail.types.kms_key_arn.KmsKeyArn"] = None,
    enable_interoperability: Optional["capo_workmail.types.boolean.Boolean"] = None,
) -> "capo_workmail.types.create_organization_response.CreateOrganizationResponse":
    """<p>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 <a href="https://docs.aws.amazon.com/workmail/latest/adminguide/add_new_organization.html">Adding an organization</a> in the <i>WorkMail Administrator Guide</i>.</p> <p>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 <a href="https://docs.aws.amazon.com/workmail/latest/adminguide/add_domain.html">Adding a domain</a> and <a href="https://docs.aws.amazon.com/workmail/latest/adminguide/default_domain.html">Choosing the default domain</a> in the <i>WorkMail Administrator Guide</i>.</p> <p>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.</p>

    Args:
        directory_id: <p>The AWS Directory Service directory ID.</p>
        alias: <p>The organization alias.</p>
        client_token: <p>The idempotency token associated with the request.</p>
        domains: <p>The email domains to associate with the organization.</p>
        kms_key_arn: <p>The Amazon Resource Name (ARN) of a customer managed key from AWS KMS.</p>
        enable_interoperability: <p>When <code>true</code>, allows organization interoperability between WorkMail and Microsoft Exchange. If <code>true</code>, you must include a AD Connector directory ID in the request.</p>

    Raises:
        capo_workmail.errors.directory_in_use_exception.DirectoryInUseException: <p>The directory is already in use by another WorkMail organization in the same account and Region.</p>
        capo_workmail.errors.directory_unavailable_exception.DirectoryUnavailableException: <p>The directory is unavailable. It might be located in another Region or deleted.</p>
        capo_workmail.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more of the input parameters don't match the service's restrictions.</p>
        capo_workmail.errors.limit_exceeded_exception.LimitExceededException: <p>The request exceeds the limit of the resource.</p>
        capo_workmail.errors.name_availability_exception.NameAvailabilityException: <p>The user, group, or resource name isn't unique in WorkMail.</p>
        capo_workmail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_workmail.types.create_organization_request.CreateOrganizationRequest]",
    ) -> OperationResponse[
        "capo_workmail.types.create_organization_response.CreateOrganizationResponse"
    ]:
        import capo_workmail._operations.work_mail_service.create_organization

        output, http_response = (
            capo_workmail._operations.work_mail_service.create_organization.create_organization(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateOrganization")
    )
    input_: capo_workmail.types.create_organization_request.CreateOrganizationRequest = {
        "alias": alias
    }
    if directory_id is not None:
        input_["directory_id"] = directory_id
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if domains is not None:
        input_["domains"] = domains
    if kms_key_arn is not None:
        input_["kms_key_arn"] = kms_key_arn
    if enable_interoperability is not None:
        input_["enable_interoperability"] = enable_interoperability

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output