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

commonMain.aws.sdk.kotlin.services.ssm.serde.UpdateMaintenanceWindowTaskOperationDeserializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.ssm.serde

import aws.sdk.kotlin.services.ssm.model.AlarmConfiguration
import aws.sdk.kotlin.services.ssm.model.LoggingInfo
import aws.sdk.kotlin.services.ssm.model.MaintenanceWindowTaskCutoffBehavior
import aws.sdk.kotlin.services.ssm.model.MaintenanceWindowTaskInvocationParameters
import aws.sdk.kotlin.services.ssm.model.MaintenanceWindowTaskParameterValueExpression
import aws.sdk.kotlin.services.ssm.model.SsmException
import aws.sdk.kotlin.services.ssm.model.Target
import aws.sdk.kotlin.services.ssm.model.UpdateMaintenanceWindowTaskResponse
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 kotlin.collections.mutableListOf
import kotlin.collections.mutableMapOf


internal class UpdateMaintenanceWindowTaskOperationDeserializer: HttpDeserializer.NonStreaming {

    override fun deserialize(context: ExecutionContext, call: HttpCall, payload: ByteArray?): UpdateMaintenanceWindowTaskResponse {
        val response = call.response
        if (!response.status.isSuccess()) {
            throwUpdateMaintenanceWindowTaskError(context, call, payload)
        }
        val builder = UpdateMaintenanceWindowTaskResponse.Builder()

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

private fun throwUpdateMaintenanceWindowTaskError(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 SsmException("Failed to parse response as 'awsJson1_1' error", ex).also {
            setAseErrorMetadata(it, wrappedCall.response, null)
        }
    }

    val ex = when(errorDetails.code) {
        "DoesNotExistException" -> DoesNotExistExceptionDeserializer().deserialize(context, wrappedCall, payload)
        "InternalServerError" -> InternalServerErrorDeserializer().deserialize(context, wrappedCall, payload)
        else -> SsmException(errorDetails.message)
    }

    setAseErrorMetadata(ex, wrappedResponse, errorDetails)
    throw ex
}

private fun deserializeUpdateMaintenanceWindowTaskOperationBody(builder: UpdateMaintenanceWindowTaskResponse.Builder, payload: ByteArray) {
    val deserializer = JsonDeserializer(payload)
    val ALARMCONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("AlarmConfiguration"))
    val CUTOFFBEHAVIOR_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("CutoffBehavior"))
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Description"))
    val LOGGINGINFO_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("LoggingInfo"))
    val MAXCONCURRENCY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MaxConcurrency"))
    val MAXERRORS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("MaxErrors"))
    val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("Name"))
    val PRIORITY_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("Priority"))
    val SERVICEROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("ServiceRoleArn"))
    val TARGETS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Targets"))
    val TASKARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("TaskArn"))
    val TASKINVOCATIONPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("TaskInvocationParameters"))
    val TASKPARAMETERS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Map, JsonSerialName("TaskParameters"))
    val WINDOWID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("WindowId"))
    val WINDOWTASKID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("WindowTaskId"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ALARMCONFIGURATION_DESCRIPTOR)
        field(CUTOFFBEHAVIOR_DESCRIPTOR)
        field(DESCRIPTION_DESCRIPTOR)
        field(LOGGINGINFO_DESCRIPTOR)
        field(MAXCONCURRENCY_DESCRIPTOR)
        field(MAXERRORS_DESCRIPTOR)
        field(NAME_DESCRIPTOR)
        field(PRIORITY_DESCRIPTOR)
        field(SERVICEROLEARN_DESCRIPTOR)
        field(TARGETS_DESCRIPTOR)
        field(TASKARN_DESCRIPTOR)
        field(TASKINVOCATIONPARAMETERS_DESCRIPTOR)
        field(TASKPARAMETERS_DESCRIPTOR)
        field(WINDOWID_DESCRIPTOR)
        field(WINDOWTASKID_DESCRIPTOR)
    }

    deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
        loop@while (true) {
            when (findNextFieldIndex()) {
                ALARMCONFIGURATION_DESCRIPTOR.index -> builder.alarmConfiguration = deserializeAlarmConfigurationDocument(deserializer)
                CUTOFFBEHAVIOR_DESCRIPTOR.index -> builder.cutoffBehavior = deserializeString().let { MaintenanceWindowTaskCutoffBehavior.fromValue(it) }
                DESCRIPTION_DESCRIPTOR.index -> builder.description = deserializeString()
                LOGGINGINFO_DESCRIPTOR.index -> builder.loggingInfo = deserializeLoggingInfoDocument(deserializer)
                MAXCONCURRENCY_DESCRIPTOR.index -> builder.maxConcurrency = deserializeString()
                MAXERRORS_DESCRIPTOR.index -> builder.maxErrors = deserializeString()
                NAME_DESCRIPTOR.index -> builder.name = deserializeString()
                PRIORITY_DESCRIPTOR.index -> builder.priority = deserializeInt()
                SERVICEROLEARN_DESCRIPTOR.index -> builder.serviceRoleArn = deserializeString()
                TARGETS_DESCRIPTOR.index -> builder.targets =
                    deserializer.deserializeList(TARGETS_DESCRIPTOR) {
                        val col0 = mutableListOf()
                        while (hasNextElement()) {
                            val el0 = if (nextHasValue()) { deserializeTargetDocument(deserializer) } else { deserializeNull(); continue }
                            col0.add(el0)
                        }
                        col0
                    }
                TASKARN_DESCRIPTOR.index -> builder.taskArn = deserializeString()
                TASKINVOCATIONPARAMETERS_DESCRIPTOR.index -> builder.taskInvocationParameters = deserializeMaintenanceWindowTaskInvocationParametersDocument(deserializer)
                TASKPARAMETERS_DESCRIPTOR.index -> builder.taskParameters =
                    deserializer.deserializeMap(TASKPARAMETERS_DESCRIPTOR) {
                        val map0 = mutableMapOf()
                        while (hasNextEntry()) {
                            val k0 = key()
                            val v0 = if (nextHasValue()) { deserializeMaintenanceWindowTaskParameterValueExpressionDocument(deserializer) } else { deserializeNull(); continue }
                            map0[k0] = v0
                        }
                        map0
                    }
                WINDOWID_DESCRIPTOR.index -> builder.windowId = deserializeString()
                WINDOWTASKID_DESCRIPTOR.index -> builder.windowTaskId = deserializeString()
                null -> break@loop
                else -> skipValue()
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy