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

commonMain.aws.sdk.kotlin.services.finspacedata.serde.CreateDataViewOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.finspacedata.serde

import aws.sdk.kotlin.services.finspacedata.model.CreateDataViewRequest
import aws.sdk.kotlin.services.finspacedata.model.DataViewDestinationTypeParams
import aws.smithy.kotlin.runtime.client.idempotencyTokenProvider
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 CreateDataViewOperationSerializer: HttpSerializer.NonStreaming {
    override fun serialize(context: ExecutionContext, input: CreateDataViewRequest): HttpRequestBuilder {
        val builder = HttpRequestBuilder()
        builder.method = HttpMethod.POST

        builder.url {
            requireNotNull(input.datasetId) { "datasetId is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("datasets"))
                add(PercentEncoding.SmithyLabel.encode(input.datasetId))
                add(PercentEncoding.Path.encode("dataviewsv2"))
            }
        }

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

private fun serializeCreateDataViewOperationBody(context: ExecutionContext, input: CreateDataViewRequest): ByteArray {
    val serializer = JsonSerializer()
    val ASOFTIMESTAMP_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Long, JsonSerialName("asOfTimestamp"))
    val AUTOUPDATE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("autoUpdate"))
    val CLIENTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientToken"))
    val DESTINATIONTYPEPARAMS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("destinationTypeParams"))
    val PARTITIONCOLUMNS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("partitionColumns"))
    val SORTCOLUMNS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("sortColumns"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(ASOFTIMESTAMP_DESCRIPTOR)
        field(AUTOUPDATE_DESCRIPTOR)
        field(CLIENTTOKEN_DESCRIPTOR)
        field(DESTINATIONTYPEPARAMS_DESCRIPTOR)
        field(PARTITIONCOLUMNS_DESCRIPTOR)
        field(SORTCOLUMNS_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.asOfTimestamp?.let { field(ASOFTIMESTAMP_DESCRIPTOR, it) }
        input.autoUpdate?.let { field(AUTOUPDATE_DESCRIPTOR, it) }
        input.clientToken?.let { field(CLIENTTOKEN_DESCRIPTOR, it) } ?: field(CLIENTTOKEN_DESCRIPTOR, context.idempotencyTokenProvider.generateToken())
        input.destinationTypeParams?.let { field(DESTINATIONTYPEPARAMS_DESCRIPTOR, it, ::serializeDataViewDestinationTypeParamsDocument) }
        if (input.partitionColumns != null) {
            listField(PARTITIONCOLUMNS_DESCRIPTOR) {
                for (el0 in input.partitionColumns) {
                    serializeString(el0)
                }
            }
        }
        if (input.sortColumns != null) {
            listField(SORTCOLUMNS_DESCRIPTOR) {
                for (el0 in input.sortColumns) {
                    serializeString(el0)
                }
            }
        }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy