|
| 1 | +/* |
| 2 | + * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with |
| 5 | + * the License. A copy of the License is located at |
| 6 | + * |
| 7 | + * http://aws.amazon.com/apache2.0 |
| 8 | + * |
| 9 | + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 10 | + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions |
| 11 | + * and limitations under the License. |
| 12 | + */ |
| 13 | +package com.amazonaws.services.lambda.runtime.events; |
| 14 | + |
| 15 | +import lombok.AllArgsConstructor; |
| 16 | +import lombok.Builder; |
| 17 | +import lombok.Data; |
| 18 | +import lombok.NoArgsConstructor; |
| 19 | + |
| 20 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 21 | + |
| 22 | +import java.io.Serializable; |
| 23 | +import java.util.Map; |
| 24 | + |
| 25 | +/** |
| 26 | + * Class to represent an Amazon Lex V2 event. |
| 27 | + * |
| 28 | + * @see <a href= |
| 29 | + * "https://docs.aws.amazon.com/lexv2/latest/dg/lambda.html#lambda-input-format">Using |
| 30 | + * an AWS Lambda function</a> |
| 31 | + */ |
| 32 | +@Data |
| 33 | +@Builder(setterPrefix = "with") |
| 34 | +@NoArgsConstructor |
| 35 | +@AllArgsConstructor |
| 36 | +public class LexV2Event implements Serializable { |
| 37 | + private String messageVersion; |
| 38 | + private String invocationSource; |
| 39 | + private String inputMode; |
| 40 | + private String responseContentType; |
| 41 | + private String sessionId; |
| 42 | + private String inputTranscript; |
| 43 | + private Bot bot; |
| 44 | + private Interpretation[] interpretations; |
| 45 | + private ProposedNextState proposedNextState; |
| 46 | + private Map<String, String> requestAttributes; |
| 47 | + private SessionState sessionState; |
| 48 | + private Transcription[] transcriptions; |
| 49 | + |
| 50 | + @Data |
| 51 | + @Builder(setterPrefix = "with") |
| 52 | + @NoArgsConstructor |
| 53 | + @AllArgsConstructor |
| 54 | + public static class Bot implements Serializable { |
| 55 | + private String id; |
| 56 | + private String name; |
| 57 | + private String aliasId; |
| 58 | + private String aliasName; |
| 59 | + private String localeId; |
| 60 | + private String version; |
| 61 | + } |
| 62 | + |
| 63 | + @Data |
| 64 | + @Builder(setterPrefix = "with") |
| 65 | + @NoArgsConstructor |
| 66 | + @AllArgsConstructor |
| 67 | + public static class Interpretation implements Serializable { |
| 68 | + private Intent intent; |
| 69 | + private Double nluConfidence; |
| 70 | + private SentimentResponse sentimentResponse; |
| 71 | + } |
| 72 | + |
| 73 | + @Data |
| 74 | + @Builder(setterPrefix = "with") |
| 75 | + @NoArgsConstructor |
| 76 | + @AllArgsConstructor |
| 77 | + public static class Intent implements Serializable { |
| 78 | + private String confirmationState; |
| 79 | + private String name; |
| 80 | + private Map<String, Slot> slots; |
| 81 | + private String state; |
| 82 | + private KendraResponse kendraResponse; |
| 83 | + |
| 84 | + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) |
| 85 | + public Map<String, Slot> getSlots() { |
| 86 | + return this.slots; |
| 87 | + } |
| 88 | + |
| 89 | + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) |
| 90 | + public void setSlots(Map<String, Slot> slots) { |
| 91 | + this.slots = slots; |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + @Data |
| 96 | + @Builder(setterPrefix = "with") |
| 97 | + @NoArgsConstructor |
| 98 | + @AllArgsConstructor |
| 99 | + public static class Slot implements Serializable { |
| 100 | + private String shape; |
| 101 | + private SlotValue value; |
| 102 | + private Slot[] values; |
| 103 | + } |
| 104 | + |
| 105 | + @Data |
| 106 | + @Builder(setterPrefix = "with") |
| 107 | + @NoArgsConstructor |
| 108 | + @AllArgsConstructor |
| 109 | + public static class SlotValue implements Serializable { |
| 110 | + private String interpretedValue; |
| 111 | + private String originalValue; |
| 112 | + private String[] resolvedValues; |
| 113 | + } |
| 114 | + |
| 115 | + @Data |
| 116 | + @Builder(setterPrefix = "with") |
| 117 | + @NoArgsConstructor |
| 118 | + @AllArgsConstructor |
| 119 | + public static class KendraResponse implements Serializable { |
| 120 | + private String queryId; |
| 121 | + private KendraResponseResultItem[] resultItems; |
| 122 | + private Object[] facetResults; |
| 123 | + private Integer totalNumberOfResults; |
| 124 | + } |
| 125 | + |
| 126 | + @Data |
| 127 | + @Builder(setterPrefix = "with") |
| 128 | + @NoArgsConstructor |
| 129 | + @AllArgsConstructor |
| 130 | + public static class KendraResponseResultItem implements Serializable { |
| 131 | + private String id; |
| 132 | + private String type; |
| 133 | + private Object[] additionalAttributes; |
| 134 | + private String documentId; |
| 135 | + private KendraResponseDocumentInfo documentTitle; |
| 136 | + private KendraResponseDocumentInfo documentExcerpt; |
| 137 | + private String documentURI; |
| 138 | + private KendraResponseDocumentAttribute[] documentAttributes; |
| 139 | + private KendraResponseScoreAttributes scoreAttributes; |
| 140 | + private String feedbackToken; |
| 141 | + } |
| 142 | + |
| 143 | + @Data |
| 144 | + @Builder(setterPrefix = "with") |
| 145 | + @NoArgsConstructor |
| 146 | + @AllArgsConstructor |
| 147 | + public static class KendraResponseDocumentInfo implements Serializable { |
| 148 | + private String text; |
| 149 | + private KendraResponseDocumentHighlights[] highlights; |
| 150 | + } |
| 151 | + |
| 152 | + @Data |
| 153 | + @Builder(setterPrefix = "with") |
| 154 | + @NoArgsConstructor |
| 155 | + @AllArgsConstructor |
| 156 | + public static class KendraResponseDocumentHighlights implements Serializable { |
| 157 | + private Integer beginOffset; |
| 158 | + private Integer endOffset; |
| 159 | + private boolean topAnswer; |
| 160 | + private String type; |
| 161 | + } |
| 162 | + |
| 163 | + @Data |
| 164 | + @Builder(setterPrefix = "with") |
| 165 | + @NoArgsConstructor |
| 166 | + @AllArgsConstructor |
| 167 | + public static class KendraResponseDocumentAttribute implements Serializable { |
| 168 | + private String key; |
| 169 | + private Map<String, String> value; |
| 170 | + } |
| 171 | + |
| 172 | + @Data |
| 173 | + @Builder(setterPrefix = "with") |
| 174 | + @NoArgsConstructor |
| 175 | + @AllArgsConstructor |
| 176 | + public static class KendraResponseScoreAttributes implements Serializable { |
| 177 | + private String scoreConfidence; |
| 178 | + } |
| 179 | + |
| 180 | + @Data |
| 181 | + @Builder(setterPrefix = "with") |
| 182 | + @NoArgsConstructor |
| 183 | + @AllArgsConstructor |
| 184 | + public static class NluConfidence implements Serializable { |
| 185 | + private Double score; |
| 186 | + } |
| 187 | + |
| 188 | + @Data |
| 189 | + @Builder(setterPrefix = "with") |
| 190 | + @NoArgsConstructor |
| 191 | + @AllArgsConstructor |
| 192 | + public static class SentimentResponse implements Serializable { |
| 193 | + private String sentiment; |
| 194 | + private SentimentScore sentimentScore; |
| 195 | + } |
| 196 | + |
| 197 | + @Data |
| 198 | + @Builder(setterPrefix = "with") |
| 199 | + @NoArgsConstructor |
| 200 | + @AllArgsConstructor |
| 201 | + public static class SentimentScore implements Serializable { |
| 202 | + private Double mixed; |
| 203 | + private Double negative; |
| 204 | + private Double neutral; |
| 205 | + private Double positive; |
| 206 | + } |
| 207 | + |
| 208 | + @Data |
| 209 | + @Builder(setterPrefix = "with") |
| 210 | + @NoArgsConstructor |
| 211 | + @AllArgsConstructor |
| 212 | + public static class ProposedNextState implements Serializable { |
| 213 | + private DialogAction dialogAction; |
| 214 | + private Intent intent; |
| 215 | + } |
| 216 | + |
| 217 | + @Data |
| 218 | + @Builder(setterPrefix = "with") |
| 219 | + @NoArgsConstructor |
| 220 | + @AllArgsConstructor |
| 221 | + public static class DialogAction implements Serializable { |
| 222 | + private String slotToElicit; |
| 223 | + private String type; |
| 224 | + } |
| 225 | + |
| 226 | + @Data |
| 227 | + @Builder(setterPrefix = "with") |
| 228 | + @NoArgsConstructor |
| 229 | + @AllArgsConstructor |
| 230 | + public static class SessionState implements Serializable { |
| 231 | + private ActiveContext[] activeContexts; |
| 232 | + private Map<String, String> sessionAttributes; |
| 233 | + private RuntimeHints runtimeHints; |
| 234 | + private DialogAction dialogAction; |
| 235 | + private Intent intent; |
| 236 | + private String originatingRequestId; |
| 237 | + } |
| 238 | + |
| 239 | + @Data |
| 240 | + @Builder(setterPrefix = "with") |
| 241 | + @NoArgsConstructor |
| 242 | + @AllArgsConstructor |
| 243 | + public static class ActiveContext implements Serializable { |
| 244 | + private String name; |
| 245 | + private Map<String, String> contextAttributes; |
| 246 | + private TimeToLive timeToLive; |
| 247 | + } |
| 248 | + |
| 249 | + @Data |
| 250 | + @Builder(setterPrefix = "with") |
| 251 | + @NoArgsConstructor |
| 252 | + @AllArgsConstructor |
| 253 | + public static class TimeToLive implements Serializable { |
| 254 | + private Integer timeToLiveInSeconds; |
| 255 | + private Integer turnsToLive; |
| 256 | + } |
| 257 | + |
| 258 | + @Data |
| 259 | + @Builder(setterPrefix = "with") |
| 260 | + @NoArgsConstructor |
| 261 | + @AllArgsConstructor |
| 262 | + public static class RuntimeHints implements Serializable { |
| 263 | + private Map<String, Map<String, Hint>> slotHints; |
| 264 | + } |
| 265 | + |
| 266 | + @Data |
| 267 | + @Builder(setterPrefix = "with") |
| 268 | + @NoArgsConstructor |
| 269 | + @AllArgsConstructor |
| 270 | + public static class Hint implements Serializable { |
| 271 | + private RuntimeHintValue[] runtimeHintValues; |
| 272 | + } |
| 273 | + |
| 274 | + @Data |
| 275 | + @Builder(setterPrefix = "with") |
| 276 | + @NoArgsConstructor |
| 277 | + @AllArgsConstructor |
| 278 | + public static class RuntimeHintValue implements Serializable { |
| 279 | + private String phrase; |
| 280 | + } |
| 281 | + |
| 282 | + @Data |
| 283 | + @Builder(setterPrefix = "with") |
| 284 | + @NoArgsConstructor |
| 285 | + @AllArgsConstructor |
| 286 | + public static class Transcription implements Serializable { |
| 287 | + private String transcription; |
| 288 | + private Double transcriptionConfidence; |
| 289 | + private ResolvedContext resolvedContext; |
| 290 | + private Map<String, Slot> resolvedSlots; |
| 291 | + |
| 292 | + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) |
| 293 | + public Map<String, Slot> getResolvedSlots() { |
| 294 | + return this.resolvedSlots; |
| 295 | + } |
| 296 | + |
| 297 | + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) |
| 298 | + public void setResolvedSlots(Map<String, Slot> resolvedSlots) { |
| 299 | + this.resolvedSlots = resolvedSlots; |
| 300 | + } |
| 301 | + } |
| 302 | + |
| 303 | + @Data |
| 304 | + @Builder(setterPrefix = "with") |
| 305 | + @NoArgsConstructor |
| 306 | + @AllArgsConstructor |
| 307 | + public static class ResolvedContext implements Serializable { |
| 308 | + private String intent; |
| 309 | + } |
| 310 | +} |
0 commit comments