Terminates a job in a job queue. Jobs that are in the STARTING or RUNNING state are terminated, which causes them to transition to FAILED. Jobs that have not progressed to the STARTING state are cancelled.
Parameters:
-
job_id
(Optional[String], default:
None
)
–
The Batch job ID of the job to terminate.
-
reason
(Optional[String], default:
None
)
–
A message to attach to the job that explains the reason for terminating it. This message is returned by future DescribeJobs operations on the job. It is also recorded in the Batch activity logs.
This parameter has a limit of 1024 characters.
Raises:
-
ClientException
–
These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.
-
ServerException
–
These errors are usually caused by a server issue.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
To terminate a job
This example terminates a job with the specified job ID.
>>> client.terminate_job(reason='Terminating job.', job_id='61e743ed-35e4-48da-b2de-5c8333821c84')
Source code in docs_src/capo_batch/_services/batch.py
| def terminate_job(
self,
*,
config_overrides: Optional[BatchClientConfig] = None,
job_id: Optional["capo_batch.types.string.String"] = None,
reason: Optional["capo_batch.types.string.String"] = None,
) -> "capo_batch.types.terminate_job_response.TerminateJobResponse":
"""<p>Terminates a job in a job queue. Jobs that are in the <code>STARTING</code> or <code>RUNNING</code> state are terminated, which causes them to transition to <code>FAILED</code>. Jobs that have not progressed to the <code>STARTING</code> state are cancelled.</p>
Args:
job_id: <p>The Batch job ID of the job to terminate.</p>
reason: <p>A message to attach to the job that explains the reason for terminating it. This message is returned by future <a>DescribeJobs</a> operations on the job. It is also recorded in the Batch activity logs.</p> <p>This parameter has a limit of 1024 characters.</p>
Raises:
capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To terminate a job
This example terminates a job with the specified job ID.
>>> client.terminate_job(reason='Terminating job.', job_id='61e743ed-35e4-48da-b2de-5c8333821c84')
"""
def _handler(
req: "OperationRequest[capo_batch.types.terminate_job_request.TerminateJobRequest]",
) -> OperationResponse[
"capo_batch.types.terminate_job_response.TerminateJobResponse"
]:
import capo_batch._operations.aws_batch_v20160810.terminate_job
output, http_response = (
capo_batch._operations.aws_batch_v20160810.terminate_job.terminate_job(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("TerminateJob")
)
input_: capo_batch.types.terminate_job_request.TerminateJobRequest = {}
if job_id is not None:
input_["job_id"] = job_id
if reason is not None:
input_["reason"] = reason
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|