commonMain.aws.sdk.kotlin.services.glacier.serde.DescribeJobOperationDeserializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glacier-jvm Show documentation
Show all versions of glacier-jvm Show documentation
The AWS Kotlin client for Glacier
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.glacier.serde
import aws.sdk.kotlin.services.glacier.model.ActionCode
import aws.sdk.kotlin.services.glacier.model.DescribeJobResponse
import aws.sdk.kotlin.services.glacier.model.GlacierException
import aws.sdk.kotlin.services.glacier.model.InventoryRetrievalJobDescription
import aws.sdk.kotlin.services.glacier.model.OutputLocation
import aws.sdk.kotlin.services.glacier.model.SelectParameters
import aws.sdk.kotlin.services.glacier.model.StatusCode
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
internal class DescribeJobOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): DescribeJobResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwDescribeJobError(context, call, payload)
}
val builder = DescribeJobResponse.Builder()
if (payload != null) {
deserializeDescribeJobOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwDescribeJobError(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 GlacierException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"MissingParameterValueException" -> MissingParameterValueExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InvalidParameterValueException" -> InvalidParameterValueExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ServiceUnavailableException" -> ServiceUnavailableExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> GlacierException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeDescribeJobOperationBody(builder: DescribeJobResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val ACTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Action"))
val ARCHIVEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ArchiveId"))
val ARCHIVESHA256TREEHASH_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ArchiveSHA256TreeHash"))
val ARCHIVESIZEINBYTES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("ArchiveSizeInBytes"))
val COMPLETED_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("Completed"))
val COMPLETIONDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("CompletionDate"))
val CREATIONDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("CreationDate"))
val INVENTORYRETRIEVALPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("InventoryRetrievalParameters"))
val INVENTORYSIZEINBYTES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("InventorySizeInBytes"))
val JOBDESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobDescription"))
val JOBID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobId"))
val JOBOUTPUTPATH_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("JobOutputPath"))
val OUTPUTLOCATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("OutputLocation"))
val RETRIEVALBYTERANGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RetrievalByteRange"))
val SHA256TREEHASH_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SHA256TreeHash"))
val SNSTOPIC_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SNSTopic"))
val SELECTPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("SelectParameters"))
val STATUSCODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("StatusCode"))
val STATUSMESSAGE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("StatusMessage"))
val TIER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Tier"))
val VAULTARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("VaultARN"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(ACTION_DESCRIPTOR)
field(ARCHIVEID_DESCRIPTOR)
field(ARCHIVESHA256TREEHASH_DESCRIPTOR)
field(ARCHIVESIZEINBYTES_DESCRIPTOR)
field(COMPLETED_DESCRIPTOR)
field(COMPLETIONDATE_DESCRIPTOR)
field(CREATIONDATE_DESCRIPTOR)
field(INVENTORYRETRIEVALPARAMETERS_DESCRIPTOR)
field(INVENTORYSIZEINBYTES_DESCRIPTOR)
field(JOBDESCRIPTION_DESCRIPTOR)
field(JOBID_DESCRIPTOR)
field(JOBOUTPUTPATH_DESCRIPTOR)
field(OUTPUTLOCATION_DESCRIPTOR)
field(RETRIEVALBYTERANGE_DESCRIPTOR)
field(SHA256TREEHASH_DESCRIPTOR)
field(SNSTOPIC_DESCRIPTOR)
field(SELECTPARAMETERS_DESCRIPTOR)
field(STATUSCODE_DESCRIPTOR)
field(STATUSMESSAGE_DESCRIPTOR)
field(TIER_DESCRIPTOR)
field(VAULTARN_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
ACTION_DESCRIPTOR.index -> builder.action = deserializeString().let { ActionCode.fromValue(it) }
ARCHIVEID_DESCRIPTOR.index -> builder.archiveId = deserializeString()
ARCHIVESHA256TREEHASH_DESCRIPTOR.index -> builder.archiveSha256TreeHash = deserializeString()
ARCHIVESIZEINBYTES_DESCRIPTOR.index -> builder.archiveSizeInBytes = deserializeLong()
COMPLETED_DESCRIPTOR.index -> builder.completed = deserializeBoolean()
COMPLETIONDATE_DESCRIPTOR.index -> builder.completionDate = deserializeString()
CREATIONDATE_DESCRIPTOR.index -> builder.creationDate = deserializeString()
INVENTORYRETRIEVALPARAMETERS_DESCRIPTOR.index -> builder.inventoryRetrievalParameters = deserializeInventoryRetrievalJobDescriptionDocument(deserializer)
INVENTORYSIZEINBYTES_DESCRIPTOR.index -> builder.inventorySizeInBytes = deserializeLong()
JOBDESCRIPTION_DESCRIPTOR.index -> builder.jobDescription = deserializeString()
JOBID_DESCRIPTOR.index -> builder.jobId = deserializeString()
JOBOUTPUTPATH_DESCRIPTOR.index -> builder.jobOutputPath = deserializeString()
OUTPUTLOCATION_DESCRIPTOR.index -> builder.outputLocation = deserializeOutputLocationDocument(deserializer)
RETRIEVALBYTERANGE_DESCRIPTOR.index -> builder.retrievalByteRange = deserializeString()
SHA256TREEHASH_DESCRIPTOR.index -> builder.sha256TreeHash = deserializeString()
SNSTOPIC_DESCRIPTOR.index -> builder.snsTopic = deserializeString()
SELECTPARAMETERS_DESCRIPTOR.index -> builder.selectParameters = deserializeSelectParametersDocument(deserializer)
STATUSCODE_DESCRIPTOR.index -> builder.statusCode = deserializeString().let { StatusCode.fromValue(it) }
STATUSMESSAGE_DESCRIPTOR.index -> builder.statusMessage = deserializeString()
TIER_DESCRIPTOR.index -> builder.tier = deserializeString()
VAULTARN_DESCRIPTOR.index -> builder.vaultArn = deserializeString()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy