All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.elasticbeanstalk.waiters.Waiters.kt Maven / Gradle / Ivy

There is a newer version: 1.3.31
Show newest version
// 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())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy