commonMain.aws.sdk.kotlin.services.redshift.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redshift-jvm Show documentation
Show all versions of redshift-jvm Show documentation
The AWS SDK for Kotlin client for Redshift
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.redshift.waiters
import aws.sdk.kotlin.services.redshift.RedshiftClient
import aws.sdk.kotlin.services.redshift.model.DescribeClusterSnapshotsRequest
import aws.sdk.kotlin.services.redshift.model.DescribeClusterSnapshotsResponse
import aws.sdk.kotlin.services.redshift.model.DescribeClustersRequest
import aws.sdk.kotlin.services.redshift.model.DescribeClustersResponse
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 aws.smithy.kotlin.runtime.util.flattenIfPossible
import kotlin.time.Duration.Companion.milliseconds
public suspend fun RedshiftClient.waitUntilClusterAvailable(request: DescribeClustersRequest = DescribeClustersRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 60_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val clusterStatus = it?.clusterStatus
listOfNotNull(clusterStatus)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "available" }
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val clusterStatus = it?.clusterStatus
listOfNotNull(clusterStatus)
}
(projection as List?)?.any { it == "deleting" } ?: false
},
ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "ClusterNotFound"),
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeClusters(request) }
}
public suspend fun RedshiftClient.waitUntilClusterAvailable(block: DescribeClustersRequest.Builder.() -> Unit): Outcome =
waitUntilClusterAvailable(DescribeClustersRequest.Builder().apply(block).build())
public suspend fun RedshiftClient.waitUntilClusterDeleted(request: DescribeClustersRequest = DescribeClustersRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 60_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ClusterNotFound"),
OutputAcceptor(RetryDirective.TerminateAndFail) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val clusterStatus = it?.clusterStatus
listOfNotNull(clusterStatus)
}
(projection as List?)?.any { it == "creating" } ?: false
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val clusterStatus = it?.clusterStatus
listOfNotNull(clusterStatus)
}
(projection as List?)?.any { it == "modifying" } ?: false
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeClusters(request) }
}
public suspend fun RedshiftClient.waitUntilClusterDeleted(block: DescribeClustersRequest.Builder.() -> Unit): Outcome =
waitUntilClusterDeleted(DescribeClustersRequest.Builder().apply(block).build())
public suspend fun RedshiftClient.waitUntilClusterRestored(request: DescribeClustersRequest = DescribeClustersRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 60_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val restoreStatus = it?.restoreStatus
val status = restoreStatus?.status
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "completed" }
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val clusters = it.clusters
val clustersOrEmpty = clusters?.flattenIfPossible()
val projection = clustersOrEmpty?.flatMap {
val clusterStatus = it?.clusterStatus
listOfNotNull(clusterStatus)
}
(projection as List?)?.any { it == "deleting" } ?: false
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeClusters(request) }
}
public suspend fun RedshiftClient.waitUntilClusterRestored(block: DescribeClustersRequest.Builder.() -> Unit): Outcome =
waitUntilClusterRestored(DescribeClustersRequest.Builder().apply(block).build())
public suspend fun RedshiftClient.waitUntilSnapshotAvailable(request: DescribeClusterSnapshotsRequest = DescribeClusterSnapshotsRequest { }): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 15_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val snapshots = it.snapshots
val snapshotsOrEmpty = snapshots?.flattenIfPossible()
val projection = snapshotsOrEmpty?.flatMap {
val status = it?.status
listOfNotNull(status)
}
!(projection as List).isNullOrEmpty() && projection.all { it == "available" }
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val snapshots = it.snapshots
val snapshotsOrEmpty = snapshots?.flattenIfPossible()
val projection = snapshotsOrEmpty?.flatMap {
val status = it?.status
listOfNotNull(status)
}
(projection as List?)?.any { it == "failed" } ?: false
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val snapshots = it.snapshots
val snapshotsOrEmpty = snapshots?.flattenIfPossible()
val projection = snapshotsOrEmpty?.flatMap {
val status = it?.status
listOfNotNull(status)
}
(projection as List?)?.any { it == "deleted" } ?: false
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { describeClusterSnapshots(request) }
}
public suspend fun RedshiftClient.waitUntilSnapshotAvailable(block: DescribeClusterSnapshotsRequest.Builder.() -> Unit): Outcome =
waitUntilSnapshotAvailable(DescribeClusterSnapshotsRequest.Builder().apply(block).build())