All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.glue.serde.GetDataQualityResultOperationDeserializer.kt Maven / Gradle / Ivy

There is a newer version: 1.3.76
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.glue.serde

import aws.sdk.kotlin.services.glue.model.DataQualityAnalyzerResult
import aws.sdk.kotlin.services.glue.model.DataQualityObservation
import aws.sdk.kotlin.services.glue.model.DataQualityRuleResult
import aws.sdk.kotlin.services.glue.model.DataSource
import aws.sdk.kotlin.services.glue.model.GetDataQualityResultResponse
import aws.sdk.kotlin.services.glue.model.GlueException
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 GetDataQualityResultOperationDeserializer: HttpDeserializer.NonStreaming {

    override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): GetDataQualityResultResponse {
        val response = call.response
        if (!response.status.isSuccess()) {
            throwGetDataQualityResultError(context, call, payload)
        }
        val builder = GetDataQualityResultResponse.Builder()

        if (payload != null) {
            deserializeGetDataQualityResultOperationBody(builder, payload)
        }
        builder.correctErrors()
        return builder.build()
    }
}

private fun throwGetDataQualityResultError(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 GlueException("Failed to parse response as 'awsJson1_1' error", ex).also {
            setAseErrorMetadata(it, wrappedCall.response, null)
        }
    }

    val ex = when(errorDetails.code) {
        "InternalServiceException" -> InternalServiceExceptionDeserializer().deserialize(context, wrappedCall, payload)
        "EntityNotFoundException" -> EntityNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
        "InvalidInputException" -> InvalidInputExceptionDeserializer().deserialize(context, wrappedCall, payload)
        "OperationTimeoutException" -> OperationTimeoutExceptionDeserializer().deserialize(context, wrappedCall, payload)
        else -> GlueException(errorDetails.message)
    }

    setAseErrorMetadata(ex, wrappedResponse, errorDetails)
    throw ex
}

private fun deserializeGetDataQualityResultOperationBody(builder: GetDataQualityResultResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val ANALYZERRESULTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("AnalyzerResults"))
    val COMPLETEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CompletedOn"))
    val DATASOURCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("DataSource"))
    val EVALUATIONCONTEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("EvaluationContext"))
    val JOBNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobName"))
    val JOBRUNID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobRunId"))
    val OBSERVATIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Observations"))
    val PROFILEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ProfileId"))
    val RESULTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ResultId"))
    val RULERESULTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("RuleResults"))
    val RULESETEVALUATIONRUNID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RulesetEvaluationRunId"))
    val RULESETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RulesetName"))
    val SCORE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Double, JsonSerialName("Score"))
    val STARTEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("StartedOn"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ANALYZERRESULTS_DESCRIPTOR)
        field(COMPLETEDON_DESCRIPTOR)
        field(DATASOURCE_DESCRIPTOR)
        field(EVALUATIONCONTEXT_DESCRIPTOR)
        field(JOBNAME_DESCRIPTOR)
        field(JOBRUNID_DESCRIPTOR)
        field(OBSERVATIONS_DESCRIPTOR)
        field(PROFILEID_DESCRIPTOR)
        field(RESULTID_DESCRIPTOR)
        field(RULERESULTS_DESCRIPTOR)
        field(RULESETEVALUATIONRUNID_DESCRIPTOR)
        field(RULESETNAME_DESCRIPTOR)
        field(SCORE_DESCRIPTOR)
        field(STARTEDON_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                ANALYZERRESULTS_DESCRIPTOR.index -> builder.analyzerResults =
                    deserializer.deserializeList(ANALYZERRESULTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataQualityAnalyzerResultDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                COMPLETEDON_DESCRIPTOR.index -> builder.completedOn = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                DATASOURCE_DESCRIPTOR.index -> builder.dataSource = deserializeDataSourceDocument(deserializer)
                EVALUATIONCONTEXT_DESCRIPTOR.index -> builder.evaluationContext = deserializeString()
                JOBNAME_DESCRIPTOR.index -> builder.jobName = deserializeString()
                JOBRUNID_DESCRIPTOR.index -> builder.jobRunId = deserializeString()
                OBSERVATIONS_DESCRIPTOR.index -> builder.observations =
                    deserializer.deserializeList(OBSERVATIONS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataQualityObservationDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                PROFILEID_DESCRIPTOR.index -> builder.profileId = deserializeString()
                RESULTID_DESCRIPTOR.index -> builder.resultId = deserializeString()
                RULERESULTS_DESCRIPTOR.index -> builder.ruleResults =
                    deserializer.deserializeList(RULERESULTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataQualityRuleResultDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                RULESETEVALUATIONRUNID_DESCRIPTOR.index -> builder.rulesetEvaluationRunId = deserializeString()
                RULESETNAME_DESCRIPTOR.index -> builder.rulesetName = deserializeString()
                SCORE_DESCRIPTOR.index -> builder.score = deserializeDouble()
                STARTEDON_DESCRIPTOR.index -> builder.startedOn = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                null -> break@loop
                else -> skipValue()
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy