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

commonMain.aws.sdk.kotlin.services.appsync.serde.UpdateDataSourceOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.appsync.serde

import aws.sdk.kotlin.services.appsync.model.DataSourceLevelMetricsConfig
import aws.sdk.kotlin.services.appsync.model.DataSourceType
import aws.sdk.kotlin.services.appsync.model.DynamodbDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.ElasticsearchDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.EventBridgeDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.HttpDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.LambdaDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.OpenSearchServiceDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.RelationalDatabaseDataSourceConfig
import aws.sdk.kotlin.services.appsync.model.UpdateDataSourceRequest
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.operation.HttpSerializer
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
import aws.smithy.kotlin.runtime.http.request.url
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.json.JsonSerializer
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.text.encoding.PercentEncoding


internal class UpdateDataSourceOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: UpdateDataSourceRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

        builder.url {
            requireNotNull(input.apiId) { "apiId is bound to the URI and must not be null" }
            requireNotNull(input.name) { "name is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("v1"))
                add(PercentEncoding.Path.encode("apis"))
                add(PercentEncoding.SmithyLabel.encode(input.apiId))
                add(PercentEncoding.Path.encode("datasources"))
                add(PercentEncoding.SmithyLabel.encode(input.name))
            }
        }

        val payload = serializeUpdateDataSourceOperationBody(context, input)
        builder.body = HttpBody.fromBytes(payload)
        if (builder.body !is HttpBody.Empty) {
            builder.headers.setMissing("Content-Type", "application/json")
        }
        return builder
    }
}

private fun serializeUpdateDataSourceOperationBody(context: ExecutionContext, input: UpdateDataSourceRequest): ByteArray {
    val serializer = JsonSerializer()
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
    val DYNAMODBCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("dynamodbConfig"))
    val ELASTICSEARCHCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("elasticsearchConfig"))
    val EVENTBRIDGECONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("eventBridgeConfig"))
    val HTTPCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("httpConfig"))
    val LAMBDACONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("lambdaConfig"))
    val METRICSCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("metricsConfig"))
    val OPENSEARCHSERVICECONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("openSearchServiceConfig"))
    val RELATIONALDATABASECONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("relationalDatabaseConfig"))
    val SERVICEROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("serviceRoleArn"))
    val TYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("type"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(DESCRIPTION_DESCRIPTOR)
        field(DYNAMODBCONFIG_DESCRIPTOR)
        field(ELASTICSEARCHCONFIG_DESCRIPTOR)
        field(EVENTBRIDGECONFIG_DESCRIPTOR)
        field(HTTPCONFIG_DESCRIPTOR)
        field(LAMBDACONFIG_DESCRIPTOR)
        field(METRICSCONFIG_DESCRIPTOR)
        field(OPENSEARCHSERVICECONFIG_DESCRIPTOR)
        field(RELATIONALDATABASECONFIG_DESCRIPTOR)
        field(SERVICEROLEARN_DESCRIPTOR)
        field(TYPE_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.description?.let { field(DESCRIPTION_DESCRIPTOR, it) }
        input.dynamodbConfig?.let { field(DYNAMODBCONFIG_DESCRIPTOR, it, ::serializeDynamodbDataSourceConfigDocument) }
        input.elasticsearchConfig?.let { field(ELASTICSEARCHCONFIG_DESCRIPTOR, it, ::serializeElasticsearchDataSourceConfigDocument) }
        input.eventBridgeConfig?.let { field(EVENTBRIDGECONFIG_DESCRIPTOR, it, ::serializeEventBridgeDataSourceConfigDocument) }
        input.httpConfig?.let { field(HTTPCONFIG_DESCRIPTOR, it, ::serializeHttpDataSourceConfigDocument) }
        input.lambdaConfig?.let { field(LAMBDACONFIG_DESCRIPTOR, it, ::serializeLambdaDataSourceConfigDocument) }
        input.metricsConfig?.let { field(METRICSCONFIG_DESCRIPTOR, it.value) }
        input.openSearchServiceConfig?.let { field(OPENSEARCHSERVICECONFIG_DESCRIPTOR, it, ::serializeOpenSearchServiceDataSourceConfigDocument) }
        input.relationalDatabaseConfig?.let { field(RELATIONALDATABASECONFIG_DESCRIPTOR, it, ::serializeRelationalDatabaseDataSourceConfigDocument) }
        input.serviceRoleArn?.let { field(SERVICEROLEARN_DESCRIPTOR, it) }
        input.type?.let { field(TYPE_DESCRIPTOR, it.value) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy