Skip to content

list_sessions async

list_sessions(
    *,
    config_overrides: Optional[AsyncEMRClientConfig] = None,
    cluster_id: Optional[ClusterId] = None,
    session_states: Optional[SessionStateList] = None,
    next_token: Optional[String] = None,
    max_results: Optional[MaxResultsNumber] = None,
) -> ListSessionsOutput

Lists the sessions on a cluster. You can filter the results by session state. Newer sessions are returned first.

Parameters:

  • cluster_id (Optional[ClusterId], default: None ) –

    The ID of the cluster to list sessions for.

  • session_states (Optional[SessionStateList], default: None ) –

    An optional filter that limits the results to sessions in the specified states.

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

    The pagination token returned by a previous ListSessions call. Use it to retrieve the next page of results.

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

    The maximum number of sessions to return in each page of results.

Raises:

Source code in docs_src/capo_emr/_services/async_emr.py
async def list_sessions(
    self,
    *,
    config_overrides: Optional[AsyncEMRClientConfig] = None,
    cluster_id: Optional["capo_emr.types.cluster_id.ClusterId"] = None,
    session_states: Optional[
        "capo_emr.types.session_state_list.SessionStateList"
    ] = None,
    next_token: Optional["capo_emr.types.string.String"] = None,
    max_results: Optional[
        "capo_emr.types.max_results_number.MaxResultsNumber"
    ] = None,
) -> "capo_emr.types.list_sessions_output.ListSessionsOutput":
    """<p>Lists the sessions on a cluster. You can filter the results by session state. Newer sessions are returned first.</p>

    Args:
        cluster_id: <p>The ID of the cluster to list sessions for.</p>
        session_states: <p>An optional filter that limits the results to sessions in the specified states.</p>
        next_token: <p>The pagination token returned by a previous <code>ListSessions</code> call. Use it to retrieve the next page of results.</p>
        max_results: <p>The maximum number of sessions to return in each page of results.</p>

    Raises:
        capo_emr.errors.internal_server_exception.InternalServerException: <p>This exception occurs when there is an internal failure in the Amazon EMR service.</p>
        capo_emr.errors.invalid_request_exception.InvalidRequestException: <p>This exception occurs when there is something wrong with user input.</p>
        capo_emr.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_emr.types.list_sessions_input.ListSessionsInput]",
    ) -> AsyncOperationResponse[
        "capo_emr.types.list_sessions_output.ListSessionsOutput"
    ]:
        import capo_emr._operations.elastic_map_reduce.list_sessions

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListSessions")
    )
    input_: capo_emr.types.list_sessions_input.ListSessionsInput = {}
    if cluster_id is not None:
        input_["cluster_id"] = cluster_id
    if session_states is not None:
        input_["session_states"] = session_states
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

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