All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
commonMain.aws.sdk.kotlin.services.glue.serde.CreateSchemaOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.glue.serde
import aws.sdk.kotlin.services.glue.model.Compatibility
import aws.sdk.kotlin.services.glue.model.CreateSchemaResponse
import aws.sdk.kotlin.services.glue.model.DataFormat
import aws.sdk.kotlin.services.glue.model.GlueException
import aws.sdk.kotlin.services.glue.model.SchemaStatus
import aws.sdk.kotlin.services.glue.model.SchemaVersionStatus
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 kotlin.collections.mutableMapOf
internal class CreateSchemaOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): CreateSchemaResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwCreateSchemaError(context, call, payload)
}
val builder = CreateSchemaResponse.Builder()
if (payload != null) {
deserializeCreateSchemaOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwCreateSchemaError(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 GlueException("Failed to parse response as 'awsJson1_1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"ConcurrentModificationException" -> ConcurrentModificationExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InternalServiceException" -> InternalServiceExceptionDeserializer().deserialize(context, wrappedCall, payload)
"AlreadyExistsException" -> AlreadyExistsExceptionDeserializer().deserialize(context, wrappedCall, payload)
"EntityNotFoundException" -> EntityNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
"InvalidInputException" -> InvalidInputExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ResourceNumberLimitExceededException" -> ResourceNumberLimitExceededExceptionDeserializer().deserialize(context, wrappedCall, payload)
"AccessDeniedException" -> AccessDeniedExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> GlueException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeCreateSchemaOperationBody(builder: CreateSchemaResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val COMPATIBILITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Compatibility"))
val DATAFORMAT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("DataFormat"))
val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Description"))
val LATESTSCHEMAVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("LatestSchemaVersion"))
val NEXTSCHEMAVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("NextSchemaVersion"))
val REGISTRYARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RegistryArn"))
val REGISTRYNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RegistryName"))
val SCHEMAARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SchemaArn"))
val SCHEMACHECKPOINT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("SchemaCheckpoint"))
val SCHEMANAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SchemaName"))
val SCHEMASTATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("SchemaStatus"))
val SCHEMAVERSIONID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("SchemaVersionId"))
val SCHEMAVERSIONSTATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("SchemaVersionStatus"))
val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("Tags"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(COMPATIBILITY_DESCRIPTOR)
field(DATAFORMAT_DESCRIPTOR)
field(DESCRIPTION_DESCRIPTOR)
field(LATESTSCHEMAVERSION_DESCRIPTOR)
field(NEXTSCHEMAVERSION_DESCRIPTOR)
field(REGISTRYARN_DESCRIPTOR)
field(REGISTRYNAME_DESCRIPTOR)
field(SCHEMAARN_DESCRIPTOR)
field(SCHEMACHECKPOINT_DESCRIPTOR)
field(SCHEMANAME_DESCRIPTOR)
field(SCHEMASTATUS_DESCRIPTOR)
field(SCHEMAVERSIONID_DESCRIPTOR)
field(SCHEMAVERSIONSTATUS_DESCRIPTOR)
field(TAGS_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
COMPATIBILITY_DESCRIPTOR.index -> builder.compatibility = deserializeString().let { Compatibility.fromValue(it) }
DATAFORMAT_DESCRIPTOR.index -> builder.dataFormat = deserializeString().let { DataFormat.fromValue(it) }
DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
LATESTSCHEMAVERSION_DESCRIPTOR.index -> builder.latestSchemaVersion = deserializeLong()
NEXTSCHEMAVERSION_DESCRIPTOR.index -> builder.nextSchemaVersion = deserializeLong()
REGISTRYARN_DESCRIPTOR.index -> builder.registryArn = deserializeString()
REGISTRYNAME_DESCRIPTOR.index -> builder.registryName = deserializeString()
SCHEMAARN_DESCRIPTOR.index -> builder.schemaArn = deserializeString()
SCHEMACHECKPOINT_DESCRIPTOR.index -> builder.schemaCheckpoint = deserializeLong()
SCHEMANAME_DESCRIPTOR.index -> builder.schemaName = deserializeString()
SCHEMASTATUS_DESCRIPTOR.index -> builder.schemaStatus = deserializeString().let { SchemaStatus.fromValue(it) }
SCHEMAVERSIONID_DESCRIPTOR.index -> builder.schemaVersionId = deserializeString()
SCHEMAVERSIONSTATUS_DESCRIPTOR.index -> builder.schemaVersionStatus = deserializeString().let { SchemaVersionStatus.fromValue(it) }
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
}
null -> break@loop
else -> skipValue()
}
}
}
}