Há mais exemplos de AWS SDK disponíveis no repositório AWS Doc SDK Examples GitHub .
As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
Use UpdateDomainConfig
com um AWS SDK
Os exemplos de código a seguir mostram como usar o UpdateDomainConfig
.
Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação em contexto no seguinte exemplo de código:
- Java
-
- SDK para Java 2.x
-
/**
* Updates the configuration of a specific domain asynchronously.
* @param domainName the name of the domain to update
* @return a {@link CompletableFuture} that represents the asynchronous operation of updating the domain configuration
*/
public CompletableFuture<UpdateDomainConfigResponse> updateSpecificDomainAsync(String domainName) {
ClusterConfig clusterConfig = ClusterConfig.builder()
.instanceCount(3)
.build();
UpdateDomainConfigRequest updateDomainConfigRequest = UpdateDomainConfigRequest.builder()
.domainName(domainName)
.clusterConfig(clusterConfig)
.build();
return getAsyncClient().updateDomainConfig(updateDomainConfigRequest)
.whenComplete((response, exception) -> {
if (exception != null) {
throw new RuntimeException("Failed to update the domain configuration", exception);
}
// Handle success if needed (e.g., logging or additional actions)
});
}
- Kotlin
-
- SDK para Kotlin
-
suspend fun updateSpecificDomain(domainNameVal: String?) {
val clusterConfigOb =
ClusterConfig {
instanceCount = 3
}
val request =
UpdateDomainConfigRequest {
domainName = domainNameVal
clusterConfig = clusterConfigOb
}
println("Sending domain update request...")
OpenSearchClient { region = "us-east-1" }.use { searchClient ->
val updateResponse = searchClient.updateDomainConfig(request)
println("Domain update response from Amazon OpenSearch Service:")
println(updateResponse.toString())
}
}