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

commonMain.aws.sdk.kotlin.services.datazone.serde.PutEnvironmentBlueprintConfigurationOperationSerializer.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.ProvisioningConfiguration
import aws.sdk.kotlin.services.datazone.model.PutEnvironmentBlueprintConfigurationRequest
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 PutEnvironmentBlueprintConfigurationOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: PutEnvironmentBlueprintConfigurationRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.PUT

        builder.url {
            requireNotNull(input.domainIdentifier) { "domainIdentifier is bound to the URI and must not be null" }
            requireNotNull(input.environmentBlueprintIdentifier) { "environmentBlueprintIdentifier 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("environment-blueprint-configurations"))
                add(PercentEncoding.SmithyLabel.encode(input.environmentBlueprintIdentifier))
            }
        }

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

private fun serializePutEnvironmentBlueprintConfigurationOperationBody(context: ExecutionContext, input: PutEnvironmentBlueprintConfigurationRequest): ByteArray {
    val serializer = JsonSerializer()
    val ENABLEDREGIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("enabledRegions"))
    val MANAGEACCESSROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("manageAccessRoleArn"))
    val PROVISIONINGCONFIGURATIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("provisioningConfigurations"))
    val PROVISIONINGROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("provisioningRoleArn"))
    val REGIONALPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("regionalParameters"))
    val REGIONALPARAMETERS_C0_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map)
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ENABLEDREGIONS_DESCRIPTOR)
        field(MANAGEACCESSROLEARN_DESCRIPTOR)
        field(PROVISIONINGCONFIGURATIONS_DESCRIPTOR)
        field(PROVISIONINGROLEARN_DESCRIPTOR)
        field(REGIONALPARAMETERS_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        if (input.enabledRegions != null) {
            listField(ENABLEDREGIONS_DESCRIPTOR) {
                for (el0 in input.enabledRegions) {
                    serializeString(el0)
                }
            }
        }
        input.manageAccessRoleArn?.let { field(MANAGEACCESSROLEARN_DESCRIPTOR, it) }
        if (input.provisioningConfigurations != null) {
            listField(PROVISIONINGCONFIGURATIONS_DESCRIPTOR) {
                for (el0 in input.provisioningConfigurations) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeProvisioningConfigurationDocument))
                }
            }
        }
        input.provisioningRoleArn?.let { field(PROVISIONINGROLEARN_DESCRIPTOR, it) }
        if (input.regionalParameters != null) {
            mapField(REGIONALPARAMETERS_DESCRIPTOR) {
                input.regionalParameters.forEach { (key, value) ->
                    mapEntry(key, REGIONALPARAMETERS_C0_DESCRIPTOR) {
                        value.forEach { (key1, value1) ->
                            entry(key1, value1)
                        }
                    }
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy