Skip to content

get_session

get_session(
    bot_id: BotIdentifier,
    bot_alias_id: BotAliasIdentifier,
    locale_id: LocaleId,
    session_id: SessionId,
    *,
    config_overrides: Optional[LexRuntimeV2ClientConfig] = None,
) -> GetSessionResponse

Returns session information for a specified bot, alias, and user.

For example, you can use this operation to retrieve session information for a user that has left a long-running session in use.

If the bot, alias, or session identifier doesn't exist, Amazon Lex V2 returns a BadRequestException. If the locale doesn't exist or is not enabled for the alias, you receive a BadRequestException.

Parameters:

  • bot_id (BotIdentifier) –

    The identifier of the bot that contains the session data.

  • bot_alias_id (BotAliasIdentifier) –

    The alias identifier in use for the bot that contains the session data.

  • locale_id (LocaleId) –

    The locale where the session is in use.

  • session_id (SessionId) –

    The identifier of the session to return.

Raises:

Source code in docs_src/capo_lex_runtime_v2/_services/lex_runtime_v2.py
def get_session(
    self,
    bot_id: "capo_lex_runtime_v2.types.bot_identifier.BotIdentifier",
    bot_alias_id: "capo_lex_runtime_v2.types.bot_alias_identifier.BotAliasIdentifier",
    locale_id: "capo_lex_runtime_v2.types.locale_id.LocaleId",
    session_id: "capo_lex_runtime_v2.types.session_id.SessionId",
    *,
    config_overrides: Optional[LexRuntimeV2ClientConfig] = None,
) -> "capo_lex_runtime_v2.types.get_session_response.GetSessionResponse":
    """<p>Returns session information for a specified bot, alias, and user.</p> <p>For example, you can use this operation to retrieve session information for a user that has left a long-running session in use.</p> <p>If the bot, alias, or session identifier doesn't exist, Amazon Lex V2 returns a <code>BadRequestException</code>. If the locale doesn't exist or is not enabled for the alias, you receive a <code>BadRequestException</code>.</p>

    Args:
        bot_id: <p>The identifier of the bot that contains the session data.</p>
        bot_alias_id: <p>The alias identifier in use for the bot that contains the session data.</p>
        locale_id: <p>The locale where the session is in use.</p>
        session_id: <p>The identifier of the session to return.</p>

    Raises:
        capo_lex_runtime_v2.errors.access_denied_exception.AccessDeniedException: <p></p>
        capo_lex_runtime_v2.errors.internal_server_exception.InternalServerException: <p></p>
        capo_lex_runtime_v2.errors.resource_not_found_exception.ResourceNotFoundException: <p></p>
        capo_lex_runtime_v2.errors.throttling_exception.ThrottlingException: <p></p>
        capo_lex_runtime_v2.errors.validation_exception.ValidationException: <p></p>
        capo_lex_runtime_v2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_lex_runtime_v2.types.get_session_request.GetSessionRequest]",
    ) -> OperationResponse[
        "capo_lex_runtime_v2.types.get_session_response.GetSessionResponse"
    ]:
        import capo_lex_runtime_v2._operations.aws_deep_sense_run_time_service_api2_0.get_session

        output, http_response = (
            capo_lex_runtime_v2._operations.aws_deep_sense_run_time_service_api2_0.get_session.get_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_lex_runtime_v2.types.get_session_response.GetSessionResponse",
    ) -> dict[str, Any]:
        import capo_lex_runtime_v2.types.get_session_response

        return capo_lex_runtime_v2.types.get_session_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetSession", redact_output=_redact_output),
    )
    input_: capo_lex_runtime_v2.types.get_session_request.GetSessionRequest = {
        "bot_id": bot_id,
        "bot_alias_id": bot_alias_id,
        "locale_id": locale_id,
        "session_id": session_id,
    }

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