
commonMain.aws.sdk.kotlin.services.cloudfront.serde.CreateFunctionOperationSerializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.cloudfront.serde
import aws.sdk.kotlin.services.cloudfront.model.CreateFunctionRequest
import aws.sdk.kotlin.services.cloudfront.model.FunctionConfig
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.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
import aws.smithy.kotlin.runtime.serde.xml.XmlNamespace
import aws.smithy.kotlin.runtime.serde.xml.XmlSerialName
import aws.smithy.kotlin.runtime.serde.xml.XmlSerializer
import aws.smithy.kotlin.runtime.text.encoding.encodeBase64String
internal class CreateFunctionOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: CreateFunctionRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/2020-05-31/function"
}
val payload = serializeCreateFunctionOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/xml")
}
return builder
}
}
private fun serializeCreateFunctionOperationBody(context: ExecutionContext, input: CreateFunctionRequest): ByteArray {
val serializer = XmlSerializer()
val FUNCTIONCODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Blob, XmlSerialName("FunctionCode"))
val FUNCTIONCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, XmlSerialName("FunctionConfig"))
val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, XmlSerialName("Name"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
trait(XmlSerialName("CreateFunctionRequest"))
trait(XmlNamespace("http://cloudfront.amazonaws.com/doc/2020-05-31/"))
field(FUNCTIONCODE_DESCRIPTOR)
field(FUNCTIONCONFIG_DESCRIPTOR)
field(NAME_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.functionCode?.let { field(FUNCTIONCODE_DESCRIPTOR, it.encodeBase64String()) }
input.functionConfig?.let { field(FUNCTIONCONFIG_DESCRIPTOR, it, ::serializeFunctionConfigDocument) }
input.name?.let { field(NAME_DESCRIPTOR, it) }
}
return serializer.toByteArray()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy