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

commonMain.aws.sdk.kotlin.services.datazone.serde.CreateEnvironmentOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.datazone.serde

import aws.sdk.kotlin.services.datazone.model.CreateEnvironmentRequest
import aws.sdk.kotlin.services.datazone.model.EnvironmentParameter
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
import aws.smithy.kotlin.runtime.text.encoding.PercentEncoding


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

        builder.url {
            requireNotNull(input.domainIdentifier) { "domainIdentifier is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("v2"))
                add(PercentEncoding.Path.encode("domains"))
                add(PercentEncoding.SmithyLabel.encode(input.domainIdentifier))
                add(PercentEncoding.Path.encode("environments"))
            }
        }

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

private fun serializeCreateEnvironmentOperationBody(context: ExecutionContext, input: CreateEnvironmentRequest): ByteArray {
    val serializer = JsonSerializer()
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
    val ENVIRONMENTACCOUNTIDENTIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("environmentAccountIdentifier"))
    val ENVIRONMENTACCOUNTREGION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("environmentAccountRegion"))
    val ENVIRONMENTBLUEPRINTIDENTIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("environmentBlueprintIdentifier"))
    val ENVIRONMENTPROFILEIDENTIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("environmentProfileIdentifier"))
    val GLOSSARYTERMS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("glossaryTerms"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
    val PROJECTIDENTIFIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("projectIdentifier"))
    val USERPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("userParameters"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(DESCRIPTION_DESCRIPTOR)
        field(ENVIRONMENTACCOUNTIDENTIFIER_DESCRIPTOR)
        field(ENVIRONMENTACCOUNTREGION_DESCRIPTOR)
        field(ENVIRONMENTBLUEPRINTIDENTIFIER_DESCRIPTOR)
        field(ENVIRONMENTPROFILEIDENTIFIER_DESCRIPTOR)
        field(GLOSSARYTERMS_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(PROJECTIDENTIFIER_DESCRIPTOR)
        field(USERPARAMETERS_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.description?.let { field(DESCRIPTION_DESCRIPTOR, it) }
        input.environmentAccountIdentifier?.let { field(ENVIRONMENTACCOUNTIDENTIFIER_DESCRIPTOR, it) }
        input.environmentAccountRegion?.let { field(ENVIRONMENTACCOUNTREGION_DESCRIPTOR, it) }
        input.environmentBlueprintIdentifier?.let { field(ENVIRONMENTBLUEPRINTIDENTIFIER_DESCRIPTOR, it) }
        input.environmentProfileIdentifier?.let { field(ENVIRONMENTPROFILEIDENTIFIER_DESCRIPTOR, it) }
        if (input.glossaryTerms != null) {
            listField(GLOSSARYTERMS_DESCRIPTOR) {
                for (el0 in input.glossaryTerms) {
                    serializeString(el0)
                }
            }
        }
        input.name?.let { field(NAME_DESCRIPTOR, it) }
        input.projectIdentifier?.let { field(PROJECTIDENTIFIER_DESCRIPTOR, it) }
        if (input.userParameters != null) {
            listField(USERPARAMETERS_DESCRIPTOR) {
                for (el0 in input.userParameters) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeEnvironmentParameterDocument))
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy