All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
software.amazon.awssdk.services.qbusiness.model.ActionReviewEvent Maven / Gradle / Ivy
Go to download
The AWS Java SDK for Q Business module holds the client classes that are used for
communicating with Q Business.
/*
* 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.qbusiness.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
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.core.traits.MapTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructMap;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An output event that Amazon Q Business returns to an user who wants to perform a plugin action during a streaming
* chat conversation. It contains information about the selected action with a list of possible user input fields, some
* pre-populated by Amazon Q Business.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class ActionReviewEvent implements SdkPojo, Serializable, ToCopyableBuilder,
ChatOutputStream {
private static final SdkField CONVERSATION_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("conversationId").getter(getter(ActionReviewEvent::conversationId))
.setter(setter(Builder::conversationId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("conversationId").build()).build();
private static final SdkField USER_MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("userMessageId").getter(getter(ActionReviewEvent::userMessageId)).setter(setter(Builder::userMessageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("userMessageId").build()).build();
private static final SdkField SYSTEM_MESSAGE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("systemMessageId").getter(getter(ActionReviewEvent::systemMessageId))
.setter(setter(Builder::systemMessageId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("systemMessageId").build()).build();
private static final SdkField PLUGIN_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("pluginId").getter(getter(ActionReviewEvent::pluginId)).setter(setter(Builder::pluginId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pluginId").build()).build();
private static final SdkField PLUGIN_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("pluginType").getter(getter(ActionReviewEvent::pluginTypeAsString)).setter(setter(Builder::pluginType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("pluginType").build()).build();
private static final SdkField> PAYLOAD_FIELD = SdkField
.> builder(MarshallingType.MAP)
.memberName("payload")
.getter(getter(ActionReviewEvent::payload))
.setter(setter(Builder::payload))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("payload").build(),
MapTrait.builder()
.keyLocationName("key")
.valueLocationName("value")
.valueFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ActionReviewPayloadField::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("value").build()).build()).build()).build();
private static final SdkField PAYLOAD_FIELD_NAME_SEPARATOR_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("payloadFieldNameSeparator").getter(getter(ActionReviewEvent::payloadFieldNameSeparator))
.setter(setter(Builder::payloadFieldNameSeparator))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("payloadFieldNameSeparator").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CONVERSATION_ID_FIELD,
USER_MESSAGE_ID_FIELD, SYSTEM_MESSAGE_ID_FIELD, PLUGIN_ID_FIELD, PLUGIN_TYPE_FIELD, PAYLOAD_FIELD,
PAYLOAD_FIELD_NAME_SEPARATOR_FIELD));
private static final long serialVersionUID = 1L;
private final String conversationId;
private final String userMessageId;
private final String systemMessageId;
private final String pluginId;
private final String pluginType;
private final Map payload;
private final String payloadFieldNameSeparator;
protected ActionReviewEvent(BuilderImpl builder) {
this.conversationId = builder.conversationId;
this.userMessageId = builder.userMessageId;
this.systemMessageId = builder.systemMessageId;
this.pluginId = builder.pluginId;
this.pluginType = builder.pluginType;
this.payload = builder.payload;
this.payloadFieldNameSeparator = builder.payloadFieldNameSeparator;
}
/**
*
* The identifier of the conversation with which the action review event is associated.
*
*
* @return The identifier of the conversation with which the action review event is associated.
*/
public final String conversationId() {
return conversationId;
}
/**
*
* The identifier of the conversation with which the plugin action is associated.
*
*
* @return The identifier of the conversation with which the plugin action is associated.
*/
public final String userMessageId() {
return userMessageId;
}
/**
*
* The identifier of an Amazon Q Business AI generated associated with the action review event.
*
*
* @return The identifier of an Amazon Q Business AI generated associated with the action review event.
*/
public final String systemMessageId() {
return systemMessageId;
}
/**
*
* The identifier of the plugin associated with the action review event.
*
*
* @return The identifier of the plugin associated with the action review event.
*/
public final String pluginId() {
return pluginId;
}
/**
*
* The type of plugin.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #pluginType} will
* return {@link PluginType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #pluginTypeAsString}.
*
*
* @return The type of plugin.
* @see PluginType
*/
public final PluginType pluginType() {
return PluginType.fromValue(pluginType);
}
/**
*
* The type of plugin.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #pluginType} will
* return {@link PluginType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #pluginTypeAsString}.
*
*
* @return The type of plugin.
* @see PluginType
*/
public final String pluginTypeAsString() {
return pluginType;
}
/**
* For responses, this returns true if the service returned a value for the Payload property. This DOES NOT check
* that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is
* useful because the SDK will never return a null collection or map, but you may need to differentiate between the
* service returning nothing (or null) and the service returning an empty collection or map. For requests, this
* returns true if a value for the property was specified in the request builder, and false if a value was not
* specified.
*/
public final boolean hasPayload() {
return payload != null && !(payload instanceof SdkAutoConstructMap);
}
/**
*
* Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the
* requested plugin action.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasPayload} method.
*
*
* @return Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the
* requested plugin action.
*/
public final Map payload() {
return payload;
}
/**
*
* A string used to retain information about the hierarchical contexts within an action review event payload.
*
*
* @return A string used to retain information about the hierarchical contexts within an action review event
* payload.
*/
public final String payloadFieldNameSeparator() {
return payloadFieldNameSeparator;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(conversationId());
hashCode = 31 * hashCode + Objects.hashCode(userMessageId());
hashCode = 31 * hashCode + Objects.hashCode(systemMessageId());
hashCode = 31 * hashCode + Objects.hashCode(pluginId());
hashCode = 31 * hashCode + Objects.hashCode(pluginTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasPayload() ? payload() : null);
hashCode = 31 * hashCode + Objects.hashCode(payloadFieldNameSeparator());
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 ActionReviewEvent)) {
return false;
}
ActionReviewEvent other = (ActionReviewEvent) obj;
return Objects.equals(conversationId(), other.conversationId()) && Objects.equals(userMessageId(), other.userMessageId())
&& Objects.equals(systemMessageId(), other.systemMessageId()) && Objects.equals(pluginId(), other.pluginId())
&& Objects.equals(pluginTypeAsString(), other.pluginTypeAsString()) && hasPayload() == other.hasPayload()
&& Objects.equals(payload(), other.payload())
&& Objects.equals(payloadFieldNameSeparator(), other.payloadFieldNameSeparator());
}
/**
* 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("ActionReviewEvent").add("ConversationId", conversationId())
.add("UserMessageId", userMessageId()).add("SystemMessageId", systemMessageId()).add("PluginId", pluginId())
.add("PluginType", pluginTypeAsString()).add("Payload", hasPayload() ? payload() : null)
.add("PayloadFieldNameSeparator", payloadFieldNameSeparator()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "conversationId":
return Optional.ofNullable(clazz.cast(conversationId()));
case "userMessageId":
return Optional.ofNullable(clazz.cast(userMessageId()));
case "systemMessageId":
return Optional.ofNullable(clazz.cast(systemMessageId()));
case "pluginId":
return Optional.ofNullable(clazz.cast(pluginId()));
case "pluginType":
return Optional.ofNullable(clazz.cast(pluginTypeAsString()));
case "payload":
return Optional.ofNullable(clazz.cast(payload()));
case "payloadFieldNameSeparator":
return Optional.ofNullable(clazz.cast(payloadFieldNameSeparator()));
default:
return Optional.empty();
}
}
@Override
public final ActionReviewEvent copy(Consumer super Builder> modifier) {
return ToCopyableBuilder.super.copy(modifier);
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((ActionReviewEvent) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
/**
* Calls the appropriate visit method depending on the subtype of {@link ActionReviewEvent}.
*
* @param visitor
* Visitor to invoke.
*/
@Override
public void accept(ChatResponseHandler.Visitor visitor) {
throw new UnsupportedOperationException();
}
public interface Builder extends SdkPojo, CopyableBuilder {
/**
*
* The identifier of the conversation with which the action review event is associated.
*
*
* @param conversationId
* The identifier of the conversation with which the action review event is associated.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder conversationId(String conversationId);
/**
*
* The identifier of the conversation with which the plugin action is associated.
*
*
* @param userMessageId
* The identifier of the conversation with which the plugin action is associated.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder userMessageId(String userMessageId);
/**
*
* The identifier of an Amazon Q Business AI generated associated with the action review event.
*
*
* @param systemMessageId
* The identifier of an Amazon Q Business AI generated associated with the action review event.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder systemMessageId(String systemMessageId);
/**
*
* The identifier of the plugin associated with the action review event.
*
*
* @param pluginId
* The identifier of the plugin associated with the action review event.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder pluginId(String pluginId);
/**
*
* The type of plugin.
*
*
* @param pluginType
* The type of plugin.
* @see PluginType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PluginType
*/
Builder pluginType(String pluginType);
/**
*
* The type of plugin.
*
*
* @param pluginType
* The type of plugin.
* @see PluginType
* @return Returns a reference to this object so that method calls can be chained together.
* @see PluginType
*/
Builder pluginType(PluginType pluginType);
/**
*
* Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform the
* requested plugin action.
*
*
* @param payload
* Field values that an end user needs to provide to Amazon Q Business for Amazon Q Business to perform
* the requested plugin action.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder payload(Map payload);
/**
*
* A string used to retain information about the hierarchical contexts within an action review event payload.
*
*
* @param payloadFieldNameSeparator
* A string used to retain information about the hierarchical contexts within an action review event
* payload.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder payloadFieldNameSeparator(String payloadFieldNameSeparator);
}
protected static class BuilderImpl implements Builder {
private String conversationId;
private String userMessageId;
private String systemMessageId;
private String pluginId;
private String pluginType;
private Map payload = DefaultSdkAutoConstructMap.getInstance();
private String payloadFieldNameSeparator;
protected BuilderImpl() {
}
protected BuilderImpl(ActionReviewEvent model) {
conversationId(model.conversationId);
userMessageId(model.userMessageId);
systemMessageId(model.systemMessageId);
pluginId(model.pluginId);
pluginType(model.pluginType);
payload(model.payload);
payloadFieldNameSeparator(model.payloadFieldNameSeparator);
}
public final String getConversationId() {
return conversationId;
}
public final void setConversationId(String conversationId) {
this.conversationId = conversationId;
}
@Override
public final Builder conversationId(String conversationId) {
this.conversationId = conversationId;
return this;
}
public final String getUserMessageId() {
return userMessageId;
}
public final void setUserMessageId(String userMessageId) {
this.userMessageId = userMessageId;
}
@Override
public final Builder userMessageId(String userMessageId) {
this.userMessageId = userMessageId;
return this;
}
public final String getSystemMessageId() {
return systemMessageId;
}
public final void setSystemMessageId(String systemMessageId) {
this.systemMessageId = systemMessageId;
}
@Override
public final Builder systemMessageId(String systemMessageId) {
this.systemMessageId = systemMessageId;
return this;
}
public final String getPluginId() {
return pluginId;
}
public final void setPluginId(String pluginId) {
this.pluginId = pluginId;
}
@Override
public final Builder pluginId(String pluginId) {
this.pluginId = pluginId;
return this;
}
public final String getPluginType() {
return pluginType;
}
public final void setPluginType(String pluginType) {
this.pluginType = pluginType;
}
@Override
public final Builder pluginType(String pluginType) {
this.pluginType = pluginType;
return this;
}
@Override
public final Builder pluginType(PluginType pluginType) {
this.pluginType(pluginType == null ? null : pluginType.toString());
return this;
}
public final Map getPayload() {
Map result = ActionReviewPayloadCopier.copyToBuilder(this.payload);
if (result instanceof SdkAutoConstructMap) {
return null;
}
return result;
}
public final void setPayload(Map payload) {
this.payload = ActionReviewPayloadCopier.copyFromBuilder(payload);
}
@Override
public final Builder payload(Map payload) {
this.payload = ActionReviewPayloadCopier.copy(payload);
return this;
}
public final String getPayloadFieldNameSeparator() {
return payloadFieldNameSeparator;
}
public final void setPayloadFieldNameSeparator(String payloadFieldNameSeparator) {
this.payloadFieldNameSeparator = payloadFieldNameSeparator;
}
@Override
public final Builder payloadFieldNameSeparator(String payloadFieldNameSeparator) {
this.payloadFieldNameSeparator = payloadFieldNameSeparator;
return this;
}
@Override
public ActionReviewEvent build() {
return new ActionReviewEvent(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}