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

commonMain.aws.sdk.kotlin.services.polly.serde.StartSpeechSynthesisTaskOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.polly.serde

import aws.sdk.kotlin.services.polly.model.Engine
import aws.sdk.kotlin.services.polly.model.LanguageCode
import aws.sdk.kotlin.services.polly.model.OutputFormat
import aws.sdk.kotlin.services.polly.model.SpeechMarkType
import aws.sdk.kotlin.services.polly.model.StartSpeechSynthesisTaskRequest
import aws.sdk.kotlin.services.polly.model.TextType
import aws.sdk.kotlin.services.polly.model.VoiceId
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 StartSpeechSynthesisTaskOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: StartSpeechSynthesisTaskRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

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

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

private fun serializeStartSpeechSynthesisTaskOperationBody(context: ExecutionContext, input: StartSpeechSynthesisTaskRequest): ByteArray {
    val serializer = JsonSerializer()
    val ENGINE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Engine"))
    val LANGUAGECODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("LanguageCode"))
    val LEXICONNAMES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("LexiconNames"))
    val OUTPUTFORMAT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("OutputFormat"))
    val OUTPUTS3BUCKETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("OutputS3BucketName"))
    val OUTPUTS3KEYPREFIX_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("OutputS3KeyPrefix"))
    val SAMPLERATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SampleRate"))
    val SNSTOPICARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SnsTopicArn"))
    val SPEECHMARKTYPES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("SpeechMarkTypes"))
    val TEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Text"))
    val TEXTTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("TextType"))
    val VOICEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("VoiceId"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ENGINE_DESCRIPTOR)
        field(LANGUAGECODE_DESCRIPTOR)
        field(LEXICONNAMES_DESCRIPTOR)
        field(OUTPUTFORMAT_DESCRIPTOR)
        field(OUTPUTS3BUCKETNAME_DESCRIPTOR)
        field(OUTPUTS3KEYPREFIX_DESCRIPTOR)
        field(SAMPLERATE_DESCRIPTOR)
        field(SNSTOPICARN_DESCRIPTOR)
        field(SPEECHMARKTYPES_DESCRIPTOR)
        field(TEXT_DESCRIPTOR)
        field(TEXTTYPE_DESCRIPTOR)
        field(VOICEID_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.engine?.let { field(ENGINE_DESCRIPTOR, it.value) }
        input.languageCode?.let { field(LANGUAGECODE_DESCRIPTOR, it.value) }
        if (input.lexiconNames != null) {
            listField(LEXICONNAMES_DESCRIPTOR) {
                for (el0 in input.lexiconNames) {
                    serializeString(el0)
                }
            }
        }
        input.outputFormat?.let { field(OUTPUTFORMAT_DESCRIPTOR, it.value) }
        input.outputS3BucketName?.let { field(OUTPUTS3BUCKETNAME_DESCRIPTOR, it) }
        input.outputS3KeyPrefix?.let { field(OUTPUTS3KEYPREFIX_DESCRIPTOR, it) }
        input.sampleRate?.let { field(SAMPLERATE_DESCRIPTOR, it) }
        input.snsTopicArn?.let { field(SNSTOPICARN_DESCRIPTOR, it) }
        if (input.speechMarkTypes != null) {
            listField(SPEECHMARKTYPES_DESCRIPTOR) {
                for (el0 in input.speechMarkTypes) {
                    serializeString(el0.value)
                }
            }
        }
        input.text?.let { field(TEXT_DESCRIPTOR, it) }
        input.textType?.let { field(TEXTTYPE_DESCRIPTOR, it.value) }
        input.voiceId?.let { field(VOICEID_DESCRIPTOR, it.value) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy