Skip to content

create_session

create_session(
    assistant_id: UuidOrArn,
    name: Name,
    *,
    config_overrides: Optional[WisdomClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    description: Optional[Description] = None,
    tags: Optional[Tags] = None,
) -> CreateSessionResponse

Creates a session. A session is a contextual container used for generating recommendations. Amazon Connect creates a new Wisdom session for each contact on which Wisdom is enabled.

Parameters:

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

  • assistant_id (UuidOrArn) –

    The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • name (Name) –

    The name of the session.

  • description (Optional[Description], default: None ) –

    The description.

  • tags (Optional[Tags], default: None ) –

    The tags used to organize, track, or control access for this resource.

Raises:

  • ConflictException –

    The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_wisdom/_services/wisdom.py
def create_session(
    self,
    assistant_id: "capo_wisdom.types.uuid_or_arn.UuidOrArn",
    name: "capo_wisdom.types.name.Name",
    *,
    config_overrides: Optional[WisdomClientConfig] = None,
    client_token: Optional["capo_wisdom.types.client_token.ClientToken"] = None,
    description: Optional["capo_wisdom.types.description.Description"] = None,
    tags: Optional["capo_wisdom.types.tags.Tags"] = None,
) -> "capo_wisdom.types.create_session_response.CreateSessionResponse":
    """<p>Creates a session. A session is a contextual container used for generating recommendations. Amazon Connect creates a new Wisdom session for each contact on which Wisdom is enabled.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        assistant_id: <p>The identifier of the Wisdom assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        name: <p>The name of the session.</p>
        description: <p>The description.</p>
        tags: <p>The tags used to organize, track, or control access for this resource.</p>

    Raises:
        capo_wisdom.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource. For example, if you're using a <code>Create</code> API (such as <code>CreateAssistant</code>) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.</p>
        capo_wisdom.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_wisdom.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_wisdom.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_wisdom.types.create_session_request.CreateSessionRequest]",
    ) -> OperationResponse[
        "capo_wisdom.types.create_session_response.CreateSessionResponse"
    ]:
        import capo_wisdom._operations.wisdom_service.create_session

        output, http_response = (
            capo_wisdom._operations.wisdom_service.create_session.create_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateSession")
    )
    input_: capo_wisdom.types.create_session_request.CreateSessionRequest = {
        "assistant_id": assistant_id,
        "name": name,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags

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