
commonMain.aws.sdk.kotlin.services.apptest.serde.GetTestConfigurationOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.apptest.serde
import aws.sdk.kotlin.services.apptest.model.AppTestException
import aws.sdk.kotlin.services.apptest.model.GetTestConfigurationResponse
import aws.sdk.kotlin.services.apptest.model.Resource
import aws.sdk.kotlin.services.apptest.model.ServiceSettings
import aws.sdk.kotlin.services.apptest.model.TestConfigurationLatestVersion
import aws.sdk.kotlin.services.apptest.model.TestConfigurationLifecycle
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 kotlin.collections.mutableListOf
import kotlin.collections.mutableMapOf
internal class GetTestConfigurationOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): GetTestConfigurationResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwGetTestConfigurationError(context, call, payload)
}
val builder = GetTestConfigurationResponse.Builder()
if (payload != null) {
deserializeGetTestConfigurationOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwGetTestConfigurationError(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 AppTestException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"InternalServerException" -> InternalServerExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ValidationException" -> ValidationExceptionDeserializer().deserialize(context, wrappedCall, payload)
"ThrottlingException" -> ThrottlingExceptionDeserializer().deserialize(context, wrappedCall, payload)
"AccessDeniedException" -> AccessDeniedExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> AppTestException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeGetTestConfigurationOperationBody(builder: GetTestConfigurationResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val CREATIONTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("creationTime"))
val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
val LASTUPDATETIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("lastUpdateTime"))
val LATESTVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("latestVersion"))
val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
val PROPERTIES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("properties"))
val RESOURCES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("resources"))
val SERVICESETTINGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("serviceSettings"))
val STATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("status"))
val STATUSREASON_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("statusReason"))
val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("tags"))
val TESTCONFIGURATIONARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("testConfigurationArn"))
val TESTCONFIGURATIONID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("testConfigurationId"))
val TESTCONFIGURATIONVERSION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("testConfigurationVersion"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CREATIONTIME_DESCRIPTOR)
field(DESCRIPTION_DESCRIPTOR)
field(LASTUPDATETIME_DESCRIPTOR)
field(LATESTVERSION_DESCRIPTOR)
field(NAME_DESCRIPTOR)
field(PROPERTIES_DESCRIPTOR)
field(RESOURCES_DESCRIPTOR)
field(SERVICESETTINGS_DESCRIPTOR)
field(STATUS_DESCRIPTOR)
field(STATUSREASON_DESCRIPTOR)
field(TAGS_DESCRIPTOR)
field(TESTCONFIGURATIONARN_DESCRIPTOR)
field(TESTCONFIGURATIONID_DESCRIPTOR)
field(TESTCONFIGURATIONVERSION_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
CREATIONTIME_DESCRIPTOR.index -> builder.creationTime = deserializeString().let { Instant.fromEpochSeconds(it) }
DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
LASTUPDATETIME_DESCRIPTOR.index -> builder.lastUpdateTime = deserializeString().let { Instant.fromEpochSeconds(it) }
LATESTVERSION_DESCRIPTOR.index -> builder.latestVersion = deserializeTestConfigurationLatestVersionDocument(deserializer)
NAME_DESCRIPTOR.index -> builder.name = deserializeString()
PROPERTIES_DESCRIPTOR.index -> builder.properties =
deserializer.deserializeMap(PROPERTIES_DESCRIPTOR) {
val map0 = mutableMapOf()
while (hasNextEntry()) {
val k0 = key()
val v0 = if (nextHasValue()) { deserializeString() } else { deserializeNull(); continue }
map0[k0] = v0
}
map0
}
RESOURCES_DESCRIPTOR.index -> builder.resources =
deserializer.deserializeList(RESOURCES_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeResourceDocument(deserializer) } else { deserializeNull(); continue }
col0.add(el0)
}
col0
}
SERVICESETTINGS_DESCRIPTOR.index -> builder.serviceSettings = deserializeServiceSettingsDocument(deserializer)
STATUS_DESCRIPTOR.index -> builder.status = deserializeString().let { TestConfigurationLifecycle.fromValue(it) }
STATUSREASON_DESCRIPTOR.index -> builder.statusReason = deserializeString()
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
}
TESTCONFIGURATIONARN_DESCRIPTOR.index -> builder.testConfigurationArn = deserializeString()
TESTCONFIGURATIONID_DESCRIPTOR.index -> builder.testConfigurationId = deserializeString()
TESTCONFIGURATIONVERSION_DESCRIPTOR.index -> builder.testConfigurationVersion = deserializeInt()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy