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

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

There is a newer version: 1.3.99
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.DescribeJobResponse
import aws.sdk.kotlin.services.databrew.model.EncryptionMode
import aws.sdk.kotlin.services.databrew.model.JobSample
import aws.sdk.kotlin.services.databrew.model.JobType
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 DescribeJobOperationDeserializer: HttpDeserialize {

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

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

private suspend fun throwDescribeJobError(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 deserializeDescribeJobOperationBody(builder: DescribeJobResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val CREATEDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CreateDate"))
    val CREATEDBY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("CreatedBy"))
    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 ENCRYPTIONKEYARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("EncryptionKeyArn"))
    val ENCRYPTIONMODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("EncryptionMode"))
    val JOBSAMPLE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("JobSample"))
    val LASTMODIFIEDBY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LastModifiedBy"))
    val LASTMODIFIEDDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("LastModifiedDate"))
    val LOGSUBSCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LogSubscription"))
    val MAXCAPACITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("MaxCapacity"))
    val MAXRETRIES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("MaxRetries"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Name"))
    val OUTPUTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Outputs"))
    val PROFILECONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("ProfileConfiguration"))
    val PROJECTNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ProjectName"))
    val RECIPEREFERENCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("RecipeReference"))
    val RESOURCEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ResourceArn"))
    val ROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RoleArn"))
    val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Tags"))
    val TIMEOUT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Timeout"))
    val TYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Type"))
    val VALIDATIONCONFIGURATIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("ValidationConfigurations"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CREATEDATE_DESCRIPTOR)
        field(CREATEDBY_DESCRIPTOR)
        field(DATACATALOGOUTPUTS_DESCRIPTOR)
        field(DATABASEOUTPUTS_DESCRIPTOR)
        field(DATASETNAME_DESCRIPTOR)
        field(ENCRYPTIONKEYARN_DESCRIPTOR)
        field(ENCRYPTIONMODE_DESCRIPTOR)
        field(JOBSAMPLE_DESCRIPTOR)
        field(LASTMODIFIEDBY_DESCRIPTOR)
        field(LASTMODIFIEDDATE_DESCRIPTOR)
        field(LOGSUBSCRIPTION_DESCRIPTOR)
        field(MAXCAPACITY_DESCRIPTOR)
        field(MAXRETRIES_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(OUTPUTS_DESCRIPTOR)
        field(PROFILECONFIGURATION_DESCRIPTOR)
        field(PROJECTNAME_DESCRIPTOR)
        field(RECIPEREFERENCE_DESCRIPTOR)
        field(RESOURCEARN_DESCRIPTOR)
        field(ROLEARN_DESCRIPTOR)
        field(TAGS_DESCRIPTOR)
        field(TIMEOUT_DESCRIPTOR)
        field(TYPE_DESCRIPTOR)
        field(VALIDATIONCONFIGURATIONS_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                CREATEDATE_DESCRIPTOR.index -> builder.createDate = deserializeString().let { Instant.fromEpochSeconds(it) }
                CREATEDBY_DESCRIPTOR.index -> builder.createdBy = deserializeString()
                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()
                ENCRYPTIONKEYARN_DESCRIPTOR.index -> builder.encryptionKeyArn = deserializeString()
                ENCRYPTIONMODE_DESCRIPTOR.index -> builder.encryptionMode = deserializeString().let { EncryptionMode.fromValue(it) }
                JOBSAMPLE_DESCRIPTOR.index -> builder.jobSample = deserializeJobSampleDocument(deserializer)
                LASTMODIFIEDBY_DESCRIPTOR.index -> builder.lastModifiedBy = deserializeString()
                LASTMODIFIEDDATE_DESCRIPTOR.index -> builder.lastModifiedDate = deserializeString().let { Instant.fromEpochSeconds(it) }
                LOGSUBSCRIPTION_DESCRIPTOR.index -> builder.logSubscription = deserializeString().let { LogSubscription.fromValue(it) }
                MAXCAPACITY_DESCRIPTOR.index -> builder.maxCapacity = deserializeInt()
                MAXRETRIES_DESCRIPTOR.index -> builder.maxRetries = deserializeInt()
                NAME_DESCRIPTOR.index -> builder.name = deserializeString()
                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)
                PROJECTNAME_DESCRIPTOR.index -> builder.projectName = deserializeString()
                RECIPEREFERENCE_DESCRIPTOR.index -> builder.recipeReference = deserializeRecipeReferenceDocument(deserializer)
                RESOURCEARN_DESCRIPTOR.index -> builder.resourceArn = deserializeString()
                ROLEARN_DESCRIPTOR.index -> builder.roleArn = deserializeString()
                TAGS_DESCRIPTOR.index -> builder.tags =
                    deserializer.deserializeMap(TAGS_DESCRIPTOR) {
                        val map0 = mutableMapOf()
                        while (hasNextEntry()) {
                            val k0 = key()
                            val v0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
                            map0[k0] = v0
                        }
                        map0
                    }
                TIMEOUT_DESCRIPTOR.index -> builder.timeout = deserializeInt()
                TYPE_DESCRIPTOR.index -> builder.type = deserializeString().let { JobType.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