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

commonMain.aws.sdk.kotlin.services.cloudwatch.serde.DescribeAlarmsOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.cloudwatch.serde

import aws.sdk.kotlin.services.cloudwatch.model.AlarmType
import aws.sdk.kotlin.services.cloudwatch.model.DescribeAlarmsRequest
import aws.sdk.kotlin.services.cloudwatch.model.StateValue
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.formurl.FormUrlSerialName
import aws.smithy.kotlin.runtime.serde.formurl.FormUrlSerializer
import aws.smithy.kotlin.runtime.serde.formurl.QueryLiteral
import aws.smithy.kotlin.runtime.serde.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct


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

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

        val payload = serializeDescribeAlarmsOperationBody(context, input)
        builder.body = HttpBody.fromBytes(payload)
        if (builder.body !is HttpBody.Empty) {
            builder.headers.setMissing("Content-Type", "application/x-www-form-urlencoded")
        }
        return builder
    }
}

private fun serializeDescribeAlarmsOperationBody(context: ExecutionContext, input: DescribeAlarmsRequest): ByteArray {
    val serializer = FormUrlSerializer()
    val ACTIONPREFIX_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("ActionPrefix"))
    val ALARMNAMEPREFIX_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("AlarmNamePrefix"))
    val ALARMNAMES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("AlarmNames"))
    val ALARMTYPES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("AlarmTypes"))
    val CHILDRENOFALARMNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("ChildrenOfAlarmName"))
    val MAXRECORDS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, FormUrlSerialName("MaxRecords"))
    val NEXTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("NextToken"))
    val PARENTSOFALARMNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("ParentsOfAlarmName"))
    val STATEVALUE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, FormUrlSerialName("StateValue"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        trait(FormUrlSerialName("DescribeAlarmsInput"))
        trait(QueryLiteral("Action", "DescribeAlarms"))
        trait(QueryLiteral("Version", "2010-08-01"))
        field(ACTIONPREFIX_DESCRIPTOR)
        field(ALARMNAMEPREFIX_DESCRIPTOR)
        field(ALARMNAMES_DESCRIPTOR)
        field(ALARMTYPES_DESCRIPTOR)
        field(CHILDRENOFALARMNAME_DESCRIPTOR)
        field(MAXRECORDS_DESCRIPTOR)
        field(NEXTTOKEN_DESCRIPTOR)
        field(PARENTSOFALARMNAME_DESCRIPTOR)
        field(STATEVALUE_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.actionPrefix?.let { field(ACTIONPREFIX_DESCRIPTOR, it) }
        input.alarmNamePrefix?.let { field(ALARMNAMEPREFIX_DESCRIPTOR, it) }
        if (input.alarmNames != null) {
            listField(ALARMNAMES_DESCRIPTOR) {
                for (el0 in input.alarmNames) {
                    serializeString(el0)
                }
            }
        }
        if (input.alarmTypes != null) {
            listField(ALARMTYPES_DESCRIPTOR) {
                for (el0 in input.alarmTypes) {
                    serializeString(el0.value)
                }
            }
        }
        input.childrenOfAlarmName?.let { field(CHILDRENOFALARMNAME_DESCRIPTOR, it) }
        input.maxRecords?.let { field(MAXRECORDS_DESCRIPTOR, it) }
        input.nextToken?.let { field(NEXTTOKEN_DESCRIPTOR, it) }
        input.parentsOfAlarmName?.let { field(PARENTSOFALARMNAME_DESCRIPTOR, it) }
        input.stateValue?.let { field(STATEVALUE_DESCRIPTOR, it.value) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy