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

commonMain.aws.sdk.kotlin.services.cloudwatch.serde.ResourceNotFoundExceptionDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.cloudwatch.serde

import aws.sdk.kotlin.services.cloudwatch.model.ResourceNotFoundException
import aws.smithy.kotlin.runtime.http.HttpCall
import aws.smithy.kotlin.runtime.http.operation.HttpDeserializer
import aws.smithy.kotlin.runtime.http.response.HttpResponse
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.deserializeStruct
import aws.smithy.kotlin.runtime.serde.getOrDeserializeErr
import aws.smithy.kotlin.runtime.serde.xml.tryData
import aws.smithy.kotlin.runtime.serde.xml.xmlTagReader


internal class ResourceNotFoundExceptionDeserializer: HttpDeserializer.NonStreaming {

    override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): ResourceNotFoundException {
        val response = call.response
        val builder = ResourceNotFoundException.Builder()

        if (payload != null) {
            deserializeResourceNotFoundExceptionError(builder, payload)
        }
        builder.correctErrors()
        return builder.build()
    }
}

internal fun deserializeResourceNotFoundExceptionError(builder: ResourceNotFoundException.Builder, payload: ByteArray) {
    val root = xmlTagReader(payload)
    val errReader = unwrapWrappedXmlErrorResponse(root)

    loop@while (true) {
        val curr = errReader.nextTag() ?: break@loop
        when (curr.tagName) {
            // Message com.amazonaws.cloudwatch#ResourceNotFoundException$Message
            "Message" -> builder.message = curr.tryData()
                .getOrDeserializeErr { "expected (string: `com.amazonaws.cloudwatch#FaultDescription`)" }
            // ResourceId com.amazonaws.cloudwatch#ResourceNotFoundException$ResourceId
            "ResourceId" -> builder.resourceId = curr.tryData()
                .getOrDeserializeErr { "expected (string: `com.amazonaws.cloudwatch#ResourceId`)" }
            // ResourceType com.amazonaws.cloudwatch#ResourceNotFoundException$ResourceType
            "ResourceType" -> builder.resourceType = curr.tryData()
                .getOrDeserializeErr { "expected (string: `com.amazonaws.cloudwatch#ResourceType`)" }
            else -> {}
        }
        curr.drop()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy