commonMain.aws.sdk.kotlin.services.autoscalingplans.DefaultAutoScalingPlansClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of autoscalingplans-jvm Show documentation
Show all versions of autoscalingplans-jvm Show documentation
The AWS SDK for Kotlin client for Auto Scaling Plans
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.autoscalingplans
import aws.sdk.kotlin.runtime.client.AwsClientOption
import aws.sdk.kotlin.runtime.http.ApiMetadata
import aws.sdk.kotlin.runtime.http.AwsUserAgentMetadata
import aws.sdk.kotlin.runtime.http.middleware.AwsRetryHeaderMiddleware
import aws.sdk.kotlin.runtime.http.middleware.RecursionDetection
import aws.sdk.kotlin.runtime.http.middleware.UserAgent
import aws.sdk.kotlin.runtime.protocol.json.AwsJsonProtocol
import aws.sdk.kotlin.services.autoscalingplans.endpoints.internal.ResolveEndpoint
import aws.sdk.kotlin.services.autoscalingplans.endpoints.internal.bindAwsBuiltins
import aws.sdk.kotlin.services.autoscalingplans.model.*
import aws.sdk.kotlin.services.autoscalingplans.model.CreateScalingPlanRequest
import aws.sdk.kotlin.services.autoscalingplans.model.DeleteScalingPlanRequest
import aws.sdk.kotlin.services.autoscalingplans.model.DescribeScalingPlanResourcesRequest
import aws.sdk.kotlin.services.autoscalingplans.model.DescribeScalingPlansRequest
import aws.sdk.kotlin.services.autoscalingplans.model.GetScalingPlanResourceForecastDataRequest
import aws.sdk.kotlin.services.autoscalingplans.model.UpdateScalingPlanRequest
import aws.sdk.kotlin.services.autoscalingplans.transform.*
import aws.smithy.kotlin.runtime.auth.awssigning.AwsHttpSigner
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigningAttributes
import aws.smithy.kotlin.runtime.client.SdkClientOption
import aws.smithy.kotlin.runtime.http.SdkHttpClient
import aws.smithy.kotlin.runtime.http.operation.SdkHttpOperation
import aws.smithy.kotlin.runtime.http.operation.context
import aws.smithy.kotlin.runtime.http.operation.roundTrip
import aws.smithy.kotlin.runtime.http.operation.sdkRequestId
import aws.smithy.kotlin.runtime.io.SdkManagedGroup
import aws.smithy.kotlin.runtime.io.addIfManaged
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.tracing.withRootTraceSpan
import aws.smithy.kotlin.runtime.util.putIfAbsent
import kotlin.coroutines.coroutineContext
public const val ServiceId: String = "Auto Scaling Plans"
public const val ServiceApiVersion: String = "2018-01-06"
public const val SdkVersion: String = "0.20.2-beta"
internal class DefaultAutoScalingPlansClient(override val config: AutoScalingPlansClient.Config) : AutoScalingPlansClient {
private val managedResources = SdkManagedGroup()
private val client = SdkHttpClient(config.httpClientEngine)
init {
managedResources.addIfManaged(config.httpClientEngine)
managedResources.addIfManaged(config.credentialsProvider)
}
private val awsUserAgentMetadata = AwsUserAgentMetadata.fromEnvironment(ApiMetadata(ServiceId, SdkVersion))
/**
* Creates a scaling plan.
*/
override suspend fun createScalingPlan(input: CreateScalingPlanRequest): CreateScalingPlanResponse {
val op = SdkHttpOperation.build {
serializer = CreateScalingPlanOperationSerializer()
deserializer = CreateScalingPlanOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "CreateScalingPlan"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("CreateScalingPlan-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
/**
* Deletes the specified scaling plan.
*
* Deleting a scaling plan deletes the underlying ScalingInstruction for all of the scalable resources that are covered by the plan.
*
* If the plan has launched resources or has scaling activities in progress, you must delete those resources separately.
*/
override suspend fun deleteScalingPlan(input: DeleteScalingPlanRequest): DeleteScalingPlanResponse {
val op = SdkHttpOperation.build {
serializer = DeleteScalingPlanOperationSerializer()
deserializer = DeleteScalingPlanOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "DeleteScalingPlan"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("DeleteScalingPlan-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
/**
* Describes the scalable resources in the specified scaling plan.
*/
override suspend fun describeScalingPlanResources(input: DescribeScalingPlanResourcesRequest): DescribeScalingPlanResourcesResponse {
val op = SdkHttpOperation.build {
serializer = DescribeScalingPlanResourcesOperationSerializer()
deserializer = DescribeScalingPlanResourcesOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "DescribeScalingPlanResources"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("DescribeScalingPlanResources-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
/**
* Describes one or more of your scaling plans.
*/
override suspend fun describeScalingPlans(input: DescribeScalingPlansRequest): DescribeScalingPlansResponse {
val op = SdkHttpOperation.build {
serializer = DescribeScalingPlansOperationSerializer()
deserializer = DescribeScalingPlansOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "DescribeScalingPlans"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("DescribeScalingPlans-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
/**
* Retrieves the forecast data for a scalable resource.
*
* Capacity forecasts are represented as predicted values, or data points, that are calculated using historical data points from a specified CloudWatch load metric. Data points are available for up to 56 days.
*/
override suspend fun getScalingPlanResourceForecastData(input: GetScalingPlanResourceForecastDataRequest): GetScalingPlanResourceForecastDataResponse {
val op = SdkHttpOperation.build {
serializer = GetScalingPlanResourceForecastDataOperationSerializer()
deserializer = GetScalingPlanResourceForecastDataOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "GetScalingPlanResourceForecastData"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("GetScalingPlanResourceForecastData-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
/**
* Updates the specified scaling plan.
*
* You cannot update a scaling plan if it is in the process of being created, updated, or deleted.
*/
override suspend fun updateScalingPlan(input: UpdateScalingPlanRequest): UpdateScalingPlanResponse {
val op = SdkHttpOperation.build {
serializer = UpdateScalingPlanOperationSerializer()
deserializer = UpdateScalingPlanOperationDeserializer()
context {
expectedHttpStatus = 200
service = serviceName
operationName = "UpdateScalingPlan"
}
}
op.execution.retryStrategy = config.retryStrategy
op.execution.retryPolicy = config.retryPolicy
mergeServiceDefaults(op.context)
op.interceptors.add(ResolveEndpoint(config.endpointProvider) {
bindAwsBuiltins(config)
})
op.install(AwsRetryHeaderMiddleware())
op.install(AwsJsonProtocol("AnyScaleScalingPlannerFrontendService", "1.1"))
op.install(UserAgent(awsUserAgentMetadata))
op.install(RecursionDetection())
op.execution.signer = AwsHttpSigner {
this.signer = config.signer
this.credentialsProvider = config.credentialsProvider
this.service = "autoscaling-plans"
}
op.interceptors.addAll(config.interceptors)
val rootSpan = config.tracer.createRootSpan("UpdateScalingPlan-${op.context.sdkRequestId}")
return coroutineContext.withRootTraceSpan(rootSpan) {
op.roundTrip(client, input)
}
}
override fun close() {
managedResources.unshareAll()
}
/**
* merge the defaults configured for the service into the execution context before firing off a request
*/
private suspend fun mergeServiceDefaults(ctx: ExecutionContext) {
ctx.putIfAbsent(AwsClientOption.Region, config.region)
ctx.putIfAbsent(SdkClientOption.ServiceName, serviceName)
ctx.putIfAbsent(SdkClientOption.LogMode, config.sdkLogMode)
ctx.putIfAbsent(AwsSigningAttributes.SigningService, "autoscaling-plans")
ctx.putIfAbsent(AwsSigningAttributes.Signer, config.signer)
ctx.putIfAbsent(AwsSigningAttributes.SigningRegion, config.region)
ctx.putIfAbsent(AwsSigningAttributes.CredentialsProvider, config.credentialsProvider)
}
}