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

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

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

package aws.sdk.kotlin.services.medialive.waiters

import aws.sdk.kotlin.services.medialive.MediaLiveClient
import aws.sdk.kotlin.services.medialive.model.DescribeChannelRequest
import aws.sdk.kotlin.services.medialive.model.DescribeChannelResponse
import aws.sdk.kotlin.services.medialive.model.DescribeInputRequest
import aws.sdk.kotlin.services.medialive.model.DescribeInputResponse
import aws.sdk.kotlin.services.medialive.model.DescribeMultiplexRequest
import aws.sdk.kotlin.services.medialive.model.DescribeMultiplexResponse
import aws.smithy.kotlin.runtime.retries.Outcome
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategyOptions
import aws.smithy.kotlin.runtime.retries.delay.ExponentialBackoffWithJitter
import aws.smithy.kotlin.runtime.retries.delay.ExponentialBackoffWithJitterOptions
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 until a channel has been created
 */
public suspend fun MediaLiveClient.waitUntilChannelCreated(request: DescribeChannelRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 3_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "IDLE"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "CREATING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val state = it.state?.value
            state == "CREATE_FAILED"
        },
    )

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

/**
 * Wait until a channel has been created
 */
public suspend fun MediaLiveClient.waitUntilChannelCreated(block: DescribeChannelRequest.Builder.() -> Unit): Outcome =
    waitUntilChannelCreated(DescribeChannelRequest.Builder().apply(block).build())

/**
 * Wait until a channel has been deleted
 */
public suspend fun MediaLiveClient.waitUntilChannelDeleted(request: DescribeChannelRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "DELETED"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "DELETING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a channel has been deleted
 */
public suspend fun MediaLiveClient.waitUntilChannelDeleted(block: DescribeChannelRequest.Builder.() -> Unit): Outcome =
    waitUntilChannelDeleted(DescribeChannelRequest.Builder().apply(block).build())

/**
 * Wait until a channel is running
 */
public suspend fun MediaLiveClient.waitUntilChannelRunning(request: DescribeChannelRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "RUNNING"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "STARTING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a channel is running
 */
public suspend fun MediaLiveClient.waitUntilChannelRunning(block: DescribeChannelRequest.Builder.() -> Unit): Outcome =
    waitUntilChannelRunning(DescribeChannelRequest.Builder().apply(block).build())

/**
 * Wait until a channel has is stopped
 */
public suspend fun MediaLiveClient.waitUntilChannelStopped(request: DescribeChannelRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "IDLE"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "STOPPING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a channel has is stopped
 */
public suspend fun MediaLiveClient.waitUntilChannelStopped(block: DescribeChannelRequest.Builder.() -> Unit): Outcome =
    waitUntilChannelStopped(DescribeChannelRequest.Builder().apply(block).build())

/**
 * Wait until an input has been attached
 */
public suspend fun MediaLiveClient.waitUntilInputAttached(request: DescribeInputRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "ATTACHED"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "DETACHED"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until an input has been attached
 */
public suspend fun MediaLiveClient.waitUntilInputAttached(block: DescribeInputRequest.Builder.() -> Unit): Outcome =
    waitUntilInputAttached(DescribeInputRequest.Builder().apply(block).build())

/**
 * Wait until an input has been deleted
 */
public suspend fun MediaLiveClient.waitUntilInputDeleted(request: DescribeInputRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "DELETED"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "DELETING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until an input has been deleted
 */
public suspend fun MediaLiveClient.waitUntilInputDeleted(block: DescribeInputRequest.Builder.() -> Unit): Outcome =
    waitUntilInputDeleted(DescribeInputRequest.Builder().apply(block).build())

/**
 * Wait until an input has been detached
 */
public suspend fun MediaLiveClient.waitUntilInputDetached(request: DescribeInputRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "DETACHED"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "CREATING"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "ATTACHED"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until an input has been detached
 */
public suspend fun MediaLiveClient.waitUntilInputDetached(block: DescribeInputRequest.Builder.() -> Unit): Outcome =
    waitUntilInputDetached(DescribeInputRequest.Builder().apply(block).build())

/**
 * Wait until a multiplex has been created
 */
public suspend fun MediaLiveClient.waitUntilMultiplexCreated(request: DescribeMultiplexRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 3_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "IDLE"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "CREATING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val state = it.state?.value
            state == "CREATE_FAILED"
        },
    )

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

/**
 * Wait until a multiplex has been created
 */
public suspend fun MediaLiveClient.waitUntilMultiplexCreated(block: DescribeMultiplexRequest.Builder.() -> Unit): Outcome =
    waitUntilMultiplexCreated(DescribeMultiplexRequest.Builder().apply(block).build())

/**
 * Wait until a multiplex has been deleted
 */
public suspend fun MediaLiveClient.waitUntilMultiplexDeleted(request: DescribeMultiplexRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "DELETED"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "DELETING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a multiplex has been deleted
 */
public suspend fun MediaLiveClient.waitUntilMultiplexDeleted(block: DescribeMultiplexRequest.Builder.() -> Unit): Outcome =
    waitUntilMultiplexDeleted(DescribeMultiplexRequest.Builder().apply(block).build())

/**
 * Wait until a multiplex is running
 */
public suspend fun MediaLiveClient.waitUntilMultiplexRunning(request: DescribeMultiplexRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "RUNNING"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "STARTING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a multiplex is running
 */
public suspend fun MediaLiveClient.waitUntilMultiplexRunning(block: DescribeMultiplexRequest.Builder.() -> Unit): Outcome =
    waitUntilMultiplexRunning(DescribeMultiplexRequest.Builder().apply(block).build())

/**
 * Wait until a multiplex has is stopped
 */
public suspend fun MediaLiveClient.waitUntilMultiplexStopped(request: DescribeMultiplexRequest): Outcome {
    val strategy = run {
        val delayOptions = ExponentialBackoffWithJitterOptions(
            initialDelay = 5_000.milliseconds,
            scaleFactor = 1.5,
            jitter = 1.0,
            maxBackoff = 120_000.milliseconds,
        )
        val delay = ExponentialBackoffWithJitter(delayOptions)

        val waiterOptions = StandardRetryStrategyOptions(maxAttempts = 20)
        StandardRetryStrategy(waiterOptions, InfiniteTokenBucket, delay)
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val state = it.state?.value
            state == "IDLE"
        },
        OutputAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide)) {
            val state = it.state?.value
            state == "STOPPING"
        },
        ErrorTypeAcceptor(RetryDirective.RetryError(RetryErrorType.ServerSide), "InternalServerErrorException"),
    )

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

/**
 * Wait until a multiplex has is stopped
 */
public suspend fun MediaLiveClient.waitUntilMultiplexStopped(block: DescribeMultiplexRequest.Builder.() -> Unit): Outcome =
    waitUntilMultiplexStopped(DescribeMultiplexRequest.Builder().apply(block).build())




© 2015 - 2025 Weber Informatics LLC | Privacy Policy