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

commonMain.aws.sdk.kotlin.services.codebuild.serde.CreateWebhookOperationSerializer.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.codebuild.serde

import aws.sdk.kotlin.services.codebuild.model.CreateWebhookRequest
import aws.sdk.kotlin.services.codebuild.model.ScopeConfiguration
import aws.sdk.kotlin.services.codebuild.model.WebhookBuildType
import aws.sdk.kotlin.services.codebuild.model.WebhookFilter
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


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

        builder.url {
            path.encoded = "/"
        }

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

private fun serializeCreateWebhookOperationBody(context: ExecutionContext, input: CreateWebhookRequest): ByteArray {
    val serializer = JsonSerializer()
    val BRANCHFILTER_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("branchFilter"))
    val BUILDTYPE_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Enum, JsonSerialName("buildType"))
    val FILTERGROUPS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("filterGroups"))
    val FILTERGROUPS_C0_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List)
    val MANUALCREATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Boolean, JsonSerialName("manualCreation"))
    val PROJECTNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("projectName"))
    val SCOPECONFIGURATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("scopeConfiguration"))
    val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
        field(BRANCHFILTER_DESCRIPTOR)
        field(BUILDTYPE_DESCRIPTOR)
        field(FILTERGROUPS_DESCRIPTOR)
        field(MANUALCREATION_DESCRIPTOR)
        field(PROJECTNAME_DESCRIPTOR)
        field(SCOPECONFIGURATION_DESCRIPTOR)
    }

    serializer.serializeStruct(OBJ_DESCRIPTOR) {
        input.branchFilter?.let { field(BRANCHFILTER_DESCRIPTOR, it) }
        input.buildType?.let { field(BUILDTYPE_DESCRIPTOR, it.value) }
        if (input.filterGroups != null) {
            listField(FILTERGROUPS_DESCRIPTOR) {
                for (el0 in input.filterGroups) {
                    serializer.serializeList(FILTERGROUPS_C0_DESCRIPTOR) {
                        for (el1 in el0) {
                            serializeSdkSerializable(asSdkSerializable(el1, ::serializeWebhookFilterDocument))
                        }
                    }
                }
            }
        }
        input.manualCreation?.let { field(MANUALCREATION_DESCRIPTOR, it) }
        input.projectName?.let { field(PROJECTNAME_DESCRIPTOR, it) }
        input.scopeConfiguration?.let { field(SCOPECONFIGURATION_DESCRIPTOR, it, ::serializeScopeConfigurationDocument) }
    }
    return serializer.toByteArray()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy