commonMain.aws.sdk.kotlin.services.bedrockagent.serde.FunctionDocumentDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.bedrockagent.serde
import aws.sdk.kotlin.services.bedrockagent.model.Function
import aws.sdk.kotlin.services.bedrockagent.model.ParameterDetail
import aws.sdk.kotlin.services.bedrockagent.model.RequireConfirmation
import aws.smithy.kotlin.runtime.serde.Deserializer
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.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
import kotlin.collections.mutableMapOf
internal fun deserializeFunctionDocument(deserializer: Deserializer): Function {
val builder = Function.Builder()
val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
val PARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("parameters"))
val REQUIRECONFIRMATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("requireConfirmation"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(DESCRIPTION_DESCRIPTOR)
field(NAME_DESCRIPTOR)
field(PARAMETERS_DESCRIPTOR)
field(REQUIRECONFIRMATION_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
NAME_DESCRIPTOR.index -> builder.name = deserializeString()
PARAMETERS_DESCRIPTOR.index -> builder.parameters =
deserializer.deserializeMap(PARAMETERS_DESCRIPTOR) {
val map0 = mutableMapOf()
while (hasNextEntry()) {
val k0 = key()
val v0 = if (nextHasValue()) { deserializeParameterDetailDocument(deserializer) } else { deserializeNull(); continue }
map0[k0] = v0
}
map0
}
REQUIRECONFIRMATION_DESCRIPTOR.index -> builder.requireConfirmation = deserializeString().let { RequireConfirmation.fromValue(it) }
null -> break@loop
else -> skipValue()
}
}
}
builder.correctErrors()
return builder.build()
}