
commonMain.aws.sdk.kotlin.services.quicksight.transform.DeleteAnalysisOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.quicksight.transform
import aws.sdk.kotlin.runtime.http.setAseErrorMetadata
import aws.sdk.kotlin.runtime.http.withPayload
import aws.sdk.kotlin.runtime.protocol.json.RestJsonErrorDeserializer
import aws.sdk.kotlin.services.quicksight.model.DeleteAnalysisResponse
import aws.sdk.kotlin.services.quicksight.model.QuickSightException
import aws.smithy.kotlin.runtime.client.ExecutionContext
import aws.smithy.kotlin.runtime.http.isSuccess
import aws.smithy.kotlin.runtime.http.operation.HttpDeserialize
import aws.smithy.kotlin.runtime.http.readAll
import aws.smithy.kotlin.runtime.http.response.HttpResponse
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 DeleteAnalysisOperationDeserializer: HttpDeserialize {
override suspend fun deserialize(context: ExecutionContext, response: HttpResponse): DeleteAnalysisResponse {
if (!response.status.isSuccess()) {
throwDeleteAnalysisError(context, response)
}
val builder = DeleteAnalysisResponse.Builder()
val payload = response.body.readAll()
if (payload != null) {
deserializeDeleteAnalysisOperationBody(builder, payload)
}
builder.status = response.status.value
return builder.build()
}
}
private suspend fun throwDeleteAnalysisError(context: ExecutionContext, response: HttpResponse): kotlin.Nothing {
val payload = response.body.readAll()
val wrappedResponse = response.withPayload(payload)
val errorDetails = try {
RestJsonErrorDeserializer.deserialize(response.headers, payload)
} catch (ex: Exception) {
throw QuickSightException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedResponse, null)
}
}
val ex = when(errorDetails.code) {
"ConflictException" -> ConflictExceptionDeserializer().deserialize(context, wrappedResponse)
"InternalFailureException" -> InternalFailureExceptionDeserializer().deserialize(context, wrappedResponse)
"InvalidParameterValueException" -> InvalidParameterValueExceptionDeserializer().deserialize(context, wrappedResponse)
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedResponse)
"ThrottlingException" -> ThrottlingExceptionDeserializer().deserialize(context, wrappedResponse)
"UnsupportedUserEditionException" -> UnsupportedUserEditionExceptionDeserializer().deserialize(context, wrappedResponse)
else -> QuickSightException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeDeleteAnalysisOperationBody(builder: DeleteAnalysisResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val ANALYSISID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("AnalysisId"))
val ARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Arn"))
val DELETIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("DeletionTime"))
val REQUESTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RequestId"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(ANALYSISID_DESCRIPTOR)
field(ARN_DESCRIPTOR)
field(DELETIONTIME_DESCRIPTOR)
field(REQUESTID_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
ANALYSISID_DESCRIPTOR.index -> builder.analysisId = deserializeString()
ARN_DESCRIPTOR.index -> builder.arn = deserializeString()
DELETIONTIME_DESCRIPTOR.index -> builder.deletionTime = deserializeString().let { Instant.fromEpochSeconds(it) }
REQUESTID_DESCRIPTOR.index -> builder.requestId = deserializeString()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy