forked from aws/aws-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.go
562 lines (487 loc) · 20.5 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
// Package lexruntimeservice provides a client for Amazon Lex Runtime Service.
package lexruntimeservice
import (
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/request"
)
const opPostText = "PostText"
// PostTextRequest generates a "aws/request.Request" representing the
// client's request for the PostText operation. The "output" return
// value can be used to capture response data after the request's "Send" method
// is called.
//
// See PostText for usage and error information.
//
// Creating a request object using this method should be used when you want to inject
// custom logic into the request's lifecycle using a custom handler, or if you want to
// access properties on the request object before or after sending the request. If
// you just want the service response, call the PostText method directly
// instead.
//
// Note: You must call the "Send" method on the returned request object in order
// to execute the request.
//
// // Example sending a request using the PostTextRequest method.
// req, resp := client.PostTextRequest(params)
//
// err := req.Send()
// if err == nil { // resp is now filled
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText
func (c *LexRuntimeService) PostTextRequest(input *PostTextInput) (req *request.Request, output *PostTextOutput) {
op := &request.Operation{
Name: opPostText,
HTTPMethod: "POST",
HTTPPath: "/bot/{botName}/alias/{botAlias}/user/{userId}/text",
}
if input == nil {
input = &PostTextInput{}
}
output = &PostTextOutput{}
req = c.newRequest(op, input, output)
return
}
// PostText API operation for Amazon Lex Runtime Service.
//
// Sends user input text to Amazon Lex at runtime. Amazon Lex uses the machine
// learning model that the service built for the application to interpret user
// input.
//
// In response, Amazon Lex returns the next message to convey to the user (based
// on the context of the user interaction) and whether to expect a user response
// to the message (dialogState). For example, consider the following response
// messages:
//
// * "What pizza toppings would you like?" – In this case, the dialogState
// would be ElicitSlot (that is, a user response is expected).
//
// * "Your order has been placed." – In this case, Amazon Lex returns one
// of the following dialogState values depending on how the intent fulfillment
// is configured (see fulfillmentActivity in CreateIntent):
//
// FulFilled – The intent fulfillment is configured through a Lambda function.
//
//
// ReadyForFulfilment – The intent's fulfillmentActivity is to simply return
// the intent data back to the client application.
//
// Returns awserr.Error for service API and SDK errors. Use runtime type assertions
// with awserr.Error's Code and Message methods to get detailed information about
// the error.
//
// See the AWS API reference guide for Amazon Lex Runtime Service's
// API operation PostText for usage and error information.
//
// Returned Error Codes:
// * ErrCodeNotFoundException "NotFoundException"
// Resource (such as the Amazon Lex bot or an alias) referred is not found.
//
// * ErrCodeBadRequestException "BadRequestException"
// Request validation failed, there is no usable message in the context, or
// the bot build failed.
//
// * ErrCodeLimitExceededException "LimitExceededException"
//
// * ErrCodeInternalFailureException "InternalFailureException"
// Internal service error. Retry the call.
//
// * ErrCodeConflictException "ConflictException"
// Two clients are using the same AWS account, Amazon Lex bot, and user ID.
//
// * ErrCodeDependencyFailedException "DependencyFailedException"
// One of the downstream dependencies, such as AWS Lambda or Amazon Polly, threw
// an exception. For example, if Amazon Lex does not have sufficient permissions
// to call a Lambda function which results in AWS Lambda throwing an exception.
//
// * ErrCodeBadGatewayException "BadGatewayException"
// Either the Amazon Lex bot is still building, or one of the dependent services
// (Amazon Polly, AWS Lambda) failed with an internal service error.
//
// * ErrCodeLoopDetectedException "LoopDetectedException"
// Lambda fulfilment function returned DelegateDialogAction to Amazon Lex without
// changing any slot values.
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostText
func (c *LexRuntimeService) PostText(input *PostTextInput) (*PostTextOutput, error) {
req, out := c.PostTextRequest(input)
err := req.Send()
return out, err
}
// Represents an option to be shown on the client platform (Facebook, Slack,
// etc.)
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/Button
type Button struct {
_ struct{} `type:"structure"`
// Text visible to the user on the button.
//
// Text is a required field
Text *string `locationName:"text" min:"1" type:"string" required:"true"`
// Value sent to Amazon Lex when user clicks the button. For example, consider
// button text "NYC". When the user clicks the button, the value sent can be
// "New York City".
//
// Value is a required field
Value *string `locationName:"value" min:"1" type:"string" required:"true"`
}
// String returns the string representation
func (s Button) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s Button) GoString() string {
return s.String()
}
// SetText sets the Text field's value.
func (s *Button) SetText(v string) *Button {
s.Text = &v
return s
}
// SetValue sets the Value field's value.
func (s *Button) SetValue(v string) *Button {
s.Value = &v
return s
}
// Represents an option rendered to the user when a prompt is shown. It could
// be an image, a button, a link, or text.
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/GenericAttachment
type GenericAttachment struct {
_ struct{} `type:"structure"`
AttachmentLinkUrl *string `locationName:"attachmentLinkUrl" min:"1" type:"string"`
// List of options to show to the user.
Buttons []*Button `locationName:"buttons" type:"list"`
// URL of an image that is displayed to the user.
ImageUrl *string `locationName:"imageUrl" min:"1" type:"string"`
// Subtitle shown below the title.
SubTitle *string `locationName:"subTitle" min:"1" type:"string"`
// Title of the option.
Title *string `locationName:"title" min:"1" type:"string"`
}
// String returns the string representation
func (s GenericAttachment) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s GenericAttachment) GoString() string {
return s.String()
}
// SetAttachmentLinkUrl sets the AttachmentLinkUrl field's value.
func (s *GenericAttachment) SetAttachmentLinkUrl(v string) *GenericAttachment {
s.AttachmentLinkUrl = &v
return s
}
// SetButtons sets the Buttons field's value.
func (s *GenericAttachment) SetButtons(v []*Button) *GenericAttachment {
s.Buttons = v
return s
}
// SetImageUrl sets the ImageUrl field's value.
func (s *GenericAttachment) SetImageUrl(v string) *GenericAttachment {
s.ImageUrl = &v
return s
}
// SetSubTitle sets the SubTitle field's value.
func (s *GenericAttachment) SetSubTitle(v string) *GenericAttachment {
s.SubTitle = &v
return s
}
// SetTitle sets the Title field's value.
func (s *GenericAttachment) SetTitle(v string) *GenericAttachment {
s.Title = &v
return s
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostTextRequest
type PostTextInput struct {
_ struct{} `type:"structure"`
// Alias of the Amazon Lex bot.
//
// BotAlias is a required field
BotAlias *string `location:"uri" locationName:"botAlias" type:"string" required:"true"`
// Name of the Amazon Lex bot.
//
// BotName is a required field
BotName *string `location:"uri" locationName:"botName" type:"string" required:"true"`
// Text user entered (Amazon Lex interprets this text).
//
// InputText is a required field
InputText *string `locationName:"inputText" min:"1" type:"string" required:"true"`
// A session represents the dialog between a user and Amazon Lex. At runtime,
// a client application can pass contextual information (session attributes)
// in the request. For example, "FirstName" : "Joe". Amazon Lex passes these
// session attributes to the AWS Lambda functions configured for the intent
// (see dialogCodeHook and fulfillmentActivity.codeHook in CreateIntent).
//
// In your Lambda function, you can use the session attributes for customization.
// Some examples are:
//
// * In a pizza ordering application, if you can pass user location as a
// session attribute (for example, "Location" : "111 Maple street"), your
// Lambda function might use this information to determine the closest pizzeria
// to place the order.
//
// * Use session attributes to personalize prompts. For example, you pass
// in user name as a session attribute ("FirstName" : "Joe"), you might configure
// subsequent prompts to refer to this attribute, as $session.FirstName".
// At runtime, Amazon Lex substitutes a real value when it generates a prompt,
// such as "Hello Joe, what would you like to order?"
//
// Amazon Lex does not persist session attributes.
//
// If the intent is configured without a Lambda function to process the intent
// (that is, the client application to process the intent), Amazon Lex simply
// returns the session attributes back to the client application.
//
// If the intent is configured with a Lambda function to process the intent,
// Amazon Lex passes the incoming session attributes to the Lambda function.
// The Lambda function must return these session attributes if you want Amazon
// Lex to return them back to the client.
SessionAttributes map[string]*string `locationName:"sessionAttributes" type:"map"`
// User ID of your client application. Typically, each of your application users
// should have a unique ID. Note the following considerations:
//
// * If you want a user to start a conversation on one mobile device and
// continue the conversation on another device, you might choose a user-specific
// identifier, such as a login or Amazon Cognito user ID (assuming your application
// is using Amazon Cognito).
//
// * If you want the same user to be able to have two independent conversations
// on two different devices, you might choose a device-specific identifier,
// such as device ID, or some globally unique identifier.
//
// UserId is a required field
UserId *string `location:"uri" locationName:"userId" min:"2" type:"string" required:"true"`
}
// String returns the string representation
func (s PostTextInput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PostTextInput) GoString() string {
return s.String()
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *PostTextInput) Validate() error {
invalidParams := request.ErrInvalidParams{Context: "PostTextInput"}
if s.BotAlias == nil {
invalidParams.Add(request.NewErrParamRequired("BotAlias"))
}
if s.BotName == nil {
invalidParams.Add(request.NewErrParamRequired("BotName"))
}
if s.InputText == nil {
invalidParams.Add(request.NewErrParamRequired("InputText"))
}
if s.InputText != nil && len(*s.InputText) < 1 {
invalidParams.Add(request.NewErrParamMinLen("InputText", 1))
}
if s.UserId == nil {
invalidParams.Add(request.NewErrParamRequired("UserId"))
}
if s.UserId != nil && len(*s.UserId) < 2 {
invalidParams.Add(request.NewErrParamMinLen("UserId", 2))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
// SetBotAlias sets the BotAlias field's value.
func (s *PostTextInput) SetBotAlias(v string) *PostTextInput {
s.BotAlias = &v
return s
}
// SetBotName sets the BotName field's value.
func (s *PostTextInput) SetBotName(v string) *PostTextInput {
s.BotName = &v
return s
}
// SetInputText sets the InputText field's value.
func (s *PostTextInput) SetInputText(v string) *PostTextInput {
s.InputText = &v
return s
}
// SetSessionAttributes sets the SessionAttributes field's value.
func (s *PostTextInput) SetSessionAttributes(v map[string]*string) *PostTextInput {
s.SessionAttributes = v
return s
}
// SetUserId sets the UserId field's value.
func (s *PostTextInput) SetUserId(v string) *PostTextInput {
s.UserId = &v
return s
}
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/PostTextResponse
type PostTextOutput struct {
_ struct{} `type:"structure"`
// Represents the message type to be conveyed to the user. For example:
//
// * ElicitIntent – Amazon Lex wants to elicit user intent. For example,
// Amazon Lex did not understand the first utterances such as "I want to
// order pizza", which indicates the OrderPizza intent. If Amazon Lex doesn't
// understand the intent, it returns this dialogState. Another example is
// when your intent is configured with a follow up prompt. For example, after
// OrderPizza intent is fulfilled, the intent might have a follow up prompt
// such as " Do you want to order a drink or desert?" In this case, Amazon
// Lex returns this dialogState.
//
// * ConfirmIntent – Amazon Lex is expecting a yes/no response from the user
// indicating whether to go ahead and fulfill the intent (for example, OK
// to go ahead and order the pizza). In addition to a yes/no reply, the user
// might provide a response with additional slot information (either new
// slot information or changes to the existing slot values). For example,
// "Yes, but change to thick crust." Amazon Lex understands the additional
// information and updates the intent slots accordingly.
//
// Consider another example. Before fulfilling an order, your application might
// prompt for confirmation such as "Do you want to place this pizza order?"
// A user might reply with "No, I want to order a drink." Amazon Lex recognizes
// the new OrderDrink intent.
//
// * ElicitSlot – Amazon Lex is expecting a value of a slot for the current
// intent. For example, suppose Amazon Lex asks, "What size pizza would you
// like?" A user might reply with "Medium pepperoni pizza." Amazon Lex recognizes
// the size and the topping as the two separate slot values.
//
// * Fulfilled – Conveys that the Lambda function has successfully fulfilled
// the intent. If Lambda function returns a statement/message to convey the
// fulfillment result, Amazon Lex passes this string to the client. If not,
// Amazon Lex looks for conclusionStatement that you configured for the intent.
//
//
// If both the Lambda function statement and the conclusionStatement are missing,
// Amazon Lex throws a bad request exception.
//
// * ReadyForFulfillment – conveys that the client has to do the fulfillment
// work for the intent. This is the case when the current intent is configured
// with ReturnIntent as the fulfillmentActivity , where Amazon Lex returns
// this state to client.
//
// * Failed – Conversation with the user failed. Some of the reasons for
// this dialogState are: after the configured number of attempts the user
// didn't provide an appropriate response, or the Lambda function failed
// to fulfill an intent.
DialogState *string `locationName:"dialogState" type:"string" enum:"DialogState"`
// Intent Amazon Lex inferred from the user input text. This is one of the intents
// configured for the bot.
IntentName *string `locationName:"intentName" type:"string"`
// Prompt (or statement) to convey to the user. This is based on the application
// configuration and context. For example, if Amazon Lex did not understand
// the user intent, it sends the clarificationPrompt configured for the application.
// In another example, if the intent requires confirmation before taking the
// fulfillment action, it sends the confirmationPrompt. Suppose the Lambda function
// successfully fulfilled the intent, and sent a message to convey to the user.
// In that situation, Amazon Lex sends that message in the response.
Message *string `locationName:"message" min:"1" type:"string"`
// Represents the options that the user has to respond to the current prompt.
// Amazon Lex sends this in the response only if the dialogState value indicates
// that a user response is expected.
ResponseCard *ResponseCard `locationName:"responseCard" type:"structure"`
// Map of key value pairs representing the session specific context information.
SessionAttributes map[string]*string `locationName:"sessionAttributes" type:"map"`
// If dialogState value is ElicitSlot, returns the name of the slot for which
// Amazon Lex is eliciting a value.
SlotToElicit *string `locationName:"slotToElicit" type:"string"`
// Intent slots (name/value pairs) Amazon Lex detected so far from the user
// input in the conversation.
Slots map[string]*string `locationName:"slots" type:"map"`
}
// String returns the string representation
func (s PostTextOutput) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s PostTextOutput) GoString() string {
return s.String()
}
// SetDialogState sets the DialogState field's value.
func (s *PostTextOutput) SetDialogState(v string) *PostTextOutput {
s.DialogState = &v
return s
}
// SetIntentName sets the IntentName field's value.
func (s *PostTextOutput) SetIntentName(v string) *PostTextOutput {
s.IntentName = &v
return s
}
// SetMessage sets the Message field's value.
func (s *PostTextOutput) SetMessage(v string) *PostTextOutput {
s.Message = &v
return s
}
// SetResponseCard sets the ResponseCard field's value.
func (s *PostTextOutput) SetResponseCard(v *ResponseCard) *PostTextOutput {
s.ResponseCard = v
return s
}
// SetSessionAttributes sets the SessionAttributes field's value.
func (s *PostTextOutput) SetSessionAttributes(v map[string]*string) *PostTextOutput {
s.SessionAttributes = v
return s
}
// SetSlotToElicit sets the SlotToElicit field's value.
func (s *PostTextOutput) SetSlotToElicit(v string) *PostTextOutput {
s.SlotToElicit = &v
return s
}
// SetSlots sets the Slots field's value.
func (s *PostTextOutput) SetSlots(v map[string]*string) *PostTextOutput {
s.Slots = v
return s
}
// If you configure a response card when creating your bots, Amazon Lex substitutes
// the session attributes and slot values available, and then returns it. The
// response card can also come from a Lambda function ( dialogCodeHook and fulfillmentActivity
// on an intent).
// Please also see https://docs.aws.amazon.com/goto/WebAPI/runtime.lex-2016-11-28/ResponseCard
type ResponseCard struct {
_ struct{} `type:"structure"`
// Content type of the response.
ContentType *string `locationName:"contentType" type:"string" enum:"ContentType"`
// An array of attachment objects representing options.
GenericAttachments []*GenericAttachment `locationName:"genericAttachments" type:"list"`
// Version of response card format.
Version *string `locationName:"version" type:"string"`
}
// String returns the string representation
func (s ResponseCard) String() string {
return awsutil.Prettify(s)
}
// GoString returns the string representation
func (s ResponseCard) GoString() string {
return s.String()
}
// SetContentType sets the ContentType field's value.
func (s *ResponseCard) SetContentType(v string) *ResponseCard {
s.ContentType = &v
return s
}
// SetGenericAttachments sets the GenericAttachments field's value.
func (s *ResponseCard) SetGenericAttachments(v []*GenericAttachment) *ResponseCard {
s.GenericAttachments = v
return s
}
// SetVersion sets the Version field's value.
func (s *ResponseCard) SetVersion(v string) *ResponseCard {
s.Version = &v
return s
}
const (
// ContentTypeApplicationVndAmazonawsCardGeneric is a ContentType enum value
ContentTypeApplicationVndAmazonawsCardGeneric = "application/vnd.amazonaws.card.generic"
)
const (
// DialogStateElicitIntent is a DialogState enum value
DialogStateElicitIntent = "ElicitIntent"
// DialogStateConfirmIntent is a DialogState enum value
DialogStateConfirmIntent = "ConfirmIntent"
// DialogStateElicitSlot is a DialogState enum value
DialogStateElicitSlot = "ElicitSlot"
// DialogStateFulfilled is a DialogState enum value
DialogStateFulfilled = "Fulfilled"
// DialogStateReadyForFulfillment is a DialogState enum value
DialogStateReadyForFulfillment = "ReadyForFulfillment"
// DialogStateFailed is a DialogState enum value
DialogStateFailed = "Failed"
)