File: examples_test.go

package info (click to toggle)
golang-github-aws-aws-sdk-go 1.16.18%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports, experimental
  • size: 93,084 kB
  • sloc: ruby: 193; makefile: 174; xml: 11
file content (524 lines) | stat: -rw-r--r-- 17,875 bytes parent folder | download
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
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.

package lexmodelbuildingservice_test

import (
	"fmt"
	"strings"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/lexmodelbuildingservice"
)

var _ time.Duration
var _ strings.Reader
var _ aws.Config

func parseTime(layout, value string) *time.Time {
	t, err := time.Parse(layout, value)
	if err != nil {
		panic(err)
	}
	return &t
}

// To get information about a bot
//
// This example shows how to get configuration information for a bot.
func ExampleLexModelBuildingService_GetBot_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetBotInput{
		Name:           aws.String("DocOrderPizza"),
		VersionOrAlias: aws.String("$LATEST"),
	}

	result, err := svc.GetBot(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To get a list of bots
//
// This example shows how to get a list of all of the bots in your account.
func ExampleLexModelBuildingService_GetBots_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetBotsInput{
		MaxResults: aws.Int64(5),
		NextToken:  aws.String(""),
	}

	result, err := svc.GetBots(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To get a information about an intent
//
// This example shows how to get information about an intent.
func ExampleLexModelBuildingService_GetIntent_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetIntentInput{
		Name:    aws.String("DocOrderPizza"),
		Version: aws.String("$LATEST"),
	}

	result, err := svc.GetIntent(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To get a list of intents
//
// This example shows how to get a list of all of the intents in your account.
func ExampleLexModelBuildingService_GetIntents_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetIntentsInput{
		MaxResults: aws.Int64(10),
		NextToken:  aws.String(""),
	}

	result, err := svc.GetIntents(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To get information about a slot type
//
// This example shows how to get information about a slot type.
func ExampleLexModelBuildingService_GetSlotType_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetSlotTypeInput{
		Name:    aws.String("DocPizzaCrustType"),
		Version: aws.String("$LATEST"),
	}

	result, err := svc.GetSlotType(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To get a list of slot types
//
// This example shows how to get a list of all of the slot types in your account.
func ExampleLexModelBuildingService_GetSlotTypes_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.GetSlotTypesInput{
		MaxResults: aws.Int64(10),
		NextToken:  aws.String(""),
	}

	result, err := svc.GetSlotTypes(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeNotFoundException:
				fmt.Println(lexmodelbuildingservice.ErrCodeNotFoundException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To create a bot
//
// This example shows how to create a bot for ordering pizzas.
func ExampleLexModelBuildingService_PutBot_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.PutBotInput{
		AbortStatement: &lexmodelbuildingservice.Statement{
			Messages: []*lexmodelbuildingservice.Message{
				{
					Content:     aws.String("I don't understand. Can you try again?"),
					ContentType: aws.String("PlainText"),
				},
				{
					Content:     aws.String("I'm sorry, I don't understand."),
					ContentType: aws.String("PlainText"),
				},
			},
		},
		ChildDirected: aws.Bool(true),
		ClarificationPrompt: &lexmodelbuildingservice.Prompt{
			MaxAttempts: aws.Int64(1),
			Messages: []*lexmodelbuildingservice.Message{
				{
					Content:     aws.String("I'm sorry, I didn't hear that. Can you repeate what you just said?"),
					ContentType: aws.String("PlainText"),
				},
				{
					Content:     aws.String("Can you say that again?"),
					ContentType: aws.String("PlainText"),
				},
			},
		},
		Description:             aws.String("Orders a pizza from a local pizzeria."),
		IdleSessionTTLInSeconds: aws.Int64(300),
		Intents: []*lexmodelbuildingservice.Intent{
			{
				IntentName:    aws.String("DocOrderPizza"),
				IntentVersion: aws.String("$LATEST"),
			},
		},
		Locale:          aws.String("en-US"),
		Name:            aws.String("DocOrderPizzaBot"),
		ProcessBehavior: aws.String("SAVE"),
	}

	result, err := svc.PutBot(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeConflictException:
				fmt.Println(lexmodelbuildingservice.ErrCodeConflictException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			case lexmodelbuildingservice.ErrCodePreconditionFailedException:
				fmt.Println(lexmodelbuildingservice.ErrCodePreconditionFailedException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To create an intent
//
// This example shows how to create an intent for ordering pizzas.
func ExampleLexModelBuildingService_PutIntent_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.PutIntentInput{
		ConclusionStatement: &lexmodelbuildingservice.Statement{
			Messages: []*lexmodelbuildingservice.Message{
				{
					Content:     aws.String("All right, I ordered  you a {Crust} crust {Type} pizza with {Sauce} sauce."),
					ContentType: aws.String("PlainText"),
				},
				{
					Content:     aws.String("OK, your {Crust} crust {Type} pizza with {Sauce} sauce is on the way."),
					ContentType: aws.String("PlainText"),
				},
			},
			ResponseCard: aws.String("foo"),
		},
		ConfirmationPrompt: &lexmodelbuildingservice.Prompt{
			MaxAttempts: aws.Int64(1),
			Messages: []*lexmodelbuildingservice.Message{
				{
					Content:     aws.String("Should I order  your {Crust} crust {Type} pizza with {Sauce} sauce?"),
					ContentType: aws.String("PlainText"),
				},
			},
		},
		Description: aws.String("Order a pizza from a local pizzeria."),
		FulfillmentActivity: &lexmodelbuildingservice.FulfillmentActivity{
			Type: aws.String("ReturnIntent"),
		},
		Name: aws.String("DocOrderPizza"),
		RejectionStatement: &lexmodelbuildingservice.Statement{
			Messages: []*lexmodelbuildingservice.Message{
				{
					Content:     aws.String("Ok, I'll cancel your order."),
					ContentType: aws.String("PlainText"),
				},
				{
					Content:     aws.String("I cancelled your order."),
					ContentType: aws.String("PlainText"),
				},
			},
		},
		SampleUtterances: []*string{
			aws.String("Order me a pizza."),
			aws.String("Order me a {Type} pizza."),
			aws.String("I want a {Crust} crust {Type} pizza"),
			aws.String("I want a {Crust} crust {Type} pizza with {Sauce} sauce."),
		},
		Slots: []*lexmodelbuildingservice.Slot{
			{
				Description: aws.String("The type of pizza to order."),
				Name:        aws.String("Type"),
				Priority:    aws.Int64(1),
				SampleUtterances: []*string{
					aws.String("Get me a {Type} pizza."),
					aws.String("A {Type} pizza please."),
					aws.String("I'd like a {Type} pizza."),
				},
				SlotConstraint:  aws.String("Required"),
				SlotType:        aws.String("DocPizzaType"),
				SlotTypeVersion: aws.String("$LATEST"),
				ValueElicitationPrompt: &lexmodelbuildingservice.Prompt{
					MaxAttempts: aws.Int64(1),
					Messages: []*lexmodelbuildingservice.Message{
						{
							Content:     aws.String("What type of pizza would you like?"),
							ContentType: aws.String("PlainText"),
						},
						{
							Content:     aws.String("Vegie or cheese pizza?"),
							ContentType: aws.String("PlainText"),
						},
						{
							Content:     aws.String("I can get you a vegie or a cheese pizza."),
							ContentType: aws.String("PlainText"),
						},
					},
				},
			},
			{
				Description: aws.String("The type of pizza crust to order."),
				Name:        aws.String("Crust"),
				Priority:    aws.Int64(2),
				SampleUtterances: []*string{
					aws.String("Make it a {Crust} crust."),
					aws.String("I'd like a {Crust} crust."),
				},
				SlotConstraint:  aws.String("Required"),
				SlotType:        aws.String("DocPizzaCrustType"),
				SlotTypeVersion: aws.String("$LATEST"),
				ValueElicitationPrompt: &lexmodelbuildingservice.Prompt{
					MaxAttempts: aws.Int64(1),
					Messages: []*lexmodelbuildingservice.Message{
						{
							Content:     aws.String("What type of crust would you like?"),
							ContentType: aws.String("PlainText"),
						},
						{
							Content:     aws.String("Thick or thin crust?"),
							ContentType: aws.String("PlainText"),
						},
					},
				},
			},
			{
				Description: aws.String("The type of sauce to use on the pizza."),
				Name:        aws.String("Sauce"),
				Priority:    aws.Int64(3),
				SampleUtterances: []*string{
					aws.String("Make it {Sauce} sauce."),
					aws.String("I'd like {Sauce} sauce."),
				},
				SlotConstraint:  aws.String("Required"),
				SlotType:        aws.String("DocPizzaSauceType"),
				SlotTypeVersion: aws.String("$LATEST"),
				ValueElicitationPrompt: &lexmodelbuildingservice.Prompt{
					MaxAttempts: aws.Int64(1),
					Messages: []*lexmodelbuildingservice.Message{
						{
							Content:     aws.String("White or red sauce?"),
							ContentType: aws.String("PlainText"),
						},
						{
							Content:     aws.String("Garlic or tomato sauce?"),
							ContentType: aws.String("PlainText"),
						},
					},
				},
			},
		},
	}

	result, err := svc.PutIntent(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeConflictException:
				fmt.Println(lexmodelbuildingservice.ErrCodeConflictException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			case lexmodelbuildingservice.ErrCodePreconditionFailedException:
				fmt.Println(lexmodelbuildingservice.ErrCodePreconditionFailedException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}

// To Create a Slot Type
//
// This example shows how to create a slot type that describes pizza sauces.
func ExampleLexModelBuildingService_PutSlotType_shared00() {
	svc := lexmodelbuildingservice.New(session.New())
	input := &lexmodelbuildingservice.PutSlotTypeInput{
		Description: aws.String("Available pizza sauces"),
		EnumerationValues: []*lexmodelbuildingservice.EnumerationValue{
			{
				Value: aws.String("red"),
			},
			{
				Value: aws.String("white"),
			},
		},
		Name: aws.String("PizzaSauceType"),
	}

	result, err := svc.PutSlotType(input)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			switch aerr.Code() {
			case lexmodelbuildingservice.ErrCodeConflictException:
				fmt.Println(lexmodelbuildingservice.ErrCodeConflictException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeLimitExceededException:
				fmt.Println(lexmodelbuildingservice.ErrCodeLimitExceededException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeInternalFailureException:
				fmt.Println(lexmodelbuildingservice.ErrCodeInternalFailureException, aerr.Error())
			case lexmodelbuildingservice.ErrCodeBadRequestException:
				fmt.Println(lexmodelbuildingservice.ErrCodeBadRequestException, aerr.Error())
			case lexmodelbuildingservice.ErrCodePreconditionFailedException:
				fmt.Println(lexmodelbuildingservice.ErrCodePreconditionFailedException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			// Print the error, cast err to awserr.Error to get the Code and
			// Message from an error.
			fmt.Println(err.Error())
		}
		return
	}

	fmt.Println(result)
}