commonMain.aws.sdk.kotlin.services.datasync.serde.DescribeLocationS3OperationDeserializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datasync-jvm Show documentation
Show all versions of datasync-jvm Show documentation
The AWS SDK for Kotlin client for DataSync
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.datasync.serde
import aws.sdk.kotlin.services.datasync.model.DataSyncException
import aws.sdk.kotlin.services.datasync.model.DescribeLocationS3Response
import aws.sdk.kotlin.services.datasync.model.S3Config
import aws.sdk.kotlin.services.datasync.model.S3StorageClass
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 DescribeLocationS3OperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): DescribeLocationS3Response {
val response = call.response
if (!response.status.isSuccess()) {
throwDescribeLocationS3Error(context, call, payload)
}
val builder = DescribeLocationS3Response.Builder()
if (payload != null) {
deserializeDescribeLocationS3OperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwDescribeLocationS3Error(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 DataSyncException("Failed to parse response as 'awsJson1_1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"InternalException" -> InternalExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InvalidRequestException" -> InvalidRequestExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> DataSyncException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeDescribeLocationS3OperationBody(builder: DescribeLocationS3Response.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val AGENTARNS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("AgentArns"))
val CREATIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CreationTime"))
val LOCATIONARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LocationArn"))
val LOCATIONURI_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LocationUri"))
val S3CONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("S3Config"))
val S3STORAGECLASS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("S3StorageClass"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(AGENTARNS_DESCRIPTOR)
field(CREATIONTIME_DESCRIPTOR)
field(LOCATIONARN_DESCRIPTOR)
field(LOCATIONURI_DESCRIPTOR)
field(S3CONFIG_DESCRIPTOR)
field(S3STORAGECLASS_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
AGENTARNS_DESCRIPTOR.index -> builder.agentArns =
deserializer.deserializeList(AGENTARNS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
col0.add(el0)
}
col0
}
CREATIONTIME_DESCRIPTOR.index -> builder.creationTime = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
LOCATIONARN_DESCRIPTOR.index -> builder.locationArn = deserializeString()
LOCATIONURI_DESCRIPTOR.index -> builder.locationUri = deserializeString()
S3CONFIG_DESCRIPTOR.index -> builder.s3Config = deserializeS3ConfigDocument(deserializer)
S3STORAGECLASS_DESCRIPTOR.index -> builder.s3StorageClass = deserializeString().let { S3StorageClass.fromValue(it) }
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy