commonMain.aws.sdk.kotlin.services.deadline.waiters.Waiters.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deadline-jvm Show documentation
Show all versions of deadline-jvm Show documentation
The AWS SDK for Kotlin client for deadline
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.deadline.waiters
import aws.sdk.kotlin.services.deadline.DeadlineClient
import aws.sdk.kotlin.services.deadline.model.GetFleetRequest
import aws.sdk.kotlin.services.deadline.model.GetFleetResponse
import aws.sdk.kotlin.services.deadline.model.GetJobRequest
import aws.sdk.kotlin.services.deadline.model.GetJobResponse
import aws.sdk.kotlin.services.deadline.model.GetLicenseEndpointRequest
import aws.sdk.kotlin.services.deadline.model.GetLicenseEndpointResponse
import aws.sdk.kotlin.services.deadline.model.GetQueueFleetAssociationRequest
import aws.sdk.kotlin.services.deadline.model.GetQueueFleetAssociationResponse
import aws.sdk.kotlin.services.deadline.model.GetQueueRequest
import aws.sdk.kotlin.services.deadline.model.GetQueueResponse
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 Fleet is activated. Use this after invoking CreateFleet or UpdateFleet.
*/
public suspend fun DeadlineClient.waitUntilFleetActive(request: GetFleetRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 5_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 900_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "ACTIVE"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val status = it.status?.value
status == "CREATE_FAILED"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val status = it.status?.value
status == "UPDATE_FAILED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getFleet(request) }
}
/**
* Wait until a Fleet is activated. Use this after invoking CreateFleet or UpdateFleet.
*/
public suspend fun DeadlineClient.waitUntilFleetActive(block: GetFleetRequest.Builder.() -> Unit): Outcome =
waitUntilFleetActive(GetFleetRequest.Builder().apply(block).build())
/**
* Wait until a Job is created. Use this after invoking CreateJob.
*/
public suspend fun DeadlineClient.waitUntilJobCreateComplete(request: GetJobRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 1_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 120_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "CREATE_COMPLETE"
},
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "UPDATE_IN_PROGRESS"
},
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "UPDATE_FAILED"
},
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "UPDATE_SUCCEEDED"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "UPLOAD_FAILED"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val lifecycleStatus = it.lifecycleStatus?.value
lifecycleStatus == "CREATE_FAILED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getJob(request) }
}
/**
* Wait until a Job is created. Use this after invoking CreateJob.
*/
public suspend fun DeadlineClient.waitUntilJobCreateComplete(block: GetJobRequest.Builder.() -> Unit): Outcome =
waitUntilJobCreateComplete(GetJobRequest.Builder().apply(block).build())
/**
* Wait until a LicenseEndpoint is Ready. Use this after invoking CreateLicenseEndpoint.
*/
public suspend fun DeadlineClient.waitUntilLicenseEndpointValid(request: GetLicenseEndpointRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 1_140_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "READY"
},
OutputAcceptor(RetryDirective.TerminateAndFail) {
val status = it.status?.value
status == "NOT_READY"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getLicenseEndpoint(request) }
}
/**
* Wait until a LicenseEndpoint is Ready. Use this after invoking CreateLicenseEndpoint.
*/
public suspend fun DeadlineClient.waitUntilLicenseEndpointValid(block: GetLicenseEndpointRequest.Builder.() -> Unit): Outcome =
waitUntilLicenseEndpointValid(GetLicenseEndpointRequest.Builder().apply(block).build())
/**
* Wait until a LicenseEndpoint is Deleted. Use this after invoking DeleteLicenseEndpoint.
*/
public suspend fun DeadlineClient.waitUntilLicenseEndpointDeleted(request: GetLicenseEndpointRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 2_340_000.milliseconds
}
}
val acceptors = listOf>(
ErrorTypeAcceptor(RetryDirective.TerminateAndSucceed, "ResourceNotFoundException"),
OutputAcceptor(RetryDirective.TerminateAndFail) {
val status = it.status?.value
status == "NOT_READY"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getLicenseEndpoint(request) }
}
/**
* Wait until a LicenseEndpoint is Deleted. Use this after invoking DeleteLicenseEndpoint.
*/
public suspend fun DeadlineClient.waitUntilLicenseEndpointDeleted(block: GetLicenseEndpointRequest.Builder.() -> Unit): Outcome =
waitUntilLicenseEndpointDeleted(GetLicenseEndpointRequest.Builder().apply(block).build())
public suspend fun DeadlineClient.waitUntilQueueSchedulingBlocked(request: GetQueueRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 300_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "SCHEDULING_BLOCKED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getQueue(request) }
}
public suspend fun DeadlineClient.waitUntilQueueSchedulingBlocked(block: GetQueueRequest.Builder.() -> Unit): Outcome =
waitUntilQueueSchedulingBlocked(GetQueueRequest.Builder().apply(block).build())
public suspend fun DeadlineClient.waitUntilQueueScheduling(request: GetQueueRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 700_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "SCHEDULING"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getQueue(request) }
}
public suspend fun DeadlineClient.waitUntilQueueScheduling(block: GetQueueRequest.Builder.() -> Unit): Outcome =
waitUntilQueueScheduling(GetQueueRequest.Builder().apply(block).build())
/**
* Wait until a QueueFleetAssociation is stopped. Use this after setting the status to STOP_SCHEDULING_AND_COMPLETE_TASKS or STOP_SCHEDULING_AND_CANCEL_TASKS to wait for a QueueFleetAssociation to reach STOPPED
*/
public suspend fun DeadlineClient.waitUntilQueueFleetAssociationStopped(request: GetQueueFleetAssociationRequest): Outcome {
val strategy = StandardRetryStrategy {
maxAttempts = 20
tokenBucket = InfiniteTokenBucket
delayProvider {
initialDelay = 10_000.milliseconds
scaleFactor = 1.5
jitter = 1.0
maxBackoff = 600_000.milliseconds
}
}
val acceptors = listOf>(
OutputAcceptor(RetryDirective.TerminateAndSucceed) {
val status = it.status?.value
status == "STOPPED"
},
)
val policy = AcceptorRetryPolicy(request, acceptors)
return strategy.retry(policy) { getQueueFleetAssociation(request) }
}
/**
* Wait until a QueueFleetAssociation is stopped. Use this after setting the status to STOP_SCHEDULING_AND_COMPLETE_TASKS or STOP_SCHEDULING_AND_CANCEL_TASKS to wait for a QueueFleetAssociation to reach STOPPED
*/
public suspend fun DeadlineClient.waitUntilQueueFleetAssociationStopped(block: GetQueueFleetAssociationRequest.Builder.() -> Unit): Outcome =
waitUntilQueueFleetAssociationStopped(GetQueueFleetAssociationRequest.Builder().apply(block).build())