Skip to content

create_membership async

create_membership(
    application_id: ApplicationId,
    agent_space_id: AgentSpaceId,
    membership_id: MembershipId,
    member_type: MembershipType,
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    config: Optional[MembershipConfig] = None,
) -> CreateMembershipResponse

Creates a new membership, granting a user access to an agent space within an application.

Parameters:

  • application_id (ApplicationId) –

    The unique identifier of the application that contains the agent space.

  • agent_space_id (AgentSpaceId) –

    The unique identifier of the agent space to grant access to.

  • membership_id (MembershipId) –

    The unique identifier for the membership.

  • member_type (MembershipType) –

    The type of member. Currently, only USER is supported.

  • config (Optional[MembershipConfig], default: None ) –

    The configuration for the membership, such as the user role.

Raises:

Source code in docs_src/capo_securityagent/_services/async_security_agent.py
async def create_membership(
    self,
    application_id: "capo_securityagent.types.application_id.ApplicationId",
    agent_space_id: "capo_securityagent.types.agent_space_id.AgentSpaceId",
    membership_id: "capo_securityagent.types.membership_id.MembershipId",
    member_type: "capo_securityagent.types.membership_type.MembershipType",
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    config: Optional[
        "capo_securityagent.types.membership_config.MembershipConfig"
    ] = None,
) -> "capo_securityagent.types.create_membership_response.CreateMembershipResponse":
    """<p>Creates a new membership, granting a user access to an agent space within an application.</p>

    Args:
        application_id: <p>The unique identifier of the application that contains the agent space.</p>
        agent_space_id: <p>The unique identifier of the agent space to grant access to.</p>
        membership_id: <p>The unique identifier for the membership.</p>
        member_type: <p>The type of member. Currently, only USER is supported.</p>
        config: <p>The configuration for the membership, such as the user role.</p>

    Raises:
        capo_securityagent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityagent.types.create_membership_request.CreateMembershipRequest]",
    ) -> AsyncOperationResponse[
        "capo_securityagent.types.create_membership_response.CreateMembershipResponse"
    ]:
        import capo_securityagent._operations.security_agent.create_membership

        (
            output,
            http_response,
        ) = await capo_securityagent._operations.security_agent.create_membership.async_create_membership(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateMembership")
    )
    input_: capo_securityagent.types.create_membership_request.CreateMembershipRequest = {
        "application_id": application_id,
        "agent_space_id": agent_space_id,
        "membership_id": membership_id,
        "member_type": member_type,
    }
    if config is not None:
        input_["config"] = config

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output