There are more AWS SDK examples available in the AWS Doc SDK Examples
Use UpdateJobQueue with an AWS SDK or CLI
The following code examples show how to use UpdateJobQueue.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code examples:
- CLI
-
- AWS CLI
-
To update a job queue
The following
update-job-queueexample disables a job queue so that it can be deleted.aws batch update-job-queue \ --job-queueGPGPU\ --stateDISABLEDOutput:
{ "jobQueueArn": "arn:aws:batch:us-west-2:123456789012:job-queue/GPGPU", "jobQueueName": "GPGPU" }For more information, see Delete a job queue in AWS Batch in the AWS Batch User Guide.
-
For API details, see UpdateJobQueue
in AWS CLI Command Reference.
-
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. /** * Disables the specified job queue asynchronously. * * @param jobQueueArn the Amazon Resource Name (ARN) of the job queue to be disabled * @return a {@link CompletableFuture} that completes when the job queue update operation is complete, * or completes exceptionally if an error occurs during the operation */ public CompletableFuture<Void> disableJobQueueAsync(String jobQueueArn) { UpdateJobQueueRequest updateRequest = UpdateJobQueueRequest.builder() .jobQueue(jobQueueArn) .state(JQState.DISABLED) .build(); CompletableFuture<UpdateJobQueueResponse> responseFuture = getAsyncClient().updateJobQueue(updateRequest); return responseFuture.whenComplete((updateResponse, ex) -> { if (ex != null) { throw new RuntimeException("Failed to update job queue: " + ex.getMessage(), ex); } }).thenApply(updateResponse -> null); }-
For API details, see UpdateJobQueue in AWS SDK for Java 2.x API Reference.
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. def update_job_queue(self, job_queue: str, state: str) -> dict: """ Updates a job queue, such as disabling it before deletion. :param job_queue: The job queue name or ARN. :param state: The new state (ENABLED or DISABLED). :return: The response dictionary. """ try: response = self.batch_client.update_job_queue( jobQueue=job_queue, state=state ) logger.info("Updated job queue %s to state %s.", job_queue, state) return response except ClientError as err: logger.error( "Error updating job queue %s: %s", job_queue, err.response["Error"]["Message"], ) raise-
For API details, see UpdateJobQueue in AWS SDK for Python (Boto3) API Reference.
-