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

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

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

package aws.sdk.kotlin.services.proton.waiters

import aws.sdk.kotlin.services.proton.ProtonClient
import aws.sdk.kotlin.services.proton.model.GetComponentRequest
import aws.sdk.kotlin.services.proton.model.GetComponentResponse
import aws.sdk.kotlin.services.proton.model.GetEnvironmentRequest
import aws.sdk.kotlin.services.proton.model.GetEnvironmentResponse
import aws.sdk.kotlin.services.proton.model.GetEnvironmentTemplateVersionRequest
import aws.sdk.kotlin.services.proton.model.GetEnvironmentTemplateVersionResponse
import aws.sdk.kotlin.services.proton.model.GetServiceInstanceRequest
import aws.sdk.kotlin.services.proton.model.GetServiceInstanceResponse
import aws.sdk.kotlin.services.proton.model.GetServiceRequest
import aws.sdk.kotlin.services.proton.model.GetServiceResponse
import aws.sdk.kotlin.services.proton.model.GetServiceTemplateVersionRequest
import aws.sdk.kotlin.services.proton.model.GetServiceTemplateVersionResponse
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 kotlin.time.Duration.Companion.milliseconds


/**
 * Wait until a Component is deployed. Use this after invoking CreateComponent or UpdateComponent
 */
public suspend fun ProtonClient.waitUntilComponentDeployed(request: GetComponentRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val component = it.component
            val deploymentStatus = component?.deploymentStatus?.value
            deploymentStatus == "SUCCEEDED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val component = it.component
            val deploymentStatus = component?.deploymentStatus?.value
            deploymentStatus == "FAILED"
        },
    )

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

/**
 * Wait until a Component is deployed. Use this after invoking CreateComponent or UpdateComponent
 */
public suspend fun ProtonClient.waitUntilComponentDeployed(block: GetComponentRequest.Builder.() -> Unit): Outcome =
    waitUntilComponentDeployed(GetComponentRequest.Builder().apply(block).build())

/**
 * Wait until a Component is deleted. Use this after invoking DeleteComponent
 */
public suspend fun ProtonClient.waitUntilComponentDeleted(request: GetComponentRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundException"),
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val component = it.component
            val deploymentStatus = component?.deploymentStatus?.value
            deploymentStatus == "DELETE_FAILED"
        },
    )

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

/**
 * Wait until a Component is deleted. Use this after invoking DeleteComponent
 */
public suspend fun ProtonClient.waitUntilComponentDeleted(block: GetComponentRequest.Builder.() -> Unit): Outcome =
    waitUntilComponentDeleted(GetComponentRequest.Builder().apply(block).build())

/**
 * Wait until an Environment is deployed. Use this after invoking CreateEnvironment or UpdateEnvironment
 */
public suspend fun ProtonClient.waitUntilEnvironmentDeployed(request: GetEnvironmentRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val environment = it.environment
            val deploymentStatus = environment?.deploymentStatus?.value
            deploymentStatus == "SUCCEEDED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val environment = it.environment
            val deploymentStatus = environment?.deploymentStatus?.value
            deploymentStatus == "FAILED"
        },
    )

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

/**
 * Wait until an Environment is deployed. Use this after invoking CreateEnvironment or UpdateEnvironment
 */
public suspend fun ProtonClient.waitUntilEnvironmentDeployed(block: GetEnvironmentRequest.Builder.() -> Unit): Outcome =
    waitUntilEnvironmentDeployed(GetEnvironmentRequest.Builder().apply(block).build())

/**
 * Wait until an EnvironmentTemplateVersion is registered. Use this after invoking CreateEnvironmentTemplateVersion
 */
public suspend fun ProtonClient.waitUntilEnvironmentTemplateVersionRegistered(request: GetEnvironmentTemplateVersionRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 2_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 300_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val environmentTemplateVersion = it.environmentTemplateVersion
            val status = environmentTemplateVersion?.status?.value
            status == "DRAFT"
        },
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val environmentTemplateVersion = it.environmentTemplateVersion
            val status = environmentTemplateVersion?.status?.value
            status == "PUBLISHED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val environmentTemplateVersion = it.environmentTemplateVersion
            val status = environmentTemplateVersion?.status?.value
            status == "REGISTRATION_FAILED"
        },
    )

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

/**
 * Wait until an EnvironmentTemplateVersion is registered. Use this after invoking CreateEnvironmentTemplateVersion
 */
public suspend fun ProtonClient.waitUntilEnvironmentTemplateVersionRegistered(block: GetEnvironmentTemplateVersionRequest.Builder.() -> Unit): Outcome =
    waitUntilEnvironmentTemplateVersionRegistered(GetEnvironmentTemplateVersionRequest.Builder().apply(block).build())

/**
 * Wait until an Service has deployed its instances and possibly pipeline. Use this after invoking CreateService
 */
public suspend fun ProtonClient.waitUntilServiceCreated(request: GetServiceRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val service = it.service
            val status = service?.status?.value
            status == "ACTIVE"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "CREATE_FAILED_CLEANUP_COMPLETE"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "CREATE_FAILED_CLEANUP_FAILED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "CREATE_FAILED"
        },
    )

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

/**
 * Wait until an Service has deployed its instances and possibly pipeline. Use this after invoking CreateService
 */
public suspend fun ProtonClient.waitUntilServiceCreated(block: GetServiceRequest.Builder.() -> Unit): Outcome =
    waitUntilServiceCreated(GetServiceRequest.Builder().apply(block).build())

/**
 * Wait until a Service, its instances, and possibly pipeline have been deployed after UpdateService is invoked
 */
public suspend fun ProtonClient.waitUntilServiceUpdated(request: GetServiceRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val service = it.service
            val status = service?.status?.value
            status == "ACTIVE"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "UPDATE_FAILED_CLEANUP_COMPLETE"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "UPDATE_FAILED_CLEANUP_FAILED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "UPDATE_FAILED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "UPDATE_COMPLETE_CLEANUP_FAILED"
        },
    )

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

/**
 * Wait until a Service, its instances, and possibly pipeline have been deployed after UpdateService is invoked
 */
public suspend fun ProtonClient.waitUntilServiceUpdated(block: GetServiceRequest.Builder.() -> Unit): Outcome =
    waitUntilServiceUpdated(GetServiceRequest.Builder().apply(block).build())

/**
 * Wait until a Service, its instances, and possibly pipeline have been deleted after DeleteService is invoked
 */
public suspend fun ProtonClient.waitUntilServiceDeleted(request: GetServiceRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundException"),
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val status = service?.status?.value
            status == "DELETE_FAILED"
        },
    )

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

/**
 * Wait until a Service, its instances, and possibly pipeline have been deleted after DeleteService is invoked
 */
public suspend fun ProtonClient.waitUntilServiceDeleted(block: GetServiceRequest.Builder.() -> Unit): Outcome =
    waitUntilServiceDeleted(GetServiceRequest.Builder().apply(block).build())

/**
 * Wait until an ServicePipeline is deployed. Use this after invoking CreateService or UpdateServicePipeline
 */
public suspend fun ProtonClient.waitUntilServicePipelineDeployed(request: GetServiceRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 10_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 3_600_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val service = it.service
            val pipeline = service?.pipeline
            val deploymentStatus = pipeline?.deploymentStatus?.value
            deploymentStatus == "SUCCEEDED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val service = it.service
            val pipeline = service?.pipeline
            val deploymentStatus = pipeline?.deploymentStatus?.value
            deploymentStatus == "FAILED"
        },
    )

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

/**
 * Wait until an ServicePipeline is deployed. Use this after invoking CreateService or UpdateServicePipeline
 */
public suspend fun ProtonClient.waitUntilServicePipelineDeployed(block: GetServiceRequest.Builder.() -> Unit): Outcome =
    waitUntilServicePipelineDeployed(GetServiceRequest.Builder().apply(block).build())

/**
 * Wait until a ServiceInstance is deployed. Use this after invoking CreateService or UpdateServiceInstance
 */
public suspend fun ProtonClient.waitUntilServiceInstanceDeployed(request: GetServiceInstanceRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 5_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 4_999_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val serviceInstance = it.serviceInstance
            val deploymentStatus = serviceInstance?.deploymentStatus?.value
            deploymentStatus == "SUCCEEDED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val serviceInstance = it.serviceInstance
            val deploymentStatus = serviceInstance?.deploymentStatus?.value
            deploymentStatus == "FAILED"
        },
    )

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

/**
 * Wait until a ServiceInstance is deployed. Use this after invoking CreateService or UpdateServiceInstance
 */
public suspend fun ProtonClient.waitUntilServiceInstanceDeployed(block: GetServiceInstanceRequest.Builder.() -> Unit): Outcome =
    waitUntilServiceInstanceDeployed(GetServiceInstanceRequest.Builder().apply(block).build())

/**
 * Wait until a ServiceTemplateVersion is registered. Use this after invoking CreateServiceTemplateVersion
 */
public suspend fun ProtonClient.waitUntilServiceTemplateVersionRegistered(request: GetServiceTemplateVersionRequest): Outcome {
    val strategy = StandardRetryStrategy {
        maxAttempts = 20
        tokenBucket = InfiniteTokenBucket
        delayProvider {
            initialDelay = 2_000.milliseconds
            scaleFactor = 1.5
            jitter = 1.0
            maxBackoff = 300_000.milliseconds
        }
    }

    val acceptors = listOf>(
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val serviceTemplateVersion = it.serviceTemplateVersion
            val status = serviceTemplateVersion?.status?.value
            status == "DRAFT"
        },
        OutputAcceptor(RetryDirective.TerminateAndSucceed) {
            val serviceTemplateVersion = it.serviceTemplateVersion
            val status = serviceTemplateVersion?.status?.value
            status == "PUBLISHED"
        },
        OutputAcceptor(RetryDirective.TerminateAndFail) {
            val serviceTemplateVersion = it.serviceTemplateVersion
            val status = serviceTemplateVersion?.status?.value
            status == "REGISTRATION_FAILED"
        },
    )

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

/**
 * Wait until a ServiceTemplateVersion is registered. Use this after invoking CreateServiceTemplateVersion
 */
public suspend fun ProtonClient.waitUntilServiceTemplateVersionRegistered(block: GetServiceTemplateVersionRequest.Builder.() -> Unit): Outcome =
    waitUntilServiceTemplateVersionRegistered(GetServiceTemplateVersionRequest.Builder().apply(block).build())




© 2015 - 2025 Weber Informatics LLC | Privacy Policy