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

commonMain.aws.sdk.kotlin.services.glue.serde.GetMLTransformOperationDeserializer.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.EvaluationMetrics
import aws.sdk.kotlin.services.glue.model.GetMlTransformResponse
import aws.sdk.kotlin.services.glue.model.GlueException
import aws.sdk.kotlin.services.glue.model.GlueTable
import aws.sdk.kotlin.services.glue.model.SchemaColumn
import aws.sdk.kotlin.services.glue.model.TransformEncryption
import aws.sdk.kotlin.services.glue.model.TransformParameters
import aws.sdk.kotlin.services.glue.model.TransformStatusType
import aws.sdk.kotlin.services.glue.model.WorkerType
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 GetMLTransformOperationDeserializer: HttpDeserializer.NonStreaming {

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

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

private fun throwGetMlTransformError(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 deserializeGetMLTransformOperationBody(builder: GetMlTransformResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val CREATEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CreatedOn"))
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Description"))
    val EVALUATIONMETRICS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("EvaluationMetrics"))
    val GLUEVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("GlueVersion"))
    val INPUTRECORDTABLES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("InputRecordTables"))
    val LABELCOUNT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("LabelCount"))
    val LASTMODIFIEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("LastModifiedOn"))
    val MAXCAPACITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Double, JsonSerialName("MaxCapacity"))
    val MAXRETRIES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("MaxRetries"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Name"))
    val NUMBEROFWORKERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("NumberOfWorkers"))
    val PARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("Parameters"))
    val ROLE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Role"))
    val SCHEMA_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Schema"))
    val STATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Status"))
    val TIMEOUT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Timeout"))
    val TRANSFORMENCRYPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("TransformEncryption"))
    val TRANSFORMID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("TransformId"))
    val WORKERTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("WorkerType"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CREATEDON_DESCRIPTOR)
        field(DESCRIPTION_DESCRIPTOR)
        field(EVALUATIONMETRICS_DESCRIPTOR)
        field(GLUEVERSION_DESCRIPTOR)
        field(INPUTRECORDTABLES_DESCRIPTOR)
        field(LABELCOUNT_DESCRIPTOR)
        field(LASTMODIFIEDON_DESCRIPTOR)
        field(MAXCAPACITY_DESCRIPTOR)
        field(MAXRETRIES_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(NUMBEROFWORKERS_DESCRIPTOR)
        field(PARAMETERS_DESCRIPTOR)
        field(ROLE_DESCRIPTOR)
        field(SCHEMA_DESCRIPTOR)
        field(STATUS_DESCRIPTOR)
        field(TIMEOUT_DESCRIPTOR)
        field(TRANSFORMENCRYPTION_DESCRIPTOR)
        field(TRANSFORMID_DESCRIPTOR)
        field(WORKERTYPE_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                CREATEDON_DESCRIPTOR.index -> builder.createdOn = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
                EVALUATIONMETRICS_DESCRIPTOR.index -> builder.evaluationMetrics = deserializeEvaluationMetricsDocument(deserializer)
                GLUEVERSION_DESCRIPTOR.index -> builder.glueVersion = deserializeString()
                INPUTRECORDTABLES_DESCRIPTOR.index -> builder.inputRecordTables =
                    deserializer.deserializeList(INPUTRECORDTABLES_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeGlueTableDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                LABELCOUNT_DESCRIPTOR.index -> builder.labelCount = deserializeInt()
                LASTMODIFIEDON_DESCRIPTOR.index -> builder.lastModifiedOn = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                MAXCAPACITY_DESCRIPTOR.index -> builder.maxCapacity = deserializeDouble()
                MAXRETRIES_DESCRIPTOR.index -> builder.maxRetries = deserializeInt()
                NAME_DESCRIPTOR.index -> builder.name = deserializeString()
                NUMBEROFWORKERS_DESCRIPTOR.index -> builder.numberOfWorkers = deserializeInt()
                PARAMETERS_DESCRIPTOR.index -> builder.parameters = deserializeTransformParametersDocument(deserializer)
                ROLE_DESCRIPTOR.index -> builder.role = deserializeString()
                SCHEMA_DESCRIPTOR.index -> builder.schema =
                    deserializer.deserializeList(SCHEMA_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeSchemaColumnDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                STATUS_DESCRIPTOR.index -> builder.status = deserializeString().let { TransformStatusType.fromValue(it) }
                TIMEOUT_DESCRIPTOR.index -> builder.timeout = deserializeInt()
                TRANSFORMENCRYPTION_DESCRIPTOR.index -> builder.transformEncryption = deserializeTransformEncryptionDocument(deserializer)
                TRANSFORMID_DESCRIPTOR.index -> builder.transformId = deserializeString()
                WORKERTYPE_DESCRIPTOR.index -> builder.workerType = deserializeString().let { WorkerType.fromValue(it) }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy