commonMain.aws.sdk.kotlin.services.kms.transform.GenerateRandomOperationSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kms Show documentation
Show all versions of kms Show documentation
The AWS Kotlin client for KMS
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.kms.transform
import aws.sdk.kotlin.services.kms.model.GenerateRandomRequest
import aws.sdk.kotlin.services.kms.model.RecipientInfo
import aws.smithy.kotlin.runtime.http.HttpBody
import aws.smithy.kotlin.runtime.http.HttpMethod
import aws.smithy.kotlin.runtime.http.content.ByteArrayContent
import aws.smithy.kotlin.runtime.http.operation.HttpSerialize
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 GenerateRandomOperationSerializer: HttpSerialize {
override suspend fun serialize(context: ExecutionContext, input: GenerateRandomRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path = "/"
}
val payload = serializeGenerateRandomOperationBody(context, input)
builder.body = ByteArrayContent(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/x-amz-json-1.1")
}
return builder
}
}
private fun serializeGenerateRandomOperationBody(context: ExecutionContext, input: GenerateRandomRequest): ByteArray {
val serializer = JsonSerializer()
val CUSTOMKEYSTOREID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("CustomKeyStoreId"))
val NUMBEROFBYTES_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Integer, JsonSerialName("NumberOfBytes"))
val RECIPIENT_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("Recipient"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(CUSTOMKEYSTOREID_DESCRIPTOR)
field(NUMBEROFBYTES_DESCRIPTOR)
field(RECIPIENT_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.customKeyStoreId?.let { field(CUSTOMKEYSTOREID_DESCRIPTOR, it) }
input.numberOfBytes?.let { field(NUMBEROFBYTES_DESCRIPTOR, it) }
input.recipient?.let { field(RECIPIENT_DESCRIPTOR, it, ::serializeRecipientInfoDocument) }
}
return serializer.toByteArray()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy