commonMain.aws.sdk.kotlin.services.datasync.serde.DescribeLocationEfsOperationDeserializer.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.DescribeLocationEfsResponse
import aws.sdk.kotlin.services.datasync.model.Ec2Config
import aws.sdk.kotlin.services.datasync.model.EfsInTransitEncryption
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
internal class DescribeLocationEfsOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): DescribeLocationEfsResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwDescribeLocationEfsError(context, call, payload)
}
val builder = DescribeLocationEfsResponse.Builder()
if (payload != null) {
deserializeDescribeLocationEfsOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwDescribeLocationEfsError(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 deserializeDescribeLocationEfsOperationBody(builder: DescribeLocationEfsResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val ACCESSPOINTARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("AccessPointArn"))
val CREATIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("CreationTime"))
val EC2CONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("Ec2Config"))
val FILESYSTEMACCESSROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("FileSystemAccessRoleArn"))
val INTRANSITENCRYPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("InTransitEncryption"))
val LOCATIONARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LocationArn"))
val LOCATIONURI_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("LocationUri"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(ACCESSPOINTARN_DESCRIPTOR)
field(CREATIONTIME_DESCRIPTOR)
field(EC2CONFIG_DESCRIPTOR)
field(FILESYSTEMACCESSROLEARN_DESCRIPTOR)
field(INTRANSITENCRYPTION_DESCRIPTOR)
field(LOCATIONARN_DESCRIPTOR)
field(LOCATIONURI_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
ACCESSPOINTARN_DESCRIPTOR.index -> builder.accessPointArn = deserializeString()
CREATIONTIME_DESCRIPTOR.index -> builder.creationTime = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
EC2CONFIG_DESCRIPTOR.index -> builder.ec2Config = deserializeEc2ConfigDocument(deserializer)
FILESYSTEMACCESSROLEARN_DESCRIPTOR.index -> builder.fileSystemAccessRoleArn = deserializeString()
INTRANSITENCRYPTION_DESCRIPTOR.index -> builder.inTransitEncryption = deserializeString().let { EfsInTransitEncryption.fromValue(it) }
LOCATIONARN_DESCRIPTOR.index -> builder.locationArn = deserializeString()
LOCATIONURI_DESCRIPTOR.index -> builder.locationUri = deserializeString()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy