Verwendung von UpdateJobStatus mit einem AWS-SDK oder CLI - AWS-SDK-Codebeispiele

Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs verfügbar.

Verwendung von UpdateJobStatus mit einem AWS-SDK oder CLI

Die folgenden Code-Beispiele zeigen, wie UpdateJobStatus verwendet wird.

Beispiele für Aktionen sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Im folgenden Codebeispiel können Sie diese Aktion im Kontext sehen:

CLI
AWS CLI

So aktualisieren Sie den Status eines Auftrags von Amazon S3 Batch Operations

Im folgenden update-job-status-Beispiel wird der angegebene Auftrag gelöscht, der auf Genehmigung wartet.

aws s3control update-job-status \ --account-id 123456789012 \ --job-id 8d9a18fe-c303-4d39-8ccc-860d372da386 \ --requested-job-status Cancelled

Ausgabe:

{ "Status": "Cancelled", "JobId": "8d9a18fe-c303-4d39-8ccc-860d372da386" }

Im folgenden update-job-status-Beispiel wird der angegebene Auftrag bestätigt und ausgeführt, der auf Genehmigung wartet.

aws s3control update-job-status \ --account-id 123456789012 \ --job-id 5782949f-3301-4fb3-be34-8d5bab54dbca \ --requested-job-status Ready Output:: { "Status": "Ready", "JobId": "5782949f-3301-4fb3-be34-8d5bab54dbca" }

Im folgenden update-job-status-Beispiel wird der angegebene Auftrag gelöscht, der bereits ausgeführt wird.

aws s3control update-job-status \ --account-id 123456789012 \ --job-id 5782949f-3301-4fb3-be34-8d5bab54dbca \ --requested-job-status Cancelled Output:: { "Status": "Cancelling", "JobId": "5782949f-3301-4fb3-be34-8d5bab54dbca" }
  • Weitere API-Informationen finden Sie unter UpdateJobStatus in der AWS CLI-Befehlsreferenz.

Java
SDK für Java 2.x
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Code-Beispiel- einrichten und ausführen.

/** * Cancels a job asynchronously. * * @param jobId The ID of the job to be canceled. * @param accountId The ID of the account associated with the job. * @return A {@link CompletableFuture} that completes when the job status has been updated to "CANCELLED". * If an error occurs during the update, the returned future will complete exceptionally. */ public CompletableFuture<Void> cancelJobAsync(String jobId, String accountId) { UpdateJobStatusRequest updateJobStatusRequest = UpdateJobStatusRequest.builder() .accountId(accountId) .jobId(jobId) .requestedJobStatus(String.valueOf(JobStatus.CANCELLED)) .build(); return asyncClient.updateJobStatus(updateJobStatusRequest) .thenAccept(updateJobStatusResponse -> { System.out.println("Job status updated to: " + updateJobStatusResponse.status()); }) .exceptionally(ex -> { System.err.println("Failed to cancel job: " + ex.getMessage()); throw new RuntimeException(ex); // Propagate the exception }); }
  • Weitere API-Informationen finden Sie unter UpdateJobStatus in der AWS SDK for Java 2.x-API-Referenz.