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

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

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

package aws.sdk.kotlin.services.qbusiness.serde

import aws.sdk.kotlin.services.qbusiness.model.DataSourceVpcConfiguration
import aws.sdk.kotlin.services.qbusiness.model.DocumentEnrichmentConfiguration
import aws.sdk.kotlin.services.qbusiness.model.UpdateDataSourceRequest
import aws.smithy.kotlin.runtime.content.Document
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.PUT

        builder.url {
            requireNotNull(input.applicationId) { "applicationId is bound to the URI and must not be null" }
            requireNotNull(input.indexId) { "indexId is bound to the URI and must not be null" }
            requireNotNull(input.dataSourceId) { "dataSourceId is bound to the URI and must not be null" }
            path.encodedSegments {
                add(PercentEncoding.Path.encode("applications"))
                add(PercentEncoding.SmithyLabel.encode("${input.applicationId}"))
                add(PercentEncoding.Path.encode("indices"))
                add(PercentEncoding.SmithyLabel.encode("${input.indexId}"))
                add(PercentEncoding.Path.encode("datasources"))
                add(PercentEncoding.SmithyLabel.encode("${input.dataSourceId}"))
            }
        }

        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 CONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Document, JsonSerialName("configuration"))
    val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
    val DISPLAYNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("displayName"))
    val DOCUMENTENRICHMENTCONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("documentEnrichmentConfiguration"))
    val ROLEARN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("roleArn"))
    val SYNCSCHEDULE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("syncSchedule"))
    val VPCCONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("vpcConfiguration"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(CONFIGURATION_DESCRIPTOR)
        field(DESCRIPTION_DESCRIPTOR)
        field(DISPLAYNAME_DESCRIPTOR)
        field(DOCUMENTENRICHMENTCONFIGURATION_DESCRIPTOR)
        field(ROLEARN_DESCRIPTOR)
        field(SYNCSCHEDULE_DESCRIPTOR)
        field(VPCCONFIGURATION_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.configuration?.let { field(CONFIGURATION_DESCRIPTOR, it) }
        input.description?.let { field(DESCRIPTION_DESCRIPTOR, it) }
        input.displayName?.let { field(DISPLAYNAME_DESCRIPTOR, it) }
        input.documentEnrichmentConfiguration?.let { field(DOCUMENTENRICHMENTCONFIGURATION_DESCRIPTOR, it, ::serializeDocumentEnrichmentConfigurationDocument) }
        input.roleArn?.let { field(ROLEARN_DESCRIPTOR, it) }
        input.syncSchedule?.let { field(SYNCSCHEDULE_DESCRIPTOR, it) }
        input.vpcConfiguration?.let { field(VPCCONFIGURATION_DESCRIPTOR, it, ::serializeDataSourceVpcConfigurationDocument) }
    }
    return serializer.toByteArray()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy