commonMain.aws.sdk.kotlin.services.elasticbeanstalk.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticbeanstalk-jvm Show documentation
Show all versions of elasticbeanstalk-jvm Show documentation
The AWS SDK for Kotlin client for Elastic Beanstalk
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.elasticbeanstalk.waiters
import aws.sdk.kotlin.services.elasticbeanstalk.ElasticBeanstalkClient
import aws.sdk.kotlin.services.elasticbeanstalk.model.DescribeEnvironmentsRequest
import aws.sdk.kotlin.services.elasticbeanstalk.model.DescribeEnvironmentsResponse
import aws.smithy.kotlin.runtime.retries.Outcome
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy
import aws.smithy.kotlin.runtime.retries.delay.InfiniteTokenBucket
import aws.smithy.kotlin.runtime.retries.policy.Acceptor
import aws.smithy.kotlin.runtime.retries.policy.AcceptorRetryPolicy
import aws.smithy.kotlin.runtime.retries.policy.OutputAcceptor
import aws.smithy.kotlin.runtime.retries.policy.RetryDirective
import aws.smithy.kotlin.runtime.retries.policy.RetryErrorType
import aws.smithy.kotlin.runtime.util.flattenIfPossible
import kotlin.time.Duration.Companion.milliseconds
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentExists(request: DescribeEnvironmentsRequest = DescribeEnvironmentsRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 20_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Ready" }
},
OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Launching" }
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeEnvironments(request) }
}
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentExists(block: DescribeEnvironmentsRequest.Builder.() -> Unit): Outcome =
waitUntilEnvironmentExists(DescribeEnvironmentsRequest.Builder().apply(block).build())
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentTerminated(request: DescribeEnvironmentsRequest = DescribeEnvironmentsRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 20_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Terminated" }
},
OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Terminating" }
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeEnvironments(request) }
}
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentTerminated(block: DescribeEnvironmentsRequest.Builder.() -> Unit): Outcome =
waitUntilEnvironmentTerminated(DescribeEnvironmentsRequest.Builder().apply(block).build())
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentUpdated(request: DescribeEnvironmentsRequest = DescribeEnvironmentsRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 20_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Ready" }
},
OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
val environments = it.environments
val environmentsOrEmpty = environments?.flattenIfPossible()
val projection = environmentsOrEmpty?.flatMap {
val status = it?.status?.value
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "Updating" }
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeEnvironments(request) }
}
public suspend fun ElasticBeanstalkClient.waitUntilEnvironmentUpdated(block: DescribeEnvironmentsRequest.Builder.() -> Unit): Outcome =
waitUntilEnvironmentUpdated(DescribeEnvironmentsRequest.Builder().apply(block).build())