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

commonMain.aws.sdk.kotlin.services.gamelift.serde.CreateContainerGroupDefinitionOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.gamelift.serde

import aws.sdk.kotlin.services.gamelift.model.ContainerGroupType
import aws.sdk.kotlin.services.gamelift.model.ContainerOperatingSystem
import aws.sdk.kotlin.services.gamelift.model.CreateContainerGroupDefinitionRequest
import aws.sdk.kotlin.services.gamelift.model.GameServerContainerDefinitionInput
import aws.sdk.kotlin.services.gamelift.model.SupportContainerDefinitionInput
import aws.sdk.kotlin.services.gamelift.model.Tag
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 CreateContainerGroupDefinitionOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: CreateContainerGroupDefinitionRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

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

        val payload = serializeCreateContainerGroupDefinitionOperationBody(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 serializeCreateContainerGroupDefinitionOperationBody(context: ExecutionContext, input: CreateContainerGroupDefinitionRequest): ByteArray {
    val serializer = JsonSerializer()
    val CONTAINERGROUPTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("ContainerGroupType"))
    val GAMESERVERCONTAINERDEFINITION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("GameServerContainerDefinition"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Name"))
    val OPERATINGSYSTEM_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("OperatingSystem"))
    val SUPPORTCONTAINERDEFINITIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("SupportContainerDefinitions"))
    val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Tags"))
    val TOTALMEMORYLIMITMEBIBYTES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("TotalMemoryLimitMebibytes"))
    val TOTALVCPULIMIT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Double, JsonSerialName("TotalVcpuLimit"))
    val VERSIONDESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("VersionDescription"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CONTAINERGROUPTYPE_DESCRIPTOR)
        field(GAMESERVERCONTAINERDEFINITION_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(OPERATINGSYSTEM_DESCRIPTOR)
        field(SUPPORTCONTAINERDEFINITIONS_DESCRIPTOR)
        field(TAGS_DESCRIPTOR)
        field(TOTALMEMORYLIMITMEBIBYTES_DESCRIPTOR)
        field(TOTALVCPULIMIT_DESCRIPTOR)
        field(VERSIONDESCRIPTION_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.containerGroupType?.let { field(CONTAINERGROUPTYPE_DESCRIPTOR, it.value) }
        input.gameServerContainerDefinition?.let { field(GAMESERVERCONTAINERDEFINITION_DESCRIPTOR, it, ::serializeGameServerContainerDefinitionInputDocument) }
        input.name?.let { field(NAME_DESCRIPTOR, it) }
        input.operatingSystem?.let { field(OPERATINGSYSTEM_DESCRIPTOR, it.value) }
        if (input.supportContainerDefinitions != null) {
            listField(SUPPORTCONTAINERDEFINITIONS_DESCRIPTOR) {
                for (el0 in input.supportContainerDefinitions) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeSupportContainerDefinitionInputDocument))
                }
            }
        }
        if (input.tags != null) {
            listField(TAGS_DESCRIPTOR) {
                for (el0 in input.tags) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeTagDocument))
                }
            }
        }
        input.totalMemoryLimitMebibytes?.let { field(TOTALMEMORYLIMITMEBIBYTES_DESCRIPTOR, it) }
        input.totalVcpuLimit?.let { field(TOTALVCPULIMIT_DESCRIPTOR, it) }
        input.versionDescription?.let { field(VERSIONDESCRIPTION_DESCRIPTOR, it) }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy