commonMain.aws.sdk.kotlin.services.cloudwatch.serde.InternalServiceFaultDeserializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudwatch-jvm Show documentation
Show all versions of cloudwatch-jvm Show documentation
The AWS SDK for Kotlin client for CloudWatch
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.cloudwatch.serde
import aws.sdk.kotlin.services.cloudwatch.model.InternalServiceFault
import aws.smithy.kotlin.runtime.http.HttpCall
import aws.smithy.kotlin.runtime.http.operation.HttpDeserialize
import aws.smithy.kotlin.runtime.http.readAll
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 InternalServiceFaultDeserializer: HttpDeserialize {
override suspend fun deserialize(context: ExecutionContext, call: HttpCall): InternalServiceFault {
val response = call.response
val builder = InternalServiceFault.Builder()
val payload = response.body.readAll()
if (payload != null) {
deserializeInternalServiceFaultError(builder, payload)
}
builder.correctErrors()
return builder.build()
}
}
internal fun deserializeInternalServiceFaultError(builder: InternalServiceFault.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#InternalServiceFault$Message
"Message" -> builder.message = curr.tryData()
.getOrDeserializeErr { "expected (string: `com.amazonaws.cloudwatch#FaultDescription`)" }
else -> {}
}
curr.drop()
}
}