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

commonMain.aws.sdk.kotlin.services.pinpointsmsvoicev2.serde.UpdateEventDestinationOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.pinpointsmsvoicev2.serde

import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.CloudWatchLogsDestination
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.EventType
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.KinesisFirehoseDestination
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.SnsDestination
import aws.sdk.kotlin.services.pinpointsmsvoicev2.model.UpdateEventDestinationRequest
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 UpdateEventDestinationOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: UpdateEventDestinationRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

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

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

private fun serializeUpdateEventDestinationOperationBody(context: ExecutionContext, input: UpdateEventDestinationRequest): ByteArray {
    val serializer = JsonSerializer()
    val CLOUDWATCHLOGSDESTINATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("CloudWatchLogsDestination"))
    val CONFIGURATIONSETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ConfigurationSetName"))
    val ENABLED_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("Enabled"))
    val EVENTDESTINATIONNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("EventDestinationName"))
    val KINESISFIREHOSEDESTINATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("KinesisFirehoseDestination"))
    val MATCHINGEVENTTYPES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("MatchingEventTypes"))
    val SNSDESTINATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("SnsDestination"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CLOUDWATCHLOGSDESTINATION_DESCRIPTOR)
        field(CONFIGURATIONSETNAME_DESCRIPTOR)
        field(ENABLED_DESCRIPTOR)
        field(EVENTDESTINATIONNAME_DESCRIPTOR)
        field(KINESISFIREHOSEDESTINATION_DESCRIPTOR)
        field(MATCHINGEVENTTYPES_DESCRIPTOR)
        field(SNSDESTINATION_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.cloudWatchLogsDestination?.let { field(CLOUDWATCHLOGSDESTINATION_DESCRIPTOR, it, ::serializeCloudWatchLogsDestinationDocument) }
        input.configurationSetName?.let { field(CONFIGURATIONSETNAME_DESCRIPTOR, it) }
        input.enabled?.let { field(ENABLED_DESCRIPTOR, it) }
        input.eventDestinationName?.let { field(EVENTDESTINATIONNAME_DESCRIPTOR, it) }
        input.kinesisFirehoseDestination?.let { field(KINESISFIREHOSEDESTINATION_DESCRIPTOR, it, ::serializeKinesisFirehoseDestinationDocument) }
        if (input.matchingEventTypes != null) {
            listField(MATCHINGEVENTTYPES_DESCRIPTOR) {
                for (el0 in input.matchingEventTypes) {
                    serializeString(el0.value)
                }
            }
        }
        input.snsDestination?.let { field(SNSDESTINATION_DESCRIPTOR, it, ::serializeSnsDestinationDocument) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy