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

commonMain.aws.sdk.kotlin.services.wellarchitected.serde.UpdateReviewTemplateAnswerOperationSerializer.kt Maven / Gradle / Ivy

// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.wellarchitected.serde

import aws.sdk.kotlin.services.wellarchitected.model.AnswerReason
import aws.sdk.kotlin.services.wellarchitected.model.ChoiceUpdate
import aws.sdk.kotlin.services.wellarchitected.model.UpdateReviewTemplateAnswerRequest
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 UpdateReviewTemplateAnswerOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: UpdateReviewTemplateAnswerRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.PATCH

        builder.url {
            requireNotNull(input.templateArn) { "templateArn is bound to the URI and must not be null" }
            requireNotNull(input.lensAlias) { "lensAlias is bound to the URI and must not be null" }
            requireNotNull(input.questionId) { "questionId is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("reviewTemplates"))
                add(PercentEncoding.SmithyLabel.encode(input.templateArn))
                add(PercentEncoding.Path.encode("lensReviews"))
                add(PercentEncoding.SmithyLabel.encode(input.lensAlias))
                add(PercentEncoding.Path.encode("answers"))
                add(PercentEncoding.SmithyLabel.encode(input.questionId))
            }
        }

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

private fun serializeUpdateReviewTemplateAnswerOperationBody(context: ExecutionContext, input: UpdateReviewTemplateAnswerRequest): ByteArray {
    val serializer = JsonSerializer()
    val CHOICEUPDATES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("ChoiceUpdates"))
    val ISAPPLICABLE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("IsApplicable"))
    val NOTES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Notes"))
    val REASON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Reason"))
    val SELECTEDCHOICES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("SelectedChoices"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CHOICEUPDATES_DESCRIPTOR)
        field(ISAPPLICABLE_DESCRIPTOR)
        field(NOTES_DESCRIPTOR)
        field(REASON_DESCRIPTOR)
        field(SELECTEDCHOICES_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        if (input.choiceUpdates != null) {
            mapField(CHOICEUPDATES_DESCRIPTOR) {
                input.choiceUpdates.forEach { (key, value) -> entry(key, asSdkSerializable(value, ::serializeChoiceUpdateDocument)) }
            }
        }
        input.isApplicable?.let { field(ISAPPLICABLE_DESCRIPTOR, it) }
        input.notes?.let { field(NOTES_DESCRIPTOR, it) }
        input.reason?.let { field(REASON_DESCRIPTOR, it.value) }
        if (input.selectedChoices != null) {
            listField(SELECTEDCHOICES_DESCRIPTOR) {
                for (el0 in input.selectedChoices) {
                    serializeString(el0)
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy