Skip to content

terminate_session

terminate_session(
    *,
    config_overrides: Optional[EMRClientConfig] = None,
    cluster_id: Optional[ClusterId] = None,
    session_id: Optional[SessionId] = None,
) -> TerminateSessionOutput

Terminates an active session. After you call this operation, the session enters the TERMINATING state and then transitions to TERMINATED.

Parameters:

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

    The ID of the cluster that the session belongs to.

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

    The ID of the session to terminate.

Raises:

Source code in docs_src/capo_emr/_services/emr.py
def terminate_session(
    self,
    *,
    config_overrides: Optional[EMRClientConfig] = None,
    cluster_id: Optional["capo_emr.types.cluster_id.ClusterId"] = None,
    session_id: Optional["capo_emr.types.session_id.SessionId"] = None,
) -> "capo_emr.types.terminate_session_output.TerminateSessionOutput":
    """<p>Terminates an active session. After you call this operation, the session enters the <code>TERMINATING</code> state and then transitions to <code>TERMINATED</code>.</p>

    Args:
        cluster_id: <p>The ID of the cluster that the session belongs to.</p>
        session_id: <p>The ID of the session to terminate.</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.
    """

    def _handler(
        req: "OperationRequest[capo_emr.types.terminate_session_input.TerminateSessionInput]",
    ) -> OperationResponse[
        "capo_emr.types.terminate_session_output.TerminateSessionOutput"
    ]:
        import capo_emr._operations.elastic_map_reduce.terminate_session

        output, http_response = (
            capo_emr._operations.elastic_map_reduce.terminate_session.terminate_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("TerminateSession")
    )
    input_: capo_emr.types.terminate_session_input.TerminateSessionInput = {}
    if cluster_id is not None:
        input_["cluster_id"] = cluster_id
    if session_id is not None:
        input_["session_id"] = session_id

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