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

commonMain.aws.sdk.kotlin.services.computeoptimizer.transform.InstanceRecommendationDocumentDeserializer.kt Maven / Gradle / Ivy

There is a newer version: 1.3.99
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.computeoptimizer.transform

import aws.sdk.kotlin.services.computeoptimizer.model.CurrentPerformanceRisk
import aws.sdk.kotlin.services.computeoptimizer.model.Finding
import aws.sdk.kotlin.services.computeoptimizer.model.InferredWorkloadType
import aws.sdk.kotlin.services.computeoptimizer.model.InstanceRecommendation
import aws.sdk.kotlin.services.computeoptimizer.model.InstanceRecommendationFindingReasonCode
import aws.sdk.kotlin.services.computeoptimizer.model.InstanceRecommendationOption
import aws.sdk.kotlin.services.computeoptimizer.model.InstanceState
import aws.sdk.kotlin.services.computeoptimizer.model.RecommendationSource
import aws.sdk.kotlin.services.computeoptimizer.model.Tag
import aws.sdk.kotlin.services.computeoptimizer.model.UtilizationMetric
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 kotlin.collections.mutableListOf

internal fun deserializeInstanceRecommendationDocument(deserializer: Deserializer): InstanceRecommendation {
    val builder = InstanceRecommendation.Builder()
    val ACCOUNTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("accountId"))
    val CURRENTINSTANCETYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("currentInstanceType"))
    val CURRENTPERFORMANCERISK_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("currentPerformanceRisk"))
    val EFFECTIVERECOMMENDATIONPREFERENCES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("effectiveRecommendationPreferences"))
    val FINDING_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("finding"))
    val FINDINGREASONCODES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("findingReasonCodes"))
    val INFERREDWORKLOADTYPES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("inferredWorkloadTypes"))
    val INSTANCEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("instanceArn"))
    val INSTANCENAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("instanceName"))
    val INSTANCESTATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("instanceState"))
    val LASTREFRESHTIMESTAMP_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Timestamp, JsonSerialName("lastRefreshTimestamp"))
    val LOOKBACKPERIODINDAYS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Double, JsonSerialName("lookBackPeriodInDays"))
    val RECOMMENDATIONOPTIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("recommendationOptions"))
    val RECOMMENDATIONSOURCES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("recommendationSources"))
    val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("tags"))
    val UTILIZATIONMETRICS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("utilizationMetrics"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ACCOUNTID_DESCRIPTOR)
        field(CURRENTINSTANCETYPE_DESCRIPTOR)
        field(CURRENTPERFORMANCERISK_DESCRIPTOR)
        field(EFFECTIVERECOMMENDATIONPREFERENCES_DESCRIPTOR)
        field(FINDING_DESCRIPTOR)
        field(FINDINGREASONCODES_DESCRIPTOR)
        field(INFERREDWORKLOADTYPES_DESCRIPTOR)
        field(INSTANCEARN_DESCRIPTOR)
        field(INSTANCENAME_DESCRIPTOR)
        field(INSTANCESTATE_DESCRIPTOR)
        field(LASTREFRESHTIMESTAMP_DESCRIPTOR)
        field(LOOKBACKPERIODINDAYS_DESCRIPTOR)
        field(RECOMMENDATIONOPTIONS_DESCRIPTOR)
        field(RECOMMENDATIONSOURCES_DESCRIPTOR)
        field(TAGS_DESCRIPTOR)
        field(UTILIZATIONMETRICS_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                ACCOUNTID_DESCRIPTOR.index -> builder.accountId = deserializeString()
                CURRENTINSTANCETYPE_DESCRIPTOR.index -> builder.currentInstanceType = deserializeString()
                CURRENTPERFORMANCERISK_DESCRIPTOR.index -> builder.currentPerformanceRisk = deserializeString().let { CurrentPerformanceRisk.fromValue(it) }
                EFFECTIVERECOMMENDATIONPREFERENCES_DESCRIPTOR.index -> builder.effectiveRecommendationPreferences = deserializeEffectiveRecommendationPreferencesDocument(deserializer)
                FINDING_DESCRIPTOR.index -> builder.finding = deserializeString().let { Finding.fromValue(it) }
                FINDINGREASONCODES_DESCRIPTOR.index -> builder.findingReasonCodes =
                    deserializer.deserializeList(FINDINGREASONCODES_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeString().let { InstanceRecommendationFindingReasonCode.fromValue(it) } } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                INFERREDWORKLOADTYPES_DESCRIPTOR.index -> builder.inferredWorkloadTypes =
                    deserializer.deserializeList(INFERREDWORKLOADTYPES_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeString().let { InferredWorkloadType.fromValue(it) } } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                INSTANCEARN_DESCRIPTOR.index -> builder.instanceArn = deserializeString()
                INSTANCENAME_DESCRIPTOR.index -> builder.instanceName = deserializeString()
                INSTANCESTATE_DESCRIPTOR.index -> builder.instanceState = deserializeString().let { InstanceState.fromValue(it) }
                LASTREFRESHTIMESTAMP_DESCRIPTOR.index -> builder.lastRefreshTimestamp = deserializeString().let { Instant.fromEpochSeconds(it) }
                LOOKBACKPERIODINDAYS_DESCRIPTOR.index -> builder.lookBackPeriodInDays = deserializeDouble()
                RECOMMENDATIONOPTIONS_DESCRIPTOR.index -> builder.recommendationOptions =
                    deserializer.deserializeList(RECOMMENDATIONOPTIONS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeInstanceRecommendationOptionDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                RECOMMENDATIONSOURCES_DESCRIPTOR.index -> builder.recommendationSources =
                    deserializer.deserializeList(RECOMMENDATIONSOURCES_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeRecommendationSourceDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                TAGS_DESCRIPTOR.index -> builder.tags =
                    deserializer.deserializeList(TAGS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeTagDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                UTILIZATIONMETRICS_DESCRIPTOR.index -> builder.utilizationMetrics =
                    deserializer.deserializeList(UTILIZATIONMETRICS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeUtilizationMetricDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                null -> break@loop
                else -> skipValue()
            }
        }
    }
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy