
commonMain.aws.sdk.kotlin.services.codecommit.serde.PostCommentForPullRequestOperationSerializer.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.codecommit.serde
import aws.sdk.kotlin.services.codecommit.model.Location
import aws.sdk.kotlin.services.codecommit.model.PostCommentForPullRequestRequest
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
internal class PostCommentForPullRequestOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: PostCommentForPullRequestRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/"
}
val payload = serializePostCommentForPullRequestOperationBody(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 serializePostCommentForPullRequestOperationBody(context: ExecutionContext, input: PostCommentForPullRequestRequest): ByteArray {
val serializer = JsonSerializer()
val AFTERCOMMITID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("afterCommitId"))
val BEFORECOMMITID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("beforeCommitId"))
val CLIENTREQUESTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientRequestToken"))
val CONTENT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("content"))
val LOCATION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("location"))
val PULLREQUESTID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("pullRequestId"))
val REPOSITORYNAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("repositoryName"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(AFTERCOMMITID_DESCRIPTOR)
field(BEFORECOMMITID_DESCRIPTOR)
field(CLIENTREQUESTTOKEN_DESCRIPTOR)
field(CONTENT_DESCRIPTOR)
field(LOCATION_DESCRIPTOR)
field(PULLREQUESTID_DESCRIPTOR)
field(REPOSITORYNAME_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.afterCommitId?.let { field(AFTERCOMMITID_DESCRIPTOR, it) }
input.beforeCommitId?.let { field(BEFORECOMMITID_DESCRIPTOR, it) }
input.clientRequestToken?.let { field(CLIENTREQUESTTOKEN_DESCRIPTOR, it) } ?: field(CLIENTREQUESTTOKEN_DESCRIPTOR, context.idempotencyTokenProvider.generateToken())
input.content?.let { field(CONTENT_DESCRIPTOR, it) }
input.location?.let { field(LOCATION_DESCRIPTOR, it, ::serializeLocationDocument) }
input.pullRequestId?.let { field(PULLREQUESTID_DESCRIPTOR, it) }
input.repositoryName?.let { field(REPOSITORYNAME_DESCRIPTOR, it) }
}
return serializer.toByteArray()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy