Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWS SDK와 DescribeDomain 함께 사용
다음 코드 예시는 DescribeDomain의 사용 방법을 보여 줍니다.
작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서 컨텍스트 내 이 작업을 확인할 수 있습니다.
- Java
-
- SDK for Java 2.x
-
/**
* 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
});
}