All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.pi.serde.InsightDocumentDeserializer.kt Maven / Gradle / Ivy

// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.pi.serde

import aws.sdk.kotlin.services.pi.model.ContextType
import aws.sdk.kotlin.services.pi.model.Data
import aws.sdk.kotlin.services.pi.model.Insight
import aws.sdk.kotlin.services.pi.model.Recommendation
import aws.sdk.kotlin.services.pi.model.Severity
import aws.smithy.kotlin.runtime.serde.Deserializer
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 fun deserializeInsightDocument(deserializer: Deserializer): Insight {
    val builder = Insight.Builder()
    val BASELINEDATA_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("BaselineData"))
    val CONTEXT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Context"))
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Description"))
    val ENDTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("EndTime"))
    val INSIGHTDATA_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("InsightData"))
    val INSIGHTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("InsightId"))
    val INSIGHTTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("InsightType"))
    val RECOMMENDATIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Recommendations"))
    val SEVERITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("Severity"))
    val STARTTIME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("StartTime"))
    val SUPPORTINGINSIGHTS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("SupportingInsights"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(BASELINEDATA_DESCRIPTOR)
        field(CONTEXT_DESCRIPTOR)
        field(DESCRIPTION_DESCRIPTOR)
        field(ENDTIME_DESCRIPTOR)
        field(INSIGHTDATA_DESCRIPTOR)
        field(INSIGHTID_DESCRIPTOR)
        field(INSIGHTTYPE_DESCRIPTOR)
        field(RECOMMENDATIONS_DESCRIPTOR)
        field(SEVERITY_DESCRIPTOR)
        field(STARTTIME_DESCRIPTOR)
        field(SUPPORTINGINSIGHTS_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                BASELINEDATA_DESCRIPTOR.index -> builder.baselineData =
                    deserializer.deserializeList(BASELINEDATA_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                CONTEXT_DESCRIPTOR.index -> builder.context = deserializeString().let { ContextType.fromValue(it) }
                DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
                ENDTIME_DESCRIPTOR.index -> builder.endTime = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                INSIGHTDATA_DESCRIPTOR.index -> builder.insightData =
                    deserializer.deserializeList(INSIGHTDATA_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeDataDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                INSIGHTID_DESCRIPTOR.index -> builder.insightId = deserializeString()
                INSIGHTTYPE_DESCRIPTOR.index -> builder.insightType = deserializeString()
                RECOMMENDATIONS_DESCRIPTOR.index -> builder.recommendations =
                    deserializer.deserializeList(RECOMMENDATIONS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeRecommendationDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                SEVERITY_DESCRIPTOR.index -> builder.severity = deserializeString().let { Severity.fromValue(it) }
                STARTTIME_DESCRIPTOR.index -> builder.startTime = deserializeInstant(TimestampFormat.EPOCH_SECONDS)
                SUPPORTINGINSIGHTS_DESCRIPTOR.index -> builder.supportingInsights =
                    deserializer.deserializeList(SUPPORTINGINSIGHTS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeInsightDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
    builder.correctErrors()
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy