
commonMain.aws.sdk.kotlin.services.quicksight.transform.UpdateTemplatePermissionsOperationDeserializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.quicksight.transform
import aws.sdk.kotlin.runtime.http.setAseErrorMetadata
import aws.sdk.kotlin.runtime.http.withPayload
import aws.sdk.kotlin.runtime.protocol.json.RestJsonErrorDeserializer
import aws.sdk.kotlin.services.quicksight.model.QuickSightException
import aws.sdk.kotlin.services.quicksight.model.ResourcePermission
import aws.sdk.kotlin.services.quicksight.model.UpdateTemplatePermissionsResponse
import aws.smithy.kotlin.runtime.client.ExecutionContext
import aws.smithy.kotlin.runtime.http.isSuccess
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.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
internal class UpdateTemplatePermissionsOperationDeserializer: HttpDeserialize {
override suspend fun deserialize(context: ExecutionContext, response: HttpResponse): UpdateTemplatePermissionsResponse {
if (!response.status.isSuccess()) {
throwUpdateTemplatePermissionsError(context, response)
}
val builder = UpdateTemplatePermissionsResponse.Builder()
val payload = response.body.readAll()
if (payload != null) {
deserializeUpdateTemplatePermissionsOperationBody(builder, payload)
}
builder.status = response.status.value
return builder.build()
}
}
private suspend fun throwUpdateTemplatePermissionsError(context: ExecutionContext, response: HttpResponse): kotlin.Nothing {
val payload = response.body.readAll()
val wrappedResponse = response.withPayload(payload)
val errorDetails = try {
RestJsonErrorDeserializer.deserialize(response.headers, payload)
} catch (ex: Exception) {
throw QuickSightException("Failed to parse response as 'restJson1' error", ex).also {
setAseErrorMetadata(it, wrappedResponse, null)
}
}
val ex = when(errorDetails.code) {
"ConflictException" -> ConflictExceptionDeserializer().deserialize(context, wrappedResponse)
"InternalFailureException" -> InternalFailureExceptionDeserializer().deserialize(context, wrappedResponse)
"InvalidParameterValueException" -> InvalidParameterValueExceptionDeserializer().deserialize(context, wrappedResponse)
"ResourceNotFoundException" -> ResourceNotFoundExceptionDeserializer().deserialize(context, wrappedResponse)
"ThrottlingException" -> ThrottlingExceptionDeserializer().deserialize(context, wrappedResponse)
"UnsupportedUserEditionException" -> UnsupportedUserEditionExceptionDeserializer().deserialize(context, wrappedResponse)
else -> QuickSightException(errorDetails.message)
}
setAseErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
private fun deserializeUpdateTemplatePermissionsOperationBody(builder: UpdateTemplatePermissionsResponse.Builder, payload: ByteArray) {
val deserializer = JsonDeserializer(payload)
val PERMISSIONS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("Permissions"))
val REQUESTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("RequestId"))
val TEMPLATEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("TemplateArn"))
val TEMPLATEID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("TemplateId"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(PERMISSIONS_DESCRIPTOR)
field(REQUESTID_DESCRIPTOR)
field(TEMPLATEARN_DESCRIPTOR)
field(TEMPLATEID_DESCRIPTOR)
}
deserializer.deserializeStruct(OBJ_DESCRIPTOR) {
loop@while (true) {
when (findNextFieldIndex()) {
PERMISSIONS_DESCRIPTOR.index -> builder.permissions =
deserializer.deserializeList(PERMISSIONS_DESCRIPTOR) {
val col0 = mutableListOf()
while (hasNextElement()) {
val el0 = if (nextHasValue()) { deserializeResourcePermissionDocument(deserializer) } else { deserializeNull(); continue }
col0.add(el0)
}
col0
}
REQUESTID_DESCRIPTOR.index -> builder.requestId = deserializeString()
TEMPLATEARN_DESCRIPTOR.index -> builder.templateArn = deserializeString()
TEMPLATEID_DESCRIPTOR.index -> builder.templateId = deserializeString()
null -> break@loop
else -> skipValue()
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy