commonMain.aws.sdk.kotlin.services.configservice.serde.GetResourceEvaluationSummaryOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.configservice.serde
import aws.sdk.kotlin.services.configservice.model.ComplianceType
import aws.sdk.kotlin.services.configservice.model.ConfigException
import aws.sdk.kotlin.services.configservice.model.EvaluationContext
import aws.sdk.kotlin.services.configservice.model.EvaluationMode
import aws.sdk.kotlin.services.configservice.model.EvaluationStatus
import aws.sdk.kotlin.services.configservice.model.GetResourceEvaluationSummaryResponse
import aws.sdk.kotlin.services.configservice.model.ResourceDetails
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 GetResourceEvaluationSummaryOperationDeserializer: HttpDeserializer.NonStreaming {
override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): GetResourceEvaluationSummaryResponse {
val response = call.response
if (!response.status.isSuccess()) {
throwGetResourceEvaluationSummaryError(context, call, payload)
}
val builder = GetResourceEvaluationSummaryResponse.Builder()
if (payload != null) {
deserializeGetResourceEvaluationSummaryOperationBody(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
private fun throwGetResourceEvaluationSummaryError(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 ConfigException("Failed to parse response as 'awsJson1_1' error", ex).also {
setAseErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedCall, payload)
else -> ConfigException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeGetResourceEvaluationSummaryOperationBody(builder: GetResourceEvaluationSummaryResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val COMPLIANCE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Compliance"))
val EVALUATIONCONTEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("EvaluationContext"))
val EVALUATIONMODE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("EvaluationMode"))
val EVALUATIONSTARTTIMESTAMP_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("EvaluationStartTimestamp"))
val EVALUATIONSTATUS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("EvaluationStatus"))
val RESOURCEDETAILS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("ResourceDetails"))
val RESOURCEEVALUATIONID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ResourceEvaluationId"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(COMPLIANCE_DESCRIPTOR)
field(EVALUATIONCONTEXT_DESCRIPTOR)
field(EVALUATIONMODE_DESCRIPTOR)
field(EVALUATIONSTARTTIMESTAMP_DESCRIPTOR)
field(EVALUATIONSTATUS_DESCRIPTOR)
field(RESOURCEDETAILS_DESCRIPTOR)
field(RESOURCEEVALUATIONID_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
COMPLIANCE_DESCRIPTOR.index -> builder.compliance = deserializeString().let { ComplianceType.fromValue(it) }
EVALUATIONCONTEXT_DESCRIPTOR.index -> builder.evaluationContext = deserializeEvaluationContextDocument(deserializer)
EVALUATIONMODE_DESCRIPTOR.index -> builder.evaluationMode = deserializeString().let { EvaluationMode.fromValue(it) }
EVALUATIONSTARTTIMESTAMP_DESCRIPTOR.index -> builder.evaluationStartTimestamp = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
EVALUATIONSTATUS_DESCRIPTOR.index -> builder.evaluationStatus = deserializeEvaluationStatusDocument(deserializer)
RESOURCEDETAILS_DESCRIPTOR.index -> builder.resourceDetails = deserializeResourceDetailsDocument(deserializer)
RESOURCEEVALUATIONID_DESCRIPTOR.index -> builder.resourceEvaluationId = deserializeString()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy