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

commonMain.aws.sdk.kotlin.services.omics.serde.GetRunOperationDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.omics.serde

import aws.sdk.kotlin.services.omics.model.Accelerators
import aws.sdk.kotlin.services.omics.model.GetRunResponse
import aws.sdk.kotlin.services.omics.model.OmicsException
import aws.sdk.kotlin.services.omics.model.RunLogLevel
import aws.sdk.kotlin.services.omics.model.RunLogLocation
import aws.sdk.kotlin.services.omics.model.RunRetentionMode
import aws.sdk.kotlin.services.omics.model.RunStatus
import aws.sdk.kotlin.services.omics.model.WorkflowType
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.content.Document
import aws.smithy.kotlin.runtime.http.HttpCall
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.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 kotlin.collections.mutableMapOf


internal class GetRunOperationDeserializer: HttpDeserialize {

    override suspend fun deserialize(context: ExecutionContext, call: HttpCall): GetRunResponse {
        val response = call.response
        if (!response.status.isSuccess()) {
            throwGetRunError(context, call)
        }
        val builder = GetRunResponse.Builder()

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

private suspend fun throwGetRunError(context: ExecutionContext, call: HttpCall): kotlin.Nothing {
    val payload = call.response.body.readAll()
    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 OmicsException("Failed to parse response as 'restJson1' error", ex).also {
            setAseErrorMetadata(it, wrappedCall.response, null)
        }
    }

    val ex = when(errorDetails.code) {
        "AccessDeniedException" -> AccessDeniedExceptionDeserializer().deserialize(context, wrappedCall)
        "ConflictException" -> ConflictExceptionDeserializer().deserialize(context, wrappedCall)
        "InternalServerException" -> InternalServerExceptionDeserializer().deserialize(context, wrappedCall)
        "RequestTimeoutException" -> RequestTimeoutExceptionDeserializer().deserialize(context, wrappedCall)
        "ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedCall)
        "ServiceQuotaExceededException" -> ServiceQuotaExceededExceptionDeserializer().deserialize(context, wrappedCall)
        "ThrottlingException" -> ThrottlingExceptionDeserializer().deserialize(context, wrappedCall)
        "ValidationException" -> ValidationExceptionDeserializer().deserialize(context, wrappedCall)
        else -> OmicsException(errorDetails.message)
    }

    setAseErrorMetadata(ex, wrappedResponse, errorDetails)
    throw ex
}

private fun deserializeGetRunOperationBody(builder: GetRunResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val ACCELERATORS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("accelerators"))
    val ARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("arn"))
    val CREATIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("creationTime"))
    val DEFINITION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("definition"))
    val DIGEST_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("digest"))
    val FAILUREREASON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("failureReason"))
    val ID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("id"))
    val LOGLEVEL_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("logLevel"))
    val LOGLOCATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("logLocation"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
    val OUTPUTURI_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("outputUri"))
    val PARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Document, JsonSerialName("parameters"))
    val PRIORITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("priority"))
    val RESOURCEDIGESTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("resourceDigests"))
    val RETENTIONMODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("retentionMode"))
    val ROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("roleArn"))
    val RUNGROUPID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("runGroupId"))
    val RUNID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("runId"))
    val RUNOUTPUTURI_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("runOutputUri"))
    val STARTTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("startTime"))
    val STARTEDBY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("startedBy"))
    val STATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("status"))
    val STATUSMESSAGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("statusMessage"))
    val STOPTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("stopTime"))
    val STORAGECAPACITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("storageCapacity"))
    val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("tags"))
    val UUID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("uuid"))
    val WORKFLOWID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("workflowId"))
    val WORKFLOWTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("workflowType"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ACCELERATORS_DESCRIPTOR)
        field(ARN_DESCRIPTOR)
        field(CREATIONTIME_DESCRIPTOR)
        field(DEFINITION_DESCRIPTOR)
        field(DIGEST_DESCRIPTOR)
        field(FAILUREREASON_DESCRIPTOR)
        field(ID_DESCRIPTOR)
        field(LOGLEVEL_DESCRIPTOR)
        field(LOGLOCATION_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(OUTPUTURI_DESCRIPTOR)
        field(PARAMETERS_DESCRIPTOR)
        field(PRIORITY_DESCRIPTOR)
        field(RESOURCEDIGESTS_DESCRIPTOR)
        field(RETENTIONMODE_DESCRIPTOR)
        field(ROLEARN_DESCRIPTOR)
        field(RUNGROUPID_DESCRIPTOR)
        field(RUNID_DESCRIPTOR)
        field(RUNOUTPUTURI_DESCRIPTOR)
        field(STARTTIME_DESCRIPTOR)
        field(STARTEDBY_DESCRIPTOR)
        field(STATUS_DESCRIPTOR)
        field(STATUSMESSAGE_DESCRIPTOR)
        field(STOPTIME_DESCRIPTOR)
        field(STORAGECAPACITY_DESCRIPTOR)
        field(TAGS_DESCRIPTOR)
        field(UUID_DESCRIPTOR)
        field(WORKFLOWID_DESCRIPTOR)
        field(WORKFLOWTYPE_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                ACCELERATORS_DESCRIPTOR.index -> builder.accelerators = deserializeString().let { Accelerators.fromValue(it) }
                ARN_DESCRIPTOR.index -> builder.arn = deserializeString()
                CREATIONTIME_DESCRIPTOR.index -> builder.creationTime = deserializeString().let { Instant.fromIso8601(it) }
                DEFINITION_DESCRIPTOR.index -> builder.definition = deserializeString()
                DIGEST_DESCRIPTOR.index -> builder.digest = deserializeString()
                FAILUREREASON_DESCRIPTOR.index -> builder.failureReason = deserializeString()
                ID_DESCRIPTOR.index -> builder.id = deserializeString()
                LOGLEVEL_DESCRIPTOR.index -> builder.logLevel = deserializeString().let { RunLogLevel.fromValue(it) }
                LOGLOCATION_DESCRIPTOR.index -> builder.logLocation = deserializeRunLogLocationDocument(deserializer)
                NAME_DESCRIPTOR.index -> builder.name = deserializeString()
                OUTPUTURI_DESCRIPTOR.index -> builder.outputUri = deserializeString()
                PARAMETERS_DESCRIPTOR.index -> builder.parameters = deserializeDocument()
                PRIORITY_DESCRIPTOR.index -> builder.priority = deserializeInt()
                RESOURCEDIGESTS_DESCRIPTOR.index -> builder.resourceDigests =
                    deserializer.deserializeMap(RESOURCEDIGESTS_DESCRIPTOR) {
                        val map0 = mutableMapOf()
                        while (hasNextEntry()) {
                            val k0 = key()
                            val v0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
                            map0[k0] = v0
                        }
                        map0
                    }
                RETENTIONMODE_DESCRIPTOR.index -> builder.retentionMode = deserializeString().let { RunRetentionMode.fromValue(it) }
                ROLEARN_DESCRIPTOR.index -> builder.roleArn = deserializeString()
                RUNGROUPID_DESCRIPTOR.index -> builder.runGroupId = deserializeString()
                RUNID_DESCRIPTOR.index -> builder.runId = deserializeString()
                RUNOUTPUTURI_DESCRIPTOR.index -> builder.runOutputUri = deserializeString()
                STARTTIME_DESCRIPTOR.index -> builder.startTime = deserializeString().let { Instant.fromIso8601(it) }
                STARTEDBY_DESCRIPTOR.index -> builder.startedBy = deserializeString()
                STATUS_DESCRIPTOR.index -> builder.status = deserializeString().let { RunStatus.fromValue(it) }
                STATUSMESSAGE_DESCRIPTOR.index -> builder.statusMessage = deserializeString()
                STOPTIME_DESCRIPTOR.index -> builder.stopTime = deserializeString().let { Instant.fromIso8601(it) }
                STORAGECAPACITY_DESCRIPTOR.index -> builder.storageCapacity = deserializeInt()
                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
                    }
                UUID_DESCRIPTOR.index -> builder.uuid = deserializeString()
                WORKFLOWID_DESCRIPTOR.index -> builder.workflowId = deserializeString()
                WORKFLOWTYPE_DESCRIPTOR.index -> builder.workflowType = deserializeString().let { WorkflowType.fromValue(it) }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy