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

commonMain.aws.sdk.kotlin.services.databrew.transform.DescribeJobRunOperationDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.databrew.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.databrew.model.DataBrewException
import aws.sdk.kotlin.services.databrew.model.DataCatalogOutput
import aws.sdk.kotlin.services.databrew.model.DatabaseOutput
import aws.sdk.kotlin.services.databrew.model.DescribeJobRunResponse
import aws.sdk.kotlin.services.databrew.model.JobRunState
import aws.sdk.kotlin.services.databrew.model.JobSample
import aws.sdk.kotlin.services.databrew.model.LogSubscription
import aws.sdk.kotlin.services.databrew.model.Output
import aws.sdk.kotlin.services.databrew.model.ProfileConfiguration
import aws.sdk.kotlin.services.databrew.model.RecipeReference
import aws.sdk.kotlin.services.databrew.model.ValidationConfiguration
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 DescribeJobRunOperationDeserializer: HttpDeserialize {

    override suspend fun deserialize(context: ExecutionContext, response: HttpResponse): DescribeJobRunResponse {
        if (!response.status.isSuccess()) {
            throwDescribeJobRunError(context, response)
        }
        val builder = DescribeJobRunResponse.Builder()

        val payload = response.body.readAll()
        if (payload != null) {
            deserializeDescribeJobRunOperationBody(builder, payload)
        }
        return builder.build()
    }
}

private suspend fun throwDescribeJobRunError(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 DataBrewException("Failed to parse response as 'restJson1' error", ex).also {
            setAseErrorMetadata(it, wrappedResponse, null)
        }
    }

    val ex = when(errorDetails.code) {
        "ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedResponse)
        "ValidationException" -> ValidationExceptionDeserializer().deserialize(context, wrappedResponse)
        else -> DataBrewException(errorDetails.message)
    }

    setAseErrorMetadata(ex, wrappedResponse, errorDetails)
    throw ex
}

private fun deserializeDescribeJobRunOperationBody(builder: DescribeJobRunResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val ATTEMPT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Attempt"))
    val COMPLETEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CompletedOn"))
    val DATACATALOGOUTPUTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("DataCatalogOutputs"))
    val DATABASEOUTPUTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("DatabaseOutputs"))
    val DATASETNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("DatasetName"))
    val ERRORMESSAGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ErrorMessage"))
    val EXECUTIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("ExecutionTime"))
    val JOBNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobName"))
    val JOBSAMPLE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("JobSample"))
    val LOGGROUPNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LogGroupName"))
    val LOGSUBSCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LogSubscription"))
    val OUTPUTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Outputs"))
    val PROFILECONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("ProfileConfiguration"))
    val RECIPEREFERENCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("RecipeReference"))
    val RUNID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RunId"))
    val STARTEDBY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("StartedBy"))
    val STARTEDON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("StartedOn"))
    val STATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("State"))
    val VALIDATIONCONFIGURATIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("ValidationConfigurations"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ATTEMPT_DESCRIPTOR)
        field(COMPLETEDON_DESCRIPTOR)
        field(DATACATALOGOUTPUTS_DESCRIPTOR)
        field(DATABASEOUTPUTS_DESCRIPTOR)
        field(DATASETNAME_DESCRIPTOR)
        field(ERRORMESSAGE_DESCRIPTOR)
        field(EXECUTIONTIME_DESCRIPTOR)
        field(JOBNAME_DESCRIPTOR)
        field(JOBSAMPLE_DESCRIPTOR)
        field(LOGGROUPNAME_DESCRIPTOR)
        field(LOGSUBSCRIPTION_DESCRIPTOR)
        field(OUTPUTS_DESCRIPTOR)
        field(PROFILECONFIGURATION_DESCRIPTOR)
        field(RECIPEREFERENCE_DESCRIPTOR)
        field(RUNID_DESCRIPTOR)
        field(STARTEDBY_DESCRIPTOR)
        field(STARTEDON_DESCRIPTOR)
        field(STATE_DESCRIPTOR)
        field(VALIDATIONCONFIGURATIONS_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                ATTEMPT_DESCRIPTOR.index -> builder.attempt = deserializeInt()
                COMPLETEDON_DESCRIPTOR.index -> builder.completedOn = deserializeString().let { Instant.fromEpochSeconds(it) }
                DATACATALOGOUTPUTS_DESCRIPTOR.index -> builder.dataCatalogOutputs =
                    deserializer.deserializeList(DATACATALOGOUTPUTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataCatalogOutputDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                DATABASEOUTPUTS_DESCRIPTOR.index -> builder.databaseOutputs =
                    deserializer.deserializeList(DATABASEOUTPUTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDatabaseOutputDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                DATASETNAME_DESCRIPTOR.index -> builder.datasetName = deserializeString()
                ERRORMESSAGE_DESCRIPTOR.index -> builder.errorMessage = deserializeString()
                EXECUTIONTIME_DESCRIPTOR.index -> builder.executionTime = deserializeInt()
                JOBNAME_DESCRIPTOR.index -> builder.jobName = deserializeString()
                JOBSAMPLE_DESCRIPTOR.index -> builder.jobSample = deserializeJobSampleDocument(deserializer)
                LOGGROUPNAME_DESCRIPTOR.index -> builder.logGroupName = deserializeString()
                LOGSUBSCRIPTION_DESCRIPTOR.index -> builder.logSubscription = deserializeString().let { LogSubscription.fromValue(it) }
                OUTPUTS_DESCRIPTOR.index -> builder.outputs =
                    deserializer.deserializeList(OUTPUTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeOutputDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                PROFILECONFIGURATION_DESCRIPTOR.index -> builder.profileConfiguration = deserializeProfileConfigurationDocument(deserializer)
                RECIPEREFERENCE_DESCRIPTOR.index -> builder.recipeReference = deserializeRecipeReferenceDocument(deserializer)
                RUNID_DESCRIPTOR.index -> builder.runId = deserializeString()
                STARTEDBY_DESCRIPTOR.index -> builder.startedBy = deserializeString()
                STARTEDON_DESCRIPTOR.index -> builder.startedOn = deserializeString().let { Instant.fromEpochSeconds(it) }
                STATE_DESCRIPTOR.index -> builder.state = deserializeString().let { JobRunState.fromValue(it) }
                VALIDATIONCONFIGURATIONS_DESCRIPTOR.index -> builder.validationConfigurations =
                    deserializer.deserializeList(VALIDATIONCONFIGURATIONS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeValidationConfigurationDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy