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

software.amazon.awssdk.services.bedrockruntime.model.GuardrailAssessment Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Bedrock Runtime module holds the client classes that are used for communicating with Bedrock Runtime.

There is a newer version: 2.29.15
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.bedrockruntime.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* A behavior assessment of the guardrail policies used in a call to the Converse API. *

*/ @Generated("software.amazon.awssdk:codegen") public final class GuardrailAssessment implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField TOPIC_POLICY_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("topicPolicy") .getter(getter(GuardrailAssessment::topicPolicy)).setter(setter(Builder::topicPolicy)) .constructor(GuardrailTopicPolicyAssessment::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("topicPolicy").build()).build(); private static final SdkField CONTENT_POLICY_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("contentPolicy") .getter(getter(GuardrailAssessment::contentPolicy)).setter(setter(Builder::contentPolicy)) .constructor(GuardrailContentPolicyAssessment::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("contentPolicy").build()).build(); private static final SdkField WORD_POLICY_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("wordPolicy") .getter(getter(GuardrailAssessment::wordPolicy)).setter(setter(Builder::wordPolicy)) .constructor(GuardrailWordPolicyAssessment::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("wordPolicy").build()).build(); private static final SdkField SENSITIVE_INFORMATION_POLICY_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("sensitiveInformationPolicy") .getter(getter(GuardrailAssessment::sensitiveInformationPolicy)) .setter(setter(Builder::sensitiveInformationPolicy)) .constructor(GuardrailSensitiveInformationPolicyAssessment::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sensitiveInformationPolicy").build()) .build(); private static final SdkField CONTEXTUAL_GROUNDING_POLICY_FIELD = SdkField . builder(MarshallingType.SDK_POJO) .memberName("contextualGroundingPolicy").getter(getter(GuardrailAssessment::contextualGroundingPolicy)) .setter(setter(Builder::contextualGroundingPolicy)) .constructor(GuardrailContextualGroundingPolicyAssessment::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("contextualGroundingPolicy").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(TOPIC_POLICY_FIELD, CONTENT_POLICY_FIELD, WORD_POLICY_FIELD, SENSITIVE_INFORMATION_POLICY_FIELD, CONTEXTUAL_GROUNDING_POLICY_FIELD)); private static final long serialVersionUID = 1L; private final GuardrailTopicPolicyAssessment topicPolicy; private final GuardrailContentPolicyAssessment contentPolicy; private final GuardrailWordPolicyAssessment wordPolicy; private final GuardrailSensitiveInformationPolicyAssessment sensitiveInformationPolicy; private final GuardrailContextualGroundingPolicyAssessment contextualGroundingPolicy; private GuardrailAssessment(BuilderImpl builder) { this.topicPolicy = builder.topicPolicy; this.contentPolicy = builder.contentPolicy; this.wordPolicy = builder.wordPolicy; this.sensitiveInformationPolicy = builder.sensitiveInformationPolicy; this.contextualGroundingPolicy = builder.contextualGroundingPolicy; } /** *

* The topic policy. *

* * @return The topic policy. */ public final GuardrailTopicPolicyAssessment topicPolicy() { return topicPolicy; } /** *

* The content policy. *

* * @return The content policy. */ public final GuardrailContentPolicyAssessment contentPolicy() { return contentPolicy; } /** *

* The word policy. *

* * @return The word policy. */ public final GuardrailWordPolicyAssessment wordPolicy() { return wordPolicy; } /** *

* The sensitive information policy. *

* * @return The sensitive information policy. */ public final GuardrailSensitiveInformationPolicyAssessment sensitiveInformationPolicy() { return sensitiveInformationPolicy; } /** *

* The contextual grounding policy used for the guardrail assessment. *

* * @return The contextual grounding policy used for the guardrail assessment. */ public final GuardrailContextualGroundingPolicyAssessment contextualGroundingPolicy() { return contextualGroundingPolicy; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(topicPolicy()); hashCode = 31 * hashCode + Objects.hashCode(contentPolicy()); hashCode = 31 * hashCode + Objects.hashCode(wordPolicy()); hashCode = 31 * hashCode + Objects.hashCode(sensitiveInformationPolicy()); hashCode = 31 * hashCode + Objects.hashCode(contextualGroundingPolicy()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof GuardrailAssessment)) { return false; } GuardrailAssessment other = (GuardrailAssessment) obj; return Objects.equals(topicPolicy(), other.topicPolicy()) && Objects.equals(contentPolicy(), other.contentPolicy()) && Objects.equals(wordPolicy(), other.wordPolicy()) && Objects.equals(sensitiveInformationPolicy(), other.sensitiveInformationPolicy()) && Objects.equals(contextualGroundingPolicy(), other.contextualGroundingPolicy()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("GuardrailAssessment").add("TopicPolicy", topicPolicy()).add("ContentPolicy", contentPolicy()) .add("WordPolicy", wordPolicy()).add("SensitiveInformationPolicy", sensitiveInformationPolicy()) .add("ContextualGroundingPolicy", contextualGroundingPolicy()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "topicPolicy": return Optional.ofNullable(clazz.cast(topicPolicy())); case "contentPolicy": return Optional.ofNullable(clazz.cast(contentPolicy())); case "wordPolicy": return Optional.ofNullable(clazz.cast(wordPolicy())); case "sensitiveInformationPolicy": return Optional.ofNullable(clazz.cast(sensitiveInformationPolicy())); case "contextualGroundingPolicy": return Optional.ofNullable(clazz.cast(contextualGroundingPolicy())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((GuardrailAssessment) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The topic policy. *

* * @param topicPolicy * The topic policy. * @return Returns a reference to this object so that method calls can be chained together. */ Builder topicPolicy(GuardrailTopicPolicyAssessment topicPolicy); /** *

* The topic policy. *

* This is a convenience method that creates an instance of the {@link GuardrailTopicPolicyAssessment.Builder} * avoiding the need to create one manually via {@link GuardrailTopicPolicyAssessment#builder()}. * *

* When the {@link Consumer} completes, {@link GuardrailTopicPolicyAssessment.Builder#build()} is called * immediately and its result is passed to {@link #topicPolicy(GuardrailTopicPolicyAssessment)}. * * @param topicPolicy * a consumer that will call methods on {@link GuardrailTopicPolicyAssessment.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #topicPolicy(GuardrailTopicPolicyAssessment) */ default Builder topicPolicy(Consumer topicPolicy) { return topicPolicy(GuardrailTopicPolicyAssessment.builder().applyMutation(topicPolicy).build()); } /** *

* The content policy. *

* * @param contentPolicy * The content policy. * @return Returns a reference to this object so that method calls can be chained together. */ Builder contentPolicy(GuardrailContentPolicyAssessment contentPolicy); /** *

* The content policy. *

* This is a convenience method that creates an instance of the {@link GuardrailContentPolicyAssessment.Builder} * avoiding the need to create one manually via {@link GuardrailContentPolicyAssessment#builder()}. * *

* When the {@link Consumer} completes, {@link GuardrailContentPolicyAssessment.Builder#build()} is called * immediately and its result is passed to {@link #contentPolicy(GuardrailContentPolicyAssessment)}. * * @param contentPolicy * a consumer that will call methods on {@link GuardrailContentPolicyAssessment.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #contentPolicy(GuardrailContentPolicyAssessment) */ default Builder contentPolicy(Consumer contentPolicy) { return contentPolicy(GuardrailContentPolicyAssessment.builder().applyMutation(contentPolicy).build()); } /** *

* The word policy. *

* * @param wordPolicy * The word policy. * @return Returns a reference to this object so that method calls can be chained together. */ Builder wordPolicy(GuardrailWordPolicyAssessment wordPolicy); /** *

* The word policy. *

* This is a convenience method that creates an instance of the {@link GuardrailWordPolicyAssessment.Builder} * avoiding the need to create one manually via {@link GuardrailWordPolicyAssessment#builder()}. * *

* When the {@link Consumer} completes, {@link GuardrailWordPolicyAssessment.Builder#build()} is called * immediately and its result is passed to {@link #wordPolicy(GuardrailWordPolicyAssessment)}. * * @param wordPolicy * a consumer that will call methods on {@link GuardrailWordPolicyAssessment.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #wordPolicy(GuardrailWordPolicyAssessment) */ default Builder wordPolicy(Consumer wordPolicy) { return wordPolicy(GuardrailWordPolicyAssessment.builder().applyMutation(wordPolicy).build()); } /** *

* The sensitive information policy. *

* * @param sensitiveInformationPolicy * The sensitive information policy. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sensitiveInformationPolicy(GuardrailSensitiveInformationPolicyAssessment sensitiveInformationPolicy); /** *

* The sensitive information policy. *

* This is a convenience method that creates an instance of the * {@link GuardrailSensitiveInformationPolicyAssessment.Builder} avoiding the need to create one manually via * {@link GuardrailSensitiveInformationPolicyAssessment#builder()}. * *

* When the {@link Consumer} completes, {@link GuardrailSensitiveInformationPolicyAssessment.Builder#build()} is * called immediately and its result is passed to * {@link #sensitiveInformationPolicy(GuardrailSensitiveInformationPolicyAssessment)}. * * @param sensitiveInformationPolicy * a consumer that will call methods on {@link GuardrailSensitiveInformationPolicyAssessment.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #sensitiveInformationPolicy(GuardrailSensitiveInformationPolicyAssessment) */ default Builder sensitiveInformationPolicy( Consumer sensitiveInformationPolicy) { return sensitiveInformationPolicy(GuardrailSensitiveInformationPolicyAssessment.builder() .applyMutation(sensitiveInformationPolicy).build()); } /** *

* The contextual grounding policy used for the guardrail assessment. *

* * @param contextualGroundingPolicy * The contextual grounding policy used for the guardrail assessment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder contextualGroundingPolicy(GuardrailContextualGroundingPolicyAssessment contextualGroundingPolicy); /** *

* The contextual grounding policy used for the guardrail assessment. *

* This is a convenience method that creates an instance of the * {@link GuardrailContextualGroundingPolicyAssessment.Builder} avoiding the need to create one manually via * {@link GuardrailContextualGroundingPolicyAssessment#builder()}. * *

* When the {@link Consumer} completes, {@link GuardrailContextualGroundingPolicyAssessment.Builder#build()} is * called immediately and its result is passed to * {@link #contextualGroundingPolicy(GuardrailContextualGroundingPolicyAssessment)}. * * @param contextualGroundingPolicy * a consumer that will call methods on {@link GuardrailContextualGroundingPolicyAssessment.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #contextualGroundingPolicy(GuardrailContextualGroundingPolicyAssessment) */ default Builder contextualGroundingPolicy( Consumer contextualGroundingPolicy) { return contextualGroundingPolicy(GuardrailContextualGroundingPolicyAssessment.builder() .applyMutation(contextualGroundingPolicy).build()); } } static final class BuilderImpl implements Builder { private GuardrailTopicPolicyAssessment topicPolicy; private GuardrailContentPolicyAssessment contentPolicy; private GuardrailWordPolicyAssessment wordPolicy; private GuardrailSensitiveInformationPolicyAssessment sensitiveInformationPolicy; private GuardrailContextualGroundingPolicyAssessment contextualGroundingPolicy; private BuilderImpl() { } private BuilderImpl(GuardrailAssessment model) { topicPolicy(model.topicPolicy); contentPolicy(model.contentPolicy); wordPolicy(model.wordPolicy); sensitiveInformationPolicy(model.sensitiveInformationPolicy); contextualGroundingPolicy(model.contextualGroundingPolicy); } public final GuardrailTopicPolicyAssessment.Builder getTopicPolicy() { return topicPolicy != null ? topicPolicy.toBuilder() : null; } public final void setTopicPolicy(GuardrailTopicPolicyAssessment.BuilderImpl topicPolicy) { this.topicPolicy = topicPolicy != null ? topicPolicy.build() : null; } @Override public final Builder topicPolicy(GuardrailTopicPolicyAssessment topicPolicy) { this.topicPolicy = topicPolicy; return this; } public final GuardrailContentPolicyAssessment.Builder getContentPolicy() { return contentPolicy != null ? contentPolicy.toBuilder() : null; } public final void setContentPolicy(GuardrailContentPolicyAssessment.BuilderImpl contentPolicy) { this.contentPolicy = contentPolicy != null ? contentPolicy.build() : null; } @Override public final Builder contentPolicy(GuardrailContentPolicyAssessment contentPolicy) { this.contentPolicy = contentPolicy; return this; } public final GuardrailWordPolicyAssessment.Builder getWordPolicy() { return wordPolicy != null ? wordPolicy.toBuilder() : null; } public final void setWordPolicy(GuardrailWordPolicyAssessment.BuilderImpl wordPolicy) { this.wordPolicy = wordPolicy != null ? wordPolicy.build() : null; } @Override public final Builder wordPolicy(GuardrailWordPolicyAssessment wordPolicy) { this.wordPolicy = wordPolicy; return this; } public final GuardrailSensitiveInformationPolicyAssessment.Builder getSensitiveInformationPolicy() { return sensitiveInformationPolicy != null ? sensitiveInformationPolicy.toBuilder() : null; } public final void setSensitiveInformationPolicy( GuardrailSensitiveInformationPolicyAssessment.BuilderImpl sensitiveInformationPolicy) { this.sensitiveInformationPolicy = sensitiveInformationPolicy != null ? sensitiveInformationPolicy.build() : null; } @Override public final Builder sensitiveInformationPolicy(GuardrailSensitiveInformationPolicyAssessment sensitiveInformationPolicy) { this.sensitiveInformationPolicy = sensitiveInformationPolicy; return this; } public final GuardrailContextualGroundingPolicyAssessment.Builder getContextualGroundingPolicy() { return contextualGroundingPolicy != null ? contextualGroundingPolicy.toBuilder() : null; } public final void setContextualGroundingPolicy( GuardrailContextualGroundingPolicyAssessment.BuilderImpl contextualGroundingPolicy) { this.contextualGroundingPolicy = contextualGroundingPolicy != null ? contextualGroundingPolicy.build() : null; } @Override public final Builder contextualGroundingPolicy(GuardrailContextualGroundingPolicyAssessment contextualGroundingPolicy) { this.contextualGroundingPolicy = contextualGroundingPolicy; return this; } @Override public GuardrailAssessment build() { return new GuardrailAssessment(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy