commonMain.aws.sdk.kotlin.services.lexmodelbuildingservice.serde.PutBotAliasOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.lexmodelbuildingservice.serde
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.ConversationLogsResponse
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.LexModelBuildingException
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.PutBotAliasResponse
import aws.sdk.kotlin.services.lexmodelbuildingservice.model.Tag
import aws.smithy.kotlin.runtime.awsprotocol.json.RestJsonErrorDeserializer
import aws.smithy.kotlin.runtime.awsprotocol.setAseErrorMetadata
import aws.smithy.kotlin.runtime.awsprotocol.withPayload
import aws.smithy.kotlin.runtime.http.HttpCall
import aws.smithy.kotlin.runtime.http.isSuccess
import aws.smithy.kotlin.runtime.http.operation.HttpDeserializer
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.serializeList
import aws.smithy.kotlin.runtime.serde.serializeMap
import aws.smithy.kotlin.runtime.serde.serializeStruct
import aws.smithy.kotlin.runtime.time.Instant
import aws.smithy.kotlin.runtime.time.TimestampFormat
import kotlin.collections.mutableListOf
internal class PutBotAliasOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): PutBotAliasResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwPutBotAliasError(context, call, payload)
}
val builder = PutBotAliasResponse.Builder()
if (payload != null) {
deserializePutBotAliasOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwPutBotAliasError(context: ExecutionContext, call: HttpCall, payload: ByteArray?): kotlin.Nothing {
val wrappedResponse = call.response.withPayload(payload)
val wrappedCall = call.copy(response = wrappedResponse)
val errorDetails = try {
RestJsonErrorDeserializer.deserialize(call.response.headers, payload)
} catch (ex: Exception) {
throw LexModelBuildingException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"ConflictException" -> ConflictExceptionDeserializer().deserialize(context, wrappedCall, payload)
"LimitExceededException" -> LimitExceededExceptionDeserializer().deserialize(context, wrappedCall, payload)
"BadRequestException" -> BadRequestExceptionDeserializer().deserialize(context, wrappedCall, payload)
"PreconditionFailedException" -> PreconditionFailedExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InternalFailureException" -> InternalFailureExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> LexModelBuildingException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializePutBotAliasOperationBody(builder: PutBotAliasResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val BOTNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("botName"))
val BOTVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("botVersion"))
val CHECKSUM_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("checksum"))
val CONVERSATIONLOGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("conversationLogs"))
val CREATEDDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("createdDate"))
val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
val LASTUPDATEDDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("lastUpdatedDate"))
val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("tags"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(BOTNAME_DESCRIPTOR)
field(BOTVERSION_DESCRIPTOR)
field(CHECKSUM_DESCRIPTOR)
field(CONVERSATIONLOGS_DESCRIPTOR)
field(CREATEDDATE_DESCRIPTOR)
field(DESCRIPTION_DESCRIPTOR)
field(LASTUPDATEDDATE_DESCRIPTOR)
field(NAME_DESCRIPTOR)
field(TAGS_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
BOTNAME_DESCRIPTOR.index -> builder.botName = deserializeString()
BOTVERSION_DESCRIPTOR.index -> builder.botVersion = deserializeString()
CHECKSUM_DESCRIPTOR.index -> builder.checksum = deserializeString()
CONVERSATIONLOGS_DESCRIPTOR.index -> builder.conversationLogs = deserializeConversationLogsResponseDocument(deserializer)
CREATEDDATE_DESCRIPTOR.index -> builder.createdDate = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
LASTUPDATEDDATE_DESCRIPTOR.index -> builder.lastUpdatedDate = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
NAME_DESCRIPTOR.index -> builder.name = deserializeString()
TAGS_DESCRIPTOR.index -> builder.tags =
deserializer.deserializeList(TAGS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeTagDocument(deserializer) } else { deserializeNull(); continue }
col0.add(el0)
}
col0
}
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy