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

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

The newest version!
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.databasemigrationservice.waiters

import aws.sdk.kotlin.services.databasemigrationservice.DatabaseMigrationClient
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeConnectionsRequest
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeConnectionsResponse
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeEndpointsRequest
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeEndpointsResponse
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeReplicationInstancesRequest
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeReplicationInstancesResponse
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeReplicationTasksRequest
import aws.sdk.kotlin.services.databasemigrationservice.model.DescribeReplicationTasksResponse
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.util.flattenIfPossible
import kotlin.time.Duration.Companion.milliseconds


/**
 * Wait until testing connection succeeds.
 */
public suspend fun DatabaseMigrationClient.waitUntilTestConnectionSucceeds(request: DescribeConnectionsRequest = DescribeConnectionsRequest { }): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 120_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val connections = it.connections
            val connectionsOrEmpty = connections?.flattenIfPossible()
            val projection = connectionsOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            !(projection as List).isNullOrEmpty() && projection.all { it == "successful" }
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val connections = it.connections
            val connectionsOrEmpty = connections?.flattenIfPossible()
            val projection = connectionsOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "failed" } ?: false
        },
    )

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

/**
 * Wait until testing connection succeeds.
 */
public suspend fun DatabaseMigrationClient.waitUntilTestConnectionSucceeds(block: DescribeConnectionsRequest.Builder.() -> Unit): Outcome =
    waitUntilTestConnectionSucceeds(DescribeConnectionsRequest.Builder().apply(block).build())

/**
 * Wait until testing endpoint is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilEndpointDeleted(request: DescribeEndpointsRequest = DescribeEndpointsRequest { }): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 120_000.milliseconds
        }
    }

    val acceptors = listOf>(
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundFault"),
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val endpoints = it.endpoints
            val endpointsOrEmpty = endpoints?.flattenIfPossible()
            val projection = endpointsOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "active" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val endpoints = it.endpoints
            val endpointsOrEmpty = endpoints?.flattenIfPossible()
            val projection = endpointsOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "creating" } ?: false
        },
    )

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

/**
 * Wait until testing endpoint is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilEndpointDeleted(block: DescribeEndpointsRequest.Builder.() -> Unit): Outcome =
    waitUntilEndpointDeleted(DescribeEndpointsRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication instance is available.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationInstanceAvailable(request: DescribeReplicationInstancesRequest = DescribeReplicationInstancesRequest { }): 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 replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            !(projection as List).isNullOrEmpty() && projection.all { it == "available" }
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            (projection as List?)?.any { it == "deleting" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            (projection as List?)?.any { it == "incompatible-credentials" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            (projection as List?)?.any { it == "incompatible-network" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            (projection as List?)?.any { it == "inaccessible-encryption-credentials" } ?: false
        },
    )

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

/**
 * Wait until DMS replication instance is available.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationInstanceAvailable(block: DescribeReplicationInstancesRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationInstanceAvailable(DescribeReplicationInstancesRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication instance is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationInstanceDeleted(request: DescribeReplicationInstancesRequest = DescribeReplicationInstancesRequest { }): 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.TerminateAndFail) {
            val replicationInstances = it.replicationInstances
            val replicationInstancesOrEmpty = replicationInstances?.flattenIfPossible()
            val projection = replicationInstancesOrEmpty?.flatMap {
                val replicationInstanceStatus = it?.replicationInstanceStatus
                listOfNotNull(replicationInstanceStatus)
            }
            (projection as List?)?.any { it == "available" } ?: false
        },
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundFault"),
    )

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

/**
 * Wait until DMS replication instance is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationInstanceDeleted(block: DescribeReplicationInstancesRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationInstanceDeleted(DescribeReplicationInstancesRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication task is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskDeleted(request: DescribeReplicationTasksRequest = DescribeReplicationTasksRequest { }): 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.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "ready" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "creating" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "stopped" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "running" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "failed" } ?: false
        },
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundFault"),
    )

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

/**
 * Wait until DMS replication task is deleted.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskDeleted(block: DescribeReplicationTasksRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationTaskDeleted(DescribeReplicationTasksRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication task is ready.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskReady(request: DescribeReplicationTasksRequest = DescribeReplicationTasksRequest { }): 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 replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            !(projection as List).isNullOrEmpty() && projection.all { it == "ready" }
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "starting" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "running" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "stopping" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "stopped" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "failed" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "modifying" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "testing" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "deleting" } ?: false
        },
    )

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

/**
 * Wait until DMS replication task is ready.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskReady(block: DescribeReplicationTasksRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationTaskReady(DescribeReplicationTasksRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication task is running.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskRunning(request: DescribeReplicationTasksRequest = DescribeReplicationTasksRequest { }): 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 replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            !(projection as List).isNullOrEmpty() && projection.all { it == "running" }
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "ready" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "creating" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "stopping" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "stopped" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "failed" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "modifying" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "testing" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "deleting" } ?: false
        },
    )

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

/**
 * Wait until DMS replication task is running.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskRunning(block: DescribeReplicationTasksRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationTaskRunning(DescribeReplicationTasksRequest.Builder().apply(block).build())

/**
 * Wait until DMS replication task is stopped.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskStopped(request: DescribeReplicationTasksRequest = DescribeReplicationTasksRequest { }): 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 replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            !(projection as List).isNullOrEmpty() && projection.all { it == "stopped" }
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "ready" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "creating" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "starting" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "failed" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "modifying" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "testing" } ?: false
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val replicationTasks = it.replicationTasks
            val replicationTasksOrEmpty = replicationTasks?.flattenIfPossible()
            val projection = replicationTasksOrEmpty?.flatMap {
                val status = it?.status
                listOfNotNull(status)
            }
            (projection as List?)?.any { it == "deleting" } ?: false
        },
    )

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

/**
 * Wait until DMS replication task is stopped.
 */
public suspend fun DatabaseMigrationClient.waitUntilReplicationTaskStopped(block: DescribeReplicationTasksRequest.Builder.() -> Unit): Outcome =
    waitUntilReplicationTaskStopped(DescribeReplicationTasksRequest.Builder().apply(block).build())




© 2015 - 2025 Weber Informatics LLC | Privacy Policy