Skip to content

list_sessions async

list_sessions(
    portal_id: PortalId,
    *,
    config_overrides: Optional[AsyncWorkSpacesWebClientConfig] = None,
    username: Optional[Username] = None,
    session_id: Optional[SessionId] = None,
    sort_by: Optional[SessionSortBy] = None,
    status: Optional[SessionStatus] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[PaginationToken] = None,
) -> ListSessionsResponse

Lists information for multiple secure browser sessions from a specific portal.

Parameters:

  • portal_id (PortalId) –

    The ID of the web portal for the sessions.

  • username (Optional[Username], default: None ) –

    The username of the session.

  • session_id (Optional[SessionId], default: None ) –

    The ID of the session.

  • sort_by (Optional[SessionSortBy], default: None ) –

    The method in which the returned sessions should be sorted.

  • status (Optional[SessionStatus], default: None ) –

    The status of the session.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to be included in the next page.

  • next_token (Optional[PaginationToken], default: None ) –

    The pagination token used to retrieve the next page of results for this operation.

Raises:

Source code in docs_src/capo_workspaces_web/_services/async_work_spaces_web.py
async def list_sessions(
    self,
    portal_id: "capo_workspaces_web.types.portal_id.PortalId",
    *,
    config_overrides: Optional[AsyncWorkSpacesWebClientConfig] = None,
    username: Optional["capo_workspaces_web.types.username.Username"] = None,
    session_id: Optional["capo_workspaces_web.types.session_id.SessionId"] = None,
    sort_by: Optional[
        "capo_workspaces_web.types.session_sort_by.SessionSortBy"
    ] = None,
    status: Optional[
        "capo_workspaces_web.types.session_status.SessionStatus"
    ] = None,
    max_results: Optional[
        "capo_workspaces_web.types.max_results.MaxResults"
    ] = None,
    next_token: Optional[
        "capo_workspaces_web.types.pagination_token.PaginationToken"
    ] = None,
) -> "capo_workspaces_web.types.list_sessions_response.ListSessionsResponse":
    """<p>Lists information for multiple secure browser sessions from a specific portal.</p>

    Args:
        portal_id: <p>The ID of the web portal for the sessions.</p>
        username: <p>The username of the session.</p>
        session_id: <p>The ID of the session.</p>
        sort_by: <p>The method in which the returned sessions should be sorted.</p>
        status: <p>The status of the session.</p>
        max_results: <p>The maximum number of results to be included in the next page.</p>
        next_token: <p>The pagination token used to retrieve the next page of results for this operation.</p>

    Raises:
        capo_workspaces_web.errors.access_denied_exception.AccessDeniedException: <p>Access is denied.</p>
        capo_workspaces_web.errors.internal_server_exception.InternalServerException: <p>There is an internal server error.</p>
        capo_workspaces_web.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource cannot be found.</p>
        capo_workspaces_web.errors.throttling_exception.ThrottlingException: <p>There is a throttling error.</p>
        capo_workspaces_web.errors.validation_exception.ValidationException: <p>There is a validation error.</p>
        capo_workspaces_web.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_workspaces_web.types.list_sessions_request.ListSessionsRequest]",
    ) -> AsyncOperationResponse[
        "capo_workspaces_web.types.list_sessions_response.ListSessionsResponse"
    ]:
        import capo_workspaces_web._operations.aws_ermine_control_plane_service.list_sessions

        (
            output,
            http_response,
        ) = await capo_workspaces_web._operations.aws_ermine_control_plane_service.list_sessions.async_list_sessions(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_workspaces_web.types.list_sessions_request.ListSessionsRequest",
    ) -> dict[str, Any]:
        import capo_workspaces_web.types.list_sessions_request

        return capo_workspaces_web.types.list_sessions_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_workspaces_web.types.list_sessions_response.ListSessionsResponse",
    ) -> dict[str, Any]:
        import capo_workspaces_web.types.list_sessions_response

        return capo_workspaces_web.types.list_sessions_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ListSessions", redact_input=_redact_input, redact_output=_redact_output
        ),
    )
    input_: capo_workspaces_web.types.list_sessions_request.ListSessionsRequest = {
        "portal_id": portal_id
    }
    if username is not None:
        input_["username"] = username
    if session_id is not None:
        input_["session_id"] = session_id
    if sort_by is not None:
        input_["sort_by"] = sort_by
    if status is not None:
        input_["status"] = status
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

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