Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 AWS
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK DescribeDomainで を使用する
次の例は、DescribeDomain を使用する方法を説明しています。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- Java
-
- SDK for Java 2.x
-
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。
/**
* Describes the specified domain asynchronously.
*
* @param domainName the name of the domain to describe
* @return a {@link CompletableFuture} that completes with the ARN of the domain
* @throws RuntimeException if the domain description fails
*/
public CompletableFuture<String> describeDomainAsync(String domainName) {
DescribeDomainRequest request = DescribeDomainRequest.builder()
.domainName(domainName)
.build();
return getAsyncClient().describeDomain(request)
.handle((response, exception) -> { // Handle both response and exception
if (exception != null) {
throw new RuntimeException("Failed to describe domain", exception);
}
DomainStatus domainStatus = response.domainStatus();
String endpoint = domainStatus.endpoint();
String arn = domainStatus.arn();
String engineVersion = domainStatus.engineVersion();
logger.info("Domain endpoint is: " + endpoint);
logger.info("ARN: " + arn);
System.out.println("Engine version: " + engineVersion);
return arn; // Return ARN when successful
});
}