Terminates up to 50 service jobs in a job queue. This is a bulk version of TerminateServiceJob.
Batch reports the result for each service job individually in the response. Service jobs that were processed successfully are reported in the successful list. Service jobs that encountered errors are reported in the errors list. The response returns an HTTP status code of 200 even when some service jobs encountered errors, so check the errors list. Service jobs that can't be found are treated as successfully processed.
This operation requires batch:TerminateServiceJob permission for each service job in the request. There is no separate batch:TerminateServiceJobs IAM action. If a caller's IAM policy grants batch:TerminateServiceJob, they can use both the singular TerminateServiceJob and bulk TerminateServiceJobs operations.
Parameters:
-
jobs
(Optional[StringList], default:
None
)
–
An array of up to 50 service job IDs of the service jobs to terminate.
-
reason
(Optional[String], default:
None
)
–
A message to attach to the service job that explains the reason for terminating it. This message is returned by DescribeServiceJob operations on the service job.
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 multiple service jobs
This example terminates the specified service jobs with a reason.
>>> client.terminate_service_jobs(jobs=['a4d6c728-8ee8-4c65-8e2a-9a5e8f4b7c3d', 'b3d0f26e-6d3a-4a5b-9c2e-7f4a1b2c3d4e'], reason='Job terminated by user request')
Source code in docs_src/capo_batch/_services/batch.py
| def terminate_service_jobs(
self,
*,
config_overrides: Optional[BatchClientConfig] = None,
jobs: Optional["capo_batch.types.string_list.StringList"] = None,
reason: Optional["capo_batch.types.string.String"] = None,
) -> (
"capo_batch.types.terminate_service_jobs_response.TerminateServiceJobsResponse"
):
"""<p>Terminates up to 50 service jobs in a job queue. This is a bulk version of <a>TerminateServiceJob</a>.</p> <p>Batch reports the result for each service job individually in the response. Service jobs that were processed successfully are reported in the <code>successful</code> list. Service jobs that encountered errors are reported in the <code>errors</code> list. The response returns an HTTP status code of <code>200</code> even when some service jobs encountered errors, so check the <code>errors</code> list. Service jobs that can't be found are treated as successfully processed.</p> <important> <p>This operation requires <code>batch:TerminateServiceJob</code> permission for each service job in the request. There is no separate <code>batch:TerminateServiceJobs</code> IAM action. If a caller's IAM policy grants <code>batch:TerminateServiceJob</code>, they can use both the singular <code>TerminateServiceJob</code> and bulk <code>TerminateServiceJobs</code> operations.</p> </important>
Args:
jobs: <p>An array of up to 50 service job IDs of the service jobs to terminate.</p>
reason: <p>A message to attach to the service job that explains the reason for terminating it. This message is returned by <code>DescribeServiceJob</code> operations on the service job.</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 multiple service jobs
This example terminates the specified service jobs with a reason.
>>> client.terminate_service_jobs(jobs=['a4d6c728-8ee8-4c65-8e2a-9a5e8f4b7c3d', 'b3d0f26e-6d3a-4a5b-9c2e-7f4a1b2c3d4e'], reason='Job terminated by user request')
"""
def _handler(
req: "OperationRequest[capo_batch.types.terminate_service_jobs_request.TerminateServiceJobsRequest]",
) -> OperationResponse[
"capo_batch.types.terminate_service_jobs_response.TerminateServiceJobsResponse"
]:
import capo_batch._operations.aws_batch_v20160810.terminate_service_jobs
output, http_response = (
capo_batch._operations.aws_batch_v20160810.terminate_service_jobs.terminate_service_jobs(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("TerminateServiceJobs")
)
input_: capo_batch.types.terminate_service_jobs_request.TerminateServiceJobsRequest = {}
if jobs is not None:
input_["jobs"] = jobs
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
|