Skip to content

share_directory

share_directory(
    directory_id: DirectoryId,
    share_target: ShareTarget,
    share_method: ShareMethod,
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    share_notes: Optional[Notes] = None,
) -> ShareDirectoryResult

Shares a specified directory (DirectoryId) in your Amazon Web Services account (directory owner) with another Amazon Web Services account (directory consumer). With this operation you can use your directory from any Amazon Web Services account and from any Amazon VPC within an Amazon Web Services Region.

When you share your Managed Microsoft AD directory, Directory Service creates a shared directory in the directory consumer account. This shared directory contains the metadata to provide access to the directory within the directory owner account. The shared directory is visible in all VPCs in the directory consumer account.

The ShareMethod parameter determines whether the specified directory can be shared between Amazon Web Services accounts inside the same Amazon Web Services organization (ORGANIZATIONS). It also determines whether you can share the directory with any other Amazon Web Services account either inside or outside of the organization (HANDSHAKE).

The ShareNotes parameter is only used when HANDSHAKE is called, which sends a directory sharing request to the directory consumer.

Parameters:

  • directory_id (DirectoryId) –

    Identifier of the Managed Microsoft AD directory that you want to share with other Amazon Web Services accounts.

  • share_notes (Optional[Notes], default: None ) –

    A directory share request that is sent by the directory owner to the directory consumer. The request includes a typed message to help the directory consumer administrator determine whether to approve or reject the share invitation.

  • share_target (ShareTarget) –

    Identifier for the directory consumer account with whom the directory is to be shared.

  • share_method (ShareMethod) –

    The method used when sharing a directory to determine whether the directory should be shared within your Amazon Web Services organization (ORGANIZATIONS) or with any Amazon Web Services account by sending a directory sharing request (HANDSHAKE).

Raises:

Source code in docs_src/capo_directory_service/_services/directory_service.py
def share_directory(
    self,
    directory_id: "capo_directory_service.types.directory_id.DirectoryId",
    share_target: "capo_directory_service.types.share_target.ShareTarget",
    share_method: "capo_directory_service.types.share_method.ShareMethod",
    *,
    config_overrides: Optional[DirectoryServiceClientConfig] = None,
    share_notes: Optional["capo_directory_service.types.notes.Notes"] = None,
) -> "capo_directory_service.types.share_directory_result.ShareDirectoryResult":
    """<p>Shares a specified directory (<code>DirectoryId</code>) in your Amazon Web Services account (directory owner) with another Amazon Web Services account (directory consumer). With this operation you can use your directory from any Amazon Web Services account and from any Amazon VPC within an Amazon Web Services Region.</p> <p>When you share your Managed Microsoft AD directory, Directory Service creates a shared directory in the directory consumer account. This shared directory contains the metadata to provide access to the directory within the directory owner account. The shared directory is visible in all VPCs in the directory consumer account.</p> <p>The <code>ShareMethod</code> parameter determines whether the specified directory can be shared between Amazon Web Services accounts inside the same Amazon Web Services organization (<code>ORGANIZATIONS</code>). It also determines whether you can share the directory with any other Amazon Web Services account either inside or outside of the organization (<code>HANDSHAKE</code>).</p> <p>The <code>ShareNotes</code> parameter is only used when <code>HANDSHAKE</code> is called, which sends a directory sharing request to the directory consumer. </p>

    Args:
        directory_id: <p>Identifier of the Managed Microsoft AD directory that you want to share with other Amazon Web Services accounts.</p>
        share_notes: <p>A directory share request that is sent by the directory owner to the directory consumer. The request includes a typed message to help the directory consumer administrator determine whether to approve or reject the share invitation.</p>
        share_target: <p>Identifier for the directory consumer account with whom the directory is to be shared.</p>
        share_method: <p>The method used when sharing a directory to determine whether the directory should be shared within your Amazon Web Services organization (<code>ORGANIZATIONS</code>) or with any Amazon Web Services account by sending a directory sharing request (<code>HANDSHAKE</code>).</p>

    Raises:
        capo_directory_service.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_directory_service.errors.client_exception.ClientException: <p>A client exception has occurred.</p>
        capo_directory_service.errors.directory_already_shared_exception.DirectoryAlreadySharedException: <p>The specified directory has already been shared with this Amazon Web Services account.</p>
        capo_directory_service.errors.entity_does_not_exist_exception.EntityDoesNotExistException: <p>The specified entity could not be found.</p>
        capo_directory_service.errors.invalid_parameter_exception.InvalidParameterException: <p>One or more parameters are not valid.</p>
        capo_directory_service.errors.invalid_target_exception.InvalidTargetException: <p>The specified shared target is not valid.</p>
        capo_directory_service.errors.organizations_exception.OrganizationsException: <p>Exception encountered while trying to access your Amazon Web Services organization.</p>
        capo_directory_service.errors.service_exception.ServiceException: <p>An exception has occurred in Directory Service.</p>
        capo_directory_service.errors.share_limit_exceeded_exception.ShareLimitExceededException: <p>The maximum number of Amazon Web Services accounts that you can share with this directory has been reached.</p>
        capo_directory_service.errors.unsupported_operation_exception.UnsupportedOperationException: <p>The operation is not supported.</p>
        capo_directory_service.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_directory_service.types.share_directory_request.ShareDirectoryRequest]",
    ) -> OperationResponse[
        "capo_directory_service.types.share_directory_result.ShareDirectoryResult"
    ]:
        import capo_directory_service._operations.directory_service_20150416.share_directory

        output, http_response = (
            capo_directory_service._operations.directory_service_20150416.share_directory.share_directory(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_directory_service.types.share_directory_request.ShareDirectoryRequest",
    ) -> dict[str, Any]:
        import capo_directory_service.types.share_directory_request

        return (
            capo_directory_service.types.share_directory_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ShareDirectory", redact_input=_redact_input),
    )
    input_: capo_directory_service.types.share_directory_request.ShareDirectoryRequest = {
        "directory_id": directory_id,
        "share_target": share_target,
        "share_method": share_method,
    }
    if share_notes is not None:
        input_["share_notes"] = share_notes

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