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

commonMain.aws.sdk.kotlin.services.lexmodelbuildingservice.serde.PutIntentOperationSerializer.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.lexmodelbuildingservice.serde

import aws.sdk.kotlin.services.lexmodelbuildingservice.model.CodeHook
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.FollowUpPrompt
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.FulfillmentActivity
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.InputContext
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.KendraConfiguration
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.OutputContext
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Prompt
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.PutIntentRequest
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Slot
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Statement
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 PutIntentOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: PutIntentRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.PUT

        builder.url {
            requireNotNull(input.name) { "name is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("intents"))
                add(PercentEncoding.SmithyLabel.encode(input.name))
                add(PercentEncoding.Path.encode("versions"))
                add(PercentEncoding.Path.encode("\$LATEST"))
            }
        }

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

private fun serializePutIntentOperationBody(context: ExecutionContext, input: PutIntentRequest): ByteArray {
    val serializer = JsonSerializer()
    val CHECKSUM_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("checksum"))
    val CONCLUSIONSTATEMENT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("conclusionStatement"))
    val CONFIRMATIONPROMPT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("confirmationPrompt"))
    val CREATEVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("createVersion"))
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
    val DIALOGCODEHOOK_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("dialogCodeHook"))
    val FOLLOWUPPROMPT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("followUpPrompt"))
    val FULFILLMENTACTIVITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("fulfillmentActivity"))
    val INPUTCONTEXTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("inputContexts"))
    val KENDRACONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("kendraConfiguration"))
    val OUTPUTCONTEXTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("outputContexts"))
    val PARENTINTENTSIGNATURE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("parentIntentSignature"))
    val REJECTIONSTATEMENT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("rejectionStatement"))
    val SAMPLEUTTERANCES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("sampleUtterances"))
    val SLOTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("slots"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CHECKSUM_DESCRIPTOR)
        field(CONCLUSIONSTATEMENT_DESCRIPTOR)
        field(CONFIRMATIONPROMPT_DESCRIPTOR)
        field(CREATEVERSION_DESCRIPTOR)
        field(DESCRIPTION_DESCRIPTOR)
        field(DIALOGCODEHOOK_DESCRIPTOR)
        field(FOLLOWUPPROMPT_DESCRIPTOR)
        field(FULFILLMENTACTIVITY_DESCRIPTOR)
        field(INPUTCONTEXTS_DESCRIPTOR)
        field(KENDRACONFIGURATION_DESCRIPTOR)
        field(OUTPUTCONTEXTS_DESCRIPTOR)
        field(PARENTINTENTSIGNATURE_DESCRIPTOR)
        field(REJECTIONSTATEMENT_DESCRIPTOR)
        field(SAMPLEUTTERANCES_DESCRIPTOR)
        field(SLOTS_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.checksum?.let { field(CHECKSUM_DESCRIPTOR, it) }
        input.conclusionStatement?.let { field(CONCLUSIONSTATEMENT_DESCRIPTOR, it, ::serializeStatementDocument) }
        input.confirmationPrompt?.let { field(CONFIRMATIONPROMPT_DESCRIPTOR, it, ::serializePromptDocument) }
        input.createVersion?.let { field(CREATEVERSION_DESCRIPTOR, it) }
        input.description?.let { field(DESCRIPTION_DESCRIPTOR, it) }
        input.dialogCodeHook?.let { field(DIALOGCODEHOOK_DESCRIPTOR, it, ::serializeCodeHookDocument) }
        input.followUpPrompt?.let { field(FOLLOWUPPROMPT_DESCRIPTOR, it, ::serializeFollowUpPromptDocument) }
        input.fulfillmentActivity?.let { field(FULFILLMENTACTIVITY_DESCRIPTOR, it, ::serializeFulfillmentActivityDocument) }
        if (input.inputContexts != null) {
            listField(INPUTCONTEXTS_DESCRIPTOR) {
                for (el0 in input.inputContexts) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeInputContextDocument))
                }
            }
        }
        input.kendraConfiguration?.let { field(KENDRACONFIGURATION_DESCRIPTOR, it, ::serializeKendraConfigurationDocument) }
        if (input.outputContexts != null) {
            listField(OUTPUTCONTEXTS_DESCRIPTOR) {
                for (el0 in input.outputContexts) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeOutputContextDocument))
                }
            }
        }
        input.parentIntentSignature?.let { field(PARENTINTENTSIGNATURE_DESCRIPTOR, it) }
        input.rejectionStatement?.let { field(REJECTIONSTATEMENT_DESCRIPTOR, it, ::serializeStatementDocument) }
        if (input.sampleUtterances != null) {
            listField(SAMPLEUTTERANCES_DESCRIPTOR) {
                for (el0 in input.sampleUtterances) {
                    serializeString(el0)
                }
            }
        }
        if (input.slots != null) {
            listField(SLOTS_DESCRIPTOR) {
                for (el0 in input.slots) {
                    serializeSdkSerializable(asSdkSerializable(el0, ::serializeSlotDocument))
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy