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

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

There is a newer version: 1.3.79
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.ssmincidents.waiters

import aws.sdk.kotlin.services.ssmincidents.SsmIncidentsClient
import aws.sdk.kotlin.services.ssmincidents.model.GetReplicationSetRequest
import aws.sdk.kotlin.services.ssmincidents.model.GetReplicationSetResponse
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.ErrorTypeAcceptor
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 kotlin.time.Duration.Companion.milliseconds


/**
 * Wait for a replication set to become ACTIVE
 */
public suspend fun SsmIncidentsClient.waitForReplicationSetActive(request: GetReplicationSetRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 30_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 30_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "ACTIVE"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "CREATING"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "UPDATING"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "FAILED"
        },
    )

    val policy = AcceptorRetryPolicy(request, acceptors)
    return strategy.retry(policy) { getReplicationSet(request) }
}

/**
 * Wait for a replication set to become ACTIVE
 */
public suspend fun SsmIncidentsClient.waitForReplicationSetActive(block: GetReplicationSetRequest.Builder.() -> Unit): Outcome =
    waitForReplicationSetActive(GetReplicationSetRequest.Builder().apply(block).build())

/**
 * Wait for a replication set to be deleted
 */
public suspend fun SsmIncidentsClient.waitForReplicationSetDeleted(request: GetReplicationSetRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 30_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 30_000.milliseconds
        }
    }

    val acceptors = listOf>(
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundException"),
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "DELETING"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationSet = it.replicationSet
            val status = replicationSet?.status?.value
            status == "FAILED"
        },
    )

    val policy = AcceptorRetryPolicy(request, acceptors)
    return strategy.retry(policy) { getReplicationSet(request) }
}

/**
 * Wait for a replication set to be deleted
 */
public suspend fun SsmIncidentsClient.waitForReplicationSetDeleted(block: GetReplicationSetRequest.Builder.() -> Unit): Outcome =
    waitForReplicationSetDeleted(GetReplicationSetRequest.Builder().apply(block).build())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy