
commonMain.aws.sdk.kotlin.services.qbusiness.serde.GetRetrieverOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.qbusiness.serde
import aws.sdk.kotlin.services.qbusiness.model.GetRetrieverResponse
import aws.sdk.kotlin.services.qbusiness.model.QBusinessException
import aws.sdk.kotlin.services.qbusiness.model.RetrieverConfiguration
import aws.sdk.kotlin.services.qbusiness.model.RetrieverStatus
import aws.sdk.kotlin.services.qbusiness.model.RetrieverType
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
internal class GetRetrieverOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): GetRetrieverResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwGetRetrieverError(context, call, payload)
}
val builder = GetRetrieverResponse.Builder()
if (payload != null) {
deserializeGetRetrieverOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwGetRetrieverError(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 QBusinessException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"ThrottlingException" -> ThrottlingExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ValidationException" -> ValidationExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InternalServerException" -> InternalServerExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
"AccessDeniedException" -> AccessDeniedExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> QBusinessException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeGetRetrieverOperationBody(builder: GetRetrieverResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val APPLICATIONID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("applicationId"))
val CONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("configuration"))
val CREATEDAT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("createdAt"))
val DISPLAYNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("displayName"))
val RETRIEVERARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("retrieverArn"))
val RETRIEVERID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("retrieverId"))
val ROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("roleArn"))
val STATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("status"))
val TYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("type"))
val UPDATEDAT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("updatedAt"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(APPLICATIONID_DESCRIPTOR)
field(CONFIGURATION_DESCRIPTOR)
field(CREATEDAT_DESCRIPTOR)
field(DISPLAYNAME_DESCRIPTOR)
field(RETRIEVERARN_DESCRIPTOR)
field(RETRIEVERID_DESCRIPTOR)
field(ROLEARN_DESCRIPTOR)
field(STATUS_DESCRIPTOR)
field(TYPE_DESCRIPTOR)
field(UPDATEDAT_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
APPLICATIONID_DESCRIPTOR.index -> builder.applicationId = deserializeString()
CONFIGURATION_DESCRIPTOR.index -> builder.configuration = deserializeRetrieverConfigurationDocument(deserializer)
CREATEDAT_DESCRIPTOR.index -> builder.createdAt = deserializeString().let { Instant.fromEpochSeconds(it) }
DISPLAYNAME_DESCRIPTOR.index -> builder.displayName = deserializeString()
RETRIEVERARN_DESCRIPTOR.index -> builder.retrieverArn = deserializeString()
RETRIEVERID_DESCRIPTOR.index -> builder.retrieverId = deserializeString()
ROLEARN_DESCRIPTOR.index -> builder.roleArn = deserializeString()
STATUS_DESCRIPTOR.index -> builder.status = deserializeString().let { RetrieverStatus.fromValue(it) }
TYPE_DESCRIPTOR.index -> builder.type = deserializeString().let { RetrieverType.fromValue(it) }
UPDATEDAT_DESCRIPTOR.index -> builder.updatedAt = deserializeString().let { Instant.fromEpochSeconds(it) }
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy