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

commonMain.aws.sdk.kotlin.services.applicationautoscaling.serde.PutScalingPolicyOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.applicationautoscaling.serde

import aws.sdk.kotlin.services.applicationautoscaling.model.PolicyType
import aws.sdk.kotlin.services.applicationautoscaling.model.PutScalingPolicyRequest
import aws.sdk.kotlin.services.applicationautoscaling.model.ScalableDimension
import aws.sdk.kotlin.services.applicationautoscaling.model.ServiceNamespace
import aws.sdk.kotlin.services.applicationautoscaling.model.StepScalingPolicyConfiguration
import aws.sdk.kotlin.services.applicationautoscaling.model.TargetTrackingScalingPolicyConfiguration
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.operation.HttpSerializer
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
import aws.smithy.kotlin.runtime.http.request.url
import aws.smithy.kotlin.runtime.operation.ExecutionContext
import aws.smithy.kotlin.runtime.serde.SdkFieldDescriptor
import aws.smithy.kotlin.runtime.serde.SdkObjectDescriptor
import aws.smithy.kotlin.runtime.serde.SerialKind
import aws.smithy.kotlin.runtime.serde.asSdkSerializable
import aws.smithy.kotlin.runtime.serde.deserializeList
import aws.smithy.kotlin.runtime.serde.deserializeMap
import aws.smithy.kotlin.runtime.serde.deserializeStruct
import aws.smithy.kotlin.runtime.serde.field
import aws.smithy.kotlin.runtime.serde.json.JsonDeserializer
import aws.smithy.kotlin.runtime.serde.json.JsonSerialName
import aws.smithy.kotlin.runtime.serde.json.JsonSerializer
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct


internal class PutScalingPolicyOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: PutScalingPolicyRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

        builder.url {
            path.encoded = "/"
        }

        val payload = serializePutScalingPolicyOperationBody(context, input)
        builder.body = HttpBody.fromBytes(payload)
        if (builder.body !is HttpBody.Empty) {
            builder.headers.setMissing("Content-Type", "application/x-amz-json-1.1")
        }
        return builder
    }
}

private fun serializePutScalingPolicyOperationBody(context: ExecutionContext, input: PutScalingPolicyRequest): ByteArray {
    val serializer = JsonSerializer()
    val POLICYNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("PolicyName"))
    val POLICYTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("PolicyType"))
    val RESOURCEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ResourceId"))
    val SCALABLEDIMENSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("ScalableDimension"))
    val SERVICENAMESPACE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("ServiceNamespace"))
    val STEPSCALINGPOLICYCONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("StepScalingPolicyConfiguration"))
    val TARGETTRACKINGSCALINGPOLICYCONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("TargetTrackingScalingPolicyConfiguration"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(POLICYNAME_DESCRIPTOR)
        field(POLICYTYPE_DESCRIPTOR)
        field(RESOURCEID_DESCRIPTOR)
        field(SCALABLEDIMENSION_DESCRIPTOR)
        field(SERVICENAMESPACE_DESCRIPTOR)
        field(STEPSCALINGPOLICYCONFIGURATION_DESCRIPTOR)
        field(TARGETTRACKINGSCALINGPOLICYCONFIGURATION_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.policyName?.let { field(POLICYNAME_DESCRIPTOR, it) }
        input.policyType?.let { field(POLICYTYPE_DESCRIPTOR, it.value) }
        input.resourceId?.let { field(RESOURCEID_DESCRIPTOR, it) }
        input.scalableDimension?.let { field(SCALABLEDIMENSION_DESCRIPTOR, it.value) }
        input.serviceNamespace?.let { field(SERVICENAMESPACE_DESCRIPTOR, it.value) }
        input.stepScalingPolicyConfiguration?.let { field(STEPSCALINGPOLICYCONFIGURATION_DESCRIPTOR, it, ::serializeStepScalingPolicyConfigurationDocument) }
        input.targetTrackingScalingPolicyConfiguration?.let { field(TARGETTRACKINGSCALINGPOLICYCONFIGURATION_DESCRIPTOR, it, ::serializeTargetTrackingScalingPolicyConfigurationDocument) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy