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

commonMain.aws.sdk.kotlin.services.cloudwatch.serde.PutCompositeAlarmOperationSerializer.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.PutCompositeAlarmRequest
import aws.sdk.kotlin.services.cloudwatch.model.Tag
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.operation.HttpSerialize
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 PutCompositeAlarmOperationSerializer: HttpSerialize {
    override suspend fun serialize(context: ExecutionContext, input: PutCompositeAlarmRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

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

        val payload = serializePutCompositeAlarmOperationBody(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 serializePutCompositeAlarmOperationBody(context: ExecutionContext, input: PutCompositeAlarmRequest): ByteArray {
    val serializer = FormUrlSerializer()
    val ACTIONSENABLED_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, FormUrlSerialName("ActionsEnabled"))
    val ACTIONSSUPPRESSOR_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("ActionsSuppressor"))
    val ACTIONSSUPPRESSOREXTENSIONPERIOD_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, FormUrlSerialName("ActionsSuppressorExtensionPeriod"))
    val ACTIONSSUPPRESSORWAITPERIOD_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, FormUrlSerialName("ActionsSuppressorWaitPeriod"))
    val ALARMACTIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("AlarmActions"))
    val ALARMDESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("AlarmDescription"))
    val ALARMNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("AlarmName"))
    val ALARMRULE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, FormUrlSerialName("AlarmRule"))
    val INSUFFICIENTDATAACTIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("InsufficientDataActions"))
    val OKACTIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("OKActions"))
    val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, FormUrlSerialName("Tags"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        trait(FormUrlSerialName("PutCompositeAlarmInput"))
        trait(QueryLiteral("Action", "PutCompositeAlarm"))
        trait(QueryLiteral("Version", "2010-08-01"))
        field(ACTIONSENABLED_DESCRIPTOR)
        field(ACTIONSSUPPRESSOR_DESCRIPTOR)
        field(ACTIONSSUPPRESSOREXTENSIONPERIOD_DESCRIPTOR)
        field(ACTIONSSUPPRESSORWAITPERIOD_DESCRIPTOR)
        field(ALARMACTIONS_DESCRIPTOR)
        field(ALARMDESCRIPTION_DESCRIPTOR)
        field(ALARMNAME_DESCRIPTOR)
        field(ALARMRULE_DESCRIPTOR)
        field(INSUFFICIENTDATAACTIONS_DESCRIPTOR)
        field(OKACTIONS_DESCRIPTOR)
        field(TAGS_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.actionsEnabled?.let { field(ACTIONSENABLED_DESCRIPTOR, it) }
        input.actionsSuppressor?.let { field(ACTIONSSUPPRESSOR_DESCRIPTOR, it) }
        input.actionsSuppressorExtensionPeriod?.let { field(ACTIONSSUPPRESSOREXTENSIONPERIOD_DESCRIPTOR, it) }
        input.actionsSuppressorWaitPeriod?.let { field(ACTIONSSUPPRESSORWAITPERIOD_DESCRIPTOR, it) }
        if (input.alarmActions != null) {
            listField(ALARMACTIONS_DESCRIPTOR) {
                for (el0 in input.alarmActions) {
                    serializeString(el0)
                }
            }
        }
        input.alarmDescription?.let { field(ALARMDESCRIPTION_DESCRIPTOR, it) }
        input.alarmName?.let { field(ALARMNAME_DESCRIPTOR, it) }
        input.alarmRule?.let { field(ALARMRULE_DESCRIPTOR, it) }
        if (input.insufficientDataActions != null) {
            listField(INSUFFICIENTDATAACTIONS_DESCRIPTOR) {
                for (el0 in input.insufficientDataActions) {
                    serializeString(el0)
                }
            }
        }
        if (input.okActions != null) {
            listField(OKACTIONS_DESCRIPTOR) {
                for (el0 in input.okActions) {
                    serializeString(el0)
                }
            }
        }
        if (input.tags != null) {
            listField(TAGS_DESCRIPTOR) {
                for (el0 in input.tags) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeTagDocument))
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy