commonMain.aws.sdk.kotlin.services.bedrock.serde.CreateGuardrailOperationSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bedrock-jvm Show documentation
Show all versions of bedrock-jvm Show documentation
The AWS SDK for Kotlin client for Bedrock
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.bedrock.serde
import aws.sdk.kotlin.services.bedrock.model.CreateGuardrailRequest
import aws.sdk.kotlin.services.bedrock.model.GuardrailContentPolicyConfig
import aws.sdk.kotlin.services.bedrock.model.GuardrailContextualGroundingPolicyConfig
import aws.sdk.kotlin.services.bedrock.model.GuardrailSensitiveInformationPolicyConfig
import aws.sdk.kotlin.services.bedrock.model.GuardrailTopicPolicyConfig
import aws.sdk.kotlin.services.bedrock.model.GuardrailWordPolicyConfig
import aws.sdk.kotlin.services.bedrock.model.Tag
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 CreateGuardrailOperationSerializer: HttpSerializer.NonStreaming {
override fun serialize(context: ExecutionContext, input: CreateGuardrailRequest): HttpRequestBuilder {
val builder = HttpRequestBuilder()
builder.method = HttpMethod.POST
builder.url {
path.encoded = "/guardrails"
}
val payload = serializeCreateGuardrailOperationBody(context, input)
builder.body = HttpBody.fromBytes(payload)
if (builder.body !is HttpBody.Empty) {
builder.headers.setMissing("Content-Type", "application/json")
}
return builder
}
}
private fun serializeCreateGuardrailOperationBody(context: ExecutionContext, input: CreateGuardrailRequest): ByteArray {
val serializer = JsonSerializer()
val BLOCKEDINPUTMESSAGING_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("blockedInputMessaging"))
val BLOCKEDOUTPUTSMESSAGING_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("blockedOutputsMessaging"))
val CLIENTREQUESTTOKEN_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("clientRequestToken"))
val CONTENTPOLICYCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("contentPolicyConfig"))
val CONTEXTUALGROUNDINGPOLICYCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("contextualGroundingPolicyConfig"))
val DESCRIPTION_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("description"))
val KMSKEYID_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("kmsKeyId"))
val NAME_DESCRIPTOR = SdkFieldDescriptor(SerialKind.String, JsonSerialName("name"))
val SENSITIVEINFORMATIONPOLICYCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("sensitiveInformationPolicyConfig"))
val TAGS_DESCRIPTOR = SdkFieldDescriptor(SerialKind.List, JsonSerialName("tags"))
val TOPICPOLICYCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("topicPolicyConfig"))
val WORDPOLICYCONFIG_DESCRIPTOR = SdkFieldDescriptor(SerialKind.Struct, JsonSerialName("wordPolicyConfig"))
val OBJ_DESCRIPTOR = SdkObjectDescriptor.build {
field(BLOCKEDINPUTMESSAGING_DESCRIPTOR)
field(BLOCKEDOUTPUTSMESSAGING_DESCRIPTOR)
field(CLIENTREQUESTTOKEN_DESCRIPTOR)
field(CONTENTPOLICYCONFIG_DESCRIPTOR)
field(CONTEXTUALGROUNDINGPOLICYCONFIG_DESCRIPTOR)
field(DESCRIPTION_DESCRIPTOR)
field(KMSKEYID_DESCRIPTOR)
field(NAME_DESCRIPTOR)
field(SENSITIVEINFORMATIONPOLICYCONFIG_DESCRIPTOR)
field(TAGS_DESCRIPTOR)
field(TOPICPOLICYCONFIG_DESCRIPTOR)
field(WORDPOLICYCONFIG_DESCRIPTOR)
}
serializer.serializeStruct(OBJ_DESCRIPTOR) {
input.blockedInputMessaging?.let { field(BLOCKEDINPUTMESSAGING_DESCRIPTOR, it) }
input.blockedOutputsMessaging?.let { field(BLOCKEDOUTPUTSMESSAGING_DESCRIPTOR, it) }
input.clientRequestToken?.let { field(CLIENTREQUESTTOKEN_DESCRIPTOR, it) } ?: field(CLIENTREQUESTTOKEN_DESCRIPTOR, context.idempotencyTokenProvider.generateToken())
input.contentPolicyConfig?.let { field(CONTENTPOLICYCONFIG_DESCRIPTOR, it, ::serializeGuardrailContentPolicyConfigDocument) }
input.contextualGroundingPolicyConfig?.let { field(CONTEXTUALGROUNDINGPOLICYCONFIG_DESCRIPTOR, it, ::serializeGuardrailContextualGroundingPolicyConfigDocument) }
input.description?.let { field(DESCRIPTION_DESCRIPTOR, it) }
input.kmsKeyId?.let { field(KMSKEYID_DESCRIPTOR, it) }
input.name?.let { field(NAME_DESCRIPTOR, it) }
input.sensitiveInformationPolicyConfig?.let { field(SENSITIVEINFORMATIONPOLICYCONFIG_DESCRIPTOR, it, ::serializeGuardrailSensitiveInformationPolicyConfigDocument) }
if (input.tags != null) {
listField(TAGS_DESCRIPTOR) {
for (el0 in input.tags) {
serializeSdkSerializable(asSdkSerializable(el0, ::serializeTagDocument))
}
}
}
input.topicPolicyConfig?.let { field(TOPICPOLICYCONFIG_DESCRIPTOR, it, ::serializeGuardrailTopicPolicyConfigDocument) }
input.wordPolicyConfig?.let { field(WORDPOLICYCONFIG_DESCRIPTOR, it, ::serializeGuardrailWordPolicyConfigDocument) }
}
return serializer.toByteArray()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy