Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK または CLI DescribeJobs
で を使用する
次のサンプルコードは、DescribeJobs
を使用する方法を説明しています。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- CLI
-
- AWS CLI
-
ジョブについて記述する方法
次の describe-jobs
の例では、指定されたジョブ ID を持つジョブを記述します。
aws batch describe-jobs \
--jobs bcf0b186-a532-4122-842e-2ccab8d54efb
出力:
{
"jobs": [
{
"status": "SUBMITTED",
"container": {
"mountPoints": [],
"image": "busybox",
"environment": [],
"vcpus": 1,
"command": [
"sleep",
"60"
],
"volumes": [],
"memory": 128,
"ulimits": []
},
"parameters": {},
"jobDefinition": "arn:aws:batch:us-east-1:012345678910:job-definition/sleep60:1",
"jobQueue": "arn:aws:batch:us-east-1:012345678910:job-queue/HighPriority",
"jobId": "bcf0b186-a532-4122-842e-2ccab8d54efb",
"dependsOn": [],
"jobName": "example",
"createdAt": 1480483387803
}
]
}
- Java
-
- SDK for Java 2.x
-
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
/**
* Asynchronously retrieves the status of a specific job.
*
* @param jobId the ID of the job to retrieve the status for
* @return a CompletableFuture that completes with the job status
*/
public CompletableFuture<String> describeJobAsync(String jobId) {
DescribeJobsRequest describeJobsRequest = DescribeJobsRequest.builder()
.jobs(jobId)
.build();
CompletableFuture<DescribeJobsResponse> responseFuture = getAsyncClient().describeJobs(describeJobsRequest);
return responseFuture.whenComplete((response, ex) -> {
if (ex != null) {
throw new RuntimeException("Unexpected error occurred: " + ex.getMessage(), ex);
}
}).thenApply(response -> response.jobs().get(0).status().toString());
}