
commonMain.aws.sdk.kotlin.services.wellarchitected.transform.CreateProfileOperationSerializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.wellarchitected.transform
import aws.sdk.kotlin.services.wellarchitected.model.CreateProfileRequest
import aws.sdk.kotlin.services.wellarchitected.model.ProfileQuestionUpdate
import aws.smithy.kotlin.runtime.client.idempotencyTokenProvider
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
import aws.smithy.kotlin.runtime.http.operation.HttpSerialize
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 CreateProfileOperationSerializer: HttpSerialize {
override suspend fun serialize(context: ExecutionContext, input: CreateProfileRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path = "/profiles"
}
val payload = serializeCreateProfileOperationBody(context, input)
builder.body = ByteArrayContent(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/json")
}
return builder
}
}
private fun serializeCreateProfileOperationBody(context: ExecutionContext, input: CreateProfileRequest): ByteArray {
val serializer = JsonSerializer()
val CLIENTREQUESTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ClientRequestToken"))
val PROFILEDESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ProfileDescription"))
val PROFILENAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ProfileName"))
val PROFILEQUESTIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("ProfileQuestions"))
val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Tags"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CLIENTREQUESTTOKEN_DESCRIPTOR)
field(PROFILEDESCRIPTION_DESCRIPTOR)
field(PROFILENAME_DESCRIPTOR)
field(PROFILEQUESTIONS_DESCRIPTOR)
field(TAGS_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.clientRequestToken?.let { field(CLIENTREQUESTTOKEN_DESCRIPTOR, it) } ?: field(CLIENTREQUESTTOKEN_DESCRIPTOR, context.idempotencyTokenProvider.generateToken())
input.profileDescription?.let { field(PROFILEDESCRIPTION_DESCRIPTOR, it) }
input.profileName?.let { field(PROFILENAME_DESCRIPTOR, it) }
if (input.profileQuestions != null) {
listField(PROFILEQUESTIONS_DESCRIPTOR) {
for (el0 in input.profileQuestions) {
serializeSdkSerializable(asSdkSerializable(el0, ::serializeProfileQuestionUpdateDocument))
}
}
}
if (input.tags != null) {
mapField(TAGS_DESCRIPTOR) {
input.tags.forEach { (key, value) -> entry(key, value) }
}
}
}
return serializer.toByteArray()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy