-
Notifications
You must be signed in to change notification settings - Fork 241
/
input.rs
1950 lines (1935 loc) · 109 KB
/
input.rs
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
use std::fmt::Write;
/// See [`DeleteSessionInput`](crate::input::DeleteSessionInput)
pub mod delete_session_input {
/// A builder for [`DeleteSessionInput`](crate::input::DeleteSessionInput)
#[non_exhaustive]
#[derive(std::default::Default, std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct Builder {
pub(crate) bot_name: std::option::Option<std::string::String>,
pub(crate) bot_alias: std::option::Option<std::string::String>,
pub(crate) user_id: std::option::Option<std::string::String>,
}
impl Builder {
/// <p>The name of the bot that contains the session data.</p>
pub fn bot_name(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_name = Some(input.into());
self
}
/// <p>The name of the bot that contains the session data.</p>
pub fn set_bot_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_name = input;
self
}
/// <p>The alias in use for the bot that contains the session data.</p>
pub fn bot_alias(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_alias = Some(input.into());
self
}
/// <p>The alias in use for the bot that contains the session data.</p>
pub fn set_bot_alias(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_alias = input;
self
}
/// <p>The identifier of the user associated with the session data.</p>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.user_id = Some(input.into());
self
}
/// <p>The identifier of the user associated with the session data.</p>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.user_id = input;
self
}
/// Consumes the builder and constructs a [`DeleteSessionInput`](crate::input::DeleteSessionInput)
pub fn build(
self,
) -> std::result::Result<
crate::input::DeleteSessionInput,
aws_smithy_http::operation::BuildError,
> {
Ok(crate::input::DeleteSessionInput {
bot_name: self.bot_name,
bot_alias: self.bot_alias,
user_id: self.user_id,
})
}
}
}
#[doc(hidden)]
pub type DeleteSessionInputOperationOutputAlias = crate::operation::DeleteSession;
#[doc(hidden)]
pub type DeleteSessionInputOperationRetryAlias = aws_http::retry::AwsErrorRetryPolicy;
impl DeleteSessionInput {
/// Consumes the builder and constructs an Operation<[`DeleteSession`](crate::operation::DeleteSession)>
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::DeleteSession,
aws_http::retry::AwsErrorRetryPolicy,
>,
aws_smithy_http::operation::BuildError,
> {
let mut request = {
fn uri_base(
_input: &crate::input::DeleteSessionInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::BuildError> {
let input_1 = &_input.bot_name;
let input_1 = input_1.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
},
)?;
let bot_name = aws_smithy_http::label::fmt_string(input_1, false);
if bot_name.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
});
}
let input_2 = &_input.bot_alias;
let input_2 = input_2.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
},
)?;
let bot_alias = aws_smithy_http::label::fmt_string(input_2, false);
if bot_alias.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
});
}
let input_3 = &_input.user_id;
let input_3 = input_3.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
},
)?;
let user_id = aws_smithy_http::label::fmt_string(input_3, false);
if user_id.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
});
}
write!(
output,
"/bot/{botName}/alias/{botAlias}/user/{userId}/session",
botName = bot_name,
botAlias = bot_alias,
userId = user_id
)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::DeleteSessionInput,
builder: http::request::Builder,
) -> std::result::Result<http::request::Builder, aws_smithy_http::operation::BuildError>
{
let mut uri = String::new();
uri_base(input, &mut uri)?;
Ok(builder.method("DELETE").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
aws_endpoint::set_endpoint_resolver(
&mut request.properties_mut(),
_config.endpoint_resolver.clone(),
);
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_provider(
&mut request.properties_mut(),
_config.credentials_provider.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::DeleteSession::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"DeleteSession",
"lexruntimeservice",
));
let op = op.with_retry_policy(aws_http::retry::AwsErrorRetryPolicy::new());
Ok(op)
}
/// Creates a new builder-style object to manufacture [`DeleteSessionInput`](crate::input::DeleteSessionInput)
pub fn builder() -> crate::input::delete_session_input::Builder {
crate::input::delete_session_input::Builder::default()
}
}
/// See [`GetSessionInput`](crate::input::GetSessionInput)
pub mod get_session_input {
/// A builder for [`GetSessionInput`](crate::input::GetSessionInput)
#[non_exhaustive]
#[derive(std::default::Default, std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct Builder {
pub(crate) bot_name: std::option::Option<std::string::String>,
pub(crate) bot_alias: std::option::Option<std::string::String>,
pub(crate) user_id: std::option::Option<std::string::String>,
pub(crate) checkpoint_label_filter: std::option::Option<std::string::String>,
}
impl Builder {
/// <p>The name of the bot that contains the session data.</p>
pub fn bot_name(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_name = Some(input.into());
self
}
/// <p>The name of the bot that contains the session data.</p>
pub fn set_bot_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_name = input;
self
}
/// <p>The alias in use for the bot that contains the session data.</p>
pub fn bot_alias(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_alias = Some(input.into());
self
}
/// <p>The alias in use for the bot that contains the session data.</p>
pub fn set_bot_alias(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_alias = input;
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. </p>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.user_id = Some(input.into());
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. </p>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.user_id = input;
self
}
/// <p>A string used to filter the intents returned in the <code>recentIntentSummaryView</code> structure. </p>
/// <p>When you specify a filter, only intents with their <code>checkpointLabel</code> field set to that string are returned.</p>
pub fn checkpoint_label_filter(mut self, input: impl Into<std::string::String>) -> Self {
self.checkpoint_label_filter = Some(input.into());
self
}
/// <p>A string used to filter the intents returned in the <code>recentIntentSummaryView</code> structure. </p>
/// <p>When you specify a filter, only intents with their <code>checkpointLabel</code> field set to that string are returned.</p>
pub fn set_checkpoint_label_filter(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.checkpoint_label_filter = input;
self
}
/// Consumes the builder and constructs a [`GetSessionInput`](crate::input::GetSessionInput)
pub fn build(
self,
) -> std::result::Result<
crate::input::GetSessionInput,
aws_smithy_http::operation::BuildError,
> {
Ok(crate::input::GetSessionInput {
bot_name: self.bot_name,
bot_alias: self.bot_alias,
user_id: self.user_id,
checkpoint_label_filter: self.checkpoint_label_filter,
})
}
}
}
#[doc(hidden)]
pub type GetSessionInputOperationOutputAlias = crate::operation::GetSession;
#[doc(hidden)]
pub type GetSessionInputOperationRetryAlias = aws_http::retry::AwsErrorRetryPolicy;
impl GetSessionInput {
/// Consumes the builder and constructs an Operation<[`GetSession`](crate::operation::GetSession)>
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::GetSession,
aws_http::retry::AwsErrorRetryPolicy,
>,
aws_smithy_http::operation::BuildError,
> {
let mut request = {
fn uri_base(
_input: &crate::input::GetSessionInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::BuildError> {
let input_4 = &_input.bot_name;
let input_4 = input_4.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
},
)?;
let bot_name = aws_smithy_http::label::fmt_string(input_4, false);
if bot_name.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
});
}
let input_5 = &_input.bot_alias;
let input_5 = input_5.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
},
)?;
let bot_alias = aws_smithy_http::label::fmt_string(input_5, false);
if bot_alias.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
});
}
let input_6 = &_input.user_id;
let input_6 = input_6.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
},
)?;
let user_id = aws_smithy_http::label::fmt_string(input_6, false);
if user_id.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
});
}
write!(
output,
"/bot/{botName}/alias/{botAlias}/user/{userId}/session",
botName = bot_name,
botAlias = bot_alias,
userId = user_id
)
.expect("formatting should succeed");
Ok(())
}
fn uri_query(
_input: &crate::input::GetSessionInput,
mut output: &mut String,
) -> Result<(), aws_smithy_http::operation::BuildError> {
let mut query = aws_smithy_http::query::Writer::new(&mut output);
if let Some(inner_7) = &_input.checkpoint_label_filter {
query.push_kv(
"checkpointLabelFilter",
&aws_smithy_http::query::fmt_string(&inner_7),
);
}
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::GetSessionInput,
builder: http::request::Builder,
) -> std::result::Result<http::request::Builder, aws_smithy_http::operation::BuildError>
{
let mut uri = String::new();
uri_base(input, &mut uri)?;
uri_query(input, &mut uri)?;
Ok(builder.method("GET").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from("");
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
aws_endpoint::set_endpoint_resolver(
&mut request.properties_mut(),
_config.endpoint_resolver.clone(),
);
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_provider(
&mut request.properties_mut(),
_config.credentials_provider.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::GetSession::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"GetSession",
"lexruntimeservice",
));
let op = op.with_retry_policy(aws_http::retry::AwsErrorRetryPolicy::new());
Ok(op)
}
/// Creates a new builder-style object to manufacture [`GetSessionInput`](crate::input::GetSessionInput)
pub fn builder() -> crate::input::get_session_input::Builder {
crate::input::get_session_input::Builder::default()
}
}
/// See [`PostContentInput`](crate::input::PostContentInput)
pub mod post_content_input {
/// A builder for [`PostContentInput`](crate::input::PostContentInput)
#[non_exhaustive]
#[derive(std::default::Default, std::fmt::Debug)]
pub struct Builder {
pub(crate) bot_name: std::option::Option<std::string::String>,
pub(crate) bot_alias: std::option::Option<std::string::String>,
pub(crate) user_id: std::option::Option<std::string::String>,
pub(crate) session_attributes: std::option::Option<std::string::String>,
pub(crate) request_attributes: std::option::Option<std::string::String>,
pub(crate) content_type: std::option::Option<std::string::String>,
pub(crate) accept: std::option::Option<std::string::String>,
pub(crate) input_stream: std::option::Option<aws_smithy_http::byte_stream::ByteStream>,
pub(crate) active_contexts: std::option::Option<std::string::String>,
}
impl Builder {
/// <p>Name of the Amazon Lex bot.</p>
pub fn bot_name(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_name = Some(input.into());
self
}
/// <p>Name of the Amazon Lex bot.</p>
pub fn set_bot_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_name = input;
self
}
/// <p>Alias of the Amazon Lex bot.</p>
pub fn bot_alias(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_alias = Some(input.into());
self
}
/// <p>Alias of the Amazon Lex bot.</p>
pub fn set_bot_alias(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_alias = input;
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
/// <p>To decide the user ID to use for your application, consider the following factors.</p>
/// <ul>
/// <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li>
/// <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li>
/// <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li>
/// <li> <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li>
/// </ul>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.user_id = Some(input.into());
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
/// <p>To decide the user ID to use for your application, consider the following factors.</p>
/// <ul>
/// <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li>
/// <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li>
/// <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li>
/// <li> <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li>
/// </ul>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.user_id = input;
self
}
/// <p>You pass this value as the <code>x-amz-lex-session-attributes</code> HTTP header.</p>
/// <p>Application-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>sessionAttributes</code> and <code>requestAttributes</code> headers is limited to 12 KB.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
pub fn session_attributes(mut self, input: impl Into<std::string::String>) -> Self {
self.session_attributes = Some(input.into());
self
}
/// <p>You pass this value as the <code>x-amz-lex-session-attributes</code> HTTP header.</p>
/// <p>Application-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>sessionAttributes</code> and <code>requestAttributes</code> headers is limited to 12 KB.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
pub fn set_session_attributes(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.session_attributes = input;
self
}
/// <p>You pass this value as the <code>x-amz-lex-request-attributes</code> HTTP header.</p>
/// <p>Request-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>requestAttributes</code> and <code>sessionAttributes</code> headers is limited to 12 KB.</p>
/// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
pub fn request_attributes(mut self, input: impl Into<std::string::String>) -> Self {
self.request_attributes = Some(input.into());
self
}
/// <p>You pass this value as the <code>x-amz-lex-request-attributes</code> HTTP header.</p>
/// <p>Request-specific information passed between Amazon Lex and a client application. The value must be a JSON serialized and base64 encoded map with string keys and values. The total size of the <code>requestAttributes</code> and <code>sessionAttributes</code> headers is limited to 12 KB.</p>
/// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
pub fn set_request_attributes(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.request_attributes = input;
self
}
/// <p> You pass this value as the <code>Content-Type</code> HTTP header. </p>
/// <p> Indicates the audio format or text. The header value must start with one of the following prefixes: </p>
/// <ul>
/// <li> <p>PCM format, audio data must be in little-endian byte order.</p>
/// <ul>
/// <li> <p>audio/l16; rate=16000; channels=1</p> </li>
/// <li> <p>audio/x-l16; sample-rate=16000; channel-count=1</p> </li>
/// <li> <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false </p> </li>
/// </ul> </li>
/// <li> <p>Opus format</p>
/// <ul>
/// <li> <p>audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=256000; frame-size-milliseconds=4</p> </li>
/// </ul> </li>
/// <li> <p>Text format</p>
/// <ul>
/// <li> <p>text/plain; charset=utf-8</p> </li>
/// </ul> </li>
/// </ul>
pub fn content_type(mut self, input: impl Into<std::string::String>) -> Self {
self.content_type = Some(input.into());
self
}
/// <p> You pass this value as the <code>Content-Type</code> HTTP header. </p>
/// <p> Indicates the audio format or text. The header value must start with one of the following prefixes: </p>
/// <ul>
/// <li> <p>PCM format, audio data must be in little-endian byte order.</p>
/// <ul>
/// <li> <p>audio/l16; rate=16000; channels=1</p> </li>
/// <li> <p>audio/x-l16; sample-rate=16000; channel-count=1</p> </li>
/// <li> <p>audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false </p> </li>
/// </ul> </li>
/// <li> <p>Opus format</p>
/// <ul>
/// <li> <p>audio/x-cbr-opus-with-preamble; preamble-size=0; bit-rate=256000; frame-size-milliseconds=4</p> </li>
/// </ul> </li>
/// <li> <p>Text format</p>
/// <ul>
/// <li> <p>text/plain; charset=utf-8</p> </li>
/// </ul> </li>
/// </ul>
pub fn set_content_type(mut self, input: std::option::Option<std::string::String>) -> Self {
self.content_type = input;
self
}
/// <p> You pass this value as the <code>Accept</code> HTTP header. </p>
/// <p> The message Amazon Lex returns in the response can be either text or speech based on the <code>Accept</code> HTTP header value in the request. </p>
/// <ul>
/// <li> <p> If the value is <code>text/plain; charset=utf-8</code>, Amazon Lex returns text in the response. </p> </li>
/// <li> <p> If the value begins with <code>audio/</code>, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech (using the configuration you specified in the <code>Accept</code> header). For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex returns speech in the MPEG format.</p> </li>
/// <li> <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> in 16-bit, little endian format. </p> </li>
/// <li> <p>The following are the accepted values:</p>
/// <ul>
/// <li> <p>audio/mpeg</p> </li>
/// <li> <p>audio/ogg</p> </li>
/// <li> <p>audio/pcm</p> </li>
/// <li> <p>text/plain; charset=utf-8</p> </li>
/// <li> <p>audio/* (defaults to mpeg)</p> </li>
/// </ul> </li>
/// </ul>
pub fn accept(mut self, input: impl Into<std::string::String>) -> Self {
self.accept = Some(input.into());
self
}
/// <p> You pass this value as the <code>Accept</code> HTTP header. </p>
/// <p> The message Amazon Lex returns in the response can be either text or speech based on the <code>Accept</code> HTTP header value in the request. </p>
/// <ul>
/// <li> <p> If the value is <code>text/plain; charset=utf-8</code>, Amazon Lex returns text in the response. </p> </li>
/// <li> <p> If the value begins with <code>audio/</code>, Amazon Lex returns speech in the response. Amazon Lex uses Amazon Polly to generate the speech (using the configuration you specified in the <code>Accept</code> header). For example, if you specify <code>audio/mpeg</code> as the value, Amazon Lex returns speech in the MPEG format.</p> </li>
/// <li> <p>If the value is <code>audio/pcm</code>, the speech returned is <code>audio/pcm</code> in 16-bit, little endian format. </p> </li>
/// <li> <p>The following are the accepted values:</p>
/// <ul>
/// <li> <p>audio/mpeg</p> </li>
/// <li> <p>audio/ogg</p> </li>
/// <li> <p>audio/pcm</p> </li>
/// <li> <p>text/plain; charset=utf-8</p> </li>
/// <li> <p>audio/* (defaults to mpeg)</p> </li>
/// </ul> </li>
/// </ul>
pub fn set_accept(mut self, input: std::option::Option<std::string::String>) -> Self {
self.accept = input;
self
}
/// <p> User input in PCM or Opus audio format or text format as described in the <code>Content-Type</code> HTTP header. </p>
/// <p>You can stream audio data to Amazon Lex or you can create a local buffer that captures all of the audio data before sending. In general, you get better performance if you stream audio data rather than buffering the data locally.</p>
pub fn input_stream(mut self, input: aws_smithy_http::byte_stream::ByteStream) -> Self {
self.input_stream = Some(input);
self
}
/// <p> User input in PCM or Opus audio format or text format as described in the <code>Content-Type</code> HTTP header. </p>
/// <p>You can stream audio data to Amazon Lex or you can create a local buffer that captures all of the audio data before sending. In general, you get better performance if you stream audio data rather than buffering the data locally.</p>
pub fn set_input_stream(
mut self,
input: std::option::Option<aws_smithy_http::byte_stream::ByteStream>,
) -> Self {
self.input_stream = input;
self
}
/// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
/// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
pub fn active_contexts(mut self, input: impl Into<std::string::String>) -> Self {
self.active_contexts = Some(input.into());
self
}
/// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
/// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
pub fn set_active_contexts(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.active_contexts = input;
self
}
/// Consumes the builder and constructs a [`PostContentInput`](crate::input::PostContentInput)
pub fn build(
self,
) -> std::result::Result<
crate::input::PostContentInput,
aws_smithy_http::operation::BuildError,
> {
Ok(crate::input::PostContentInput {
bot_name: self.bot_name,
bot_alias: self.bot_alias,
user_id: self.user_id,
session_attributes: self.session_attributes,
request_attributes: self.request_attributes,
content_type: self.content_type,
accept: self.accept,
input_stream: self.input_stream.unwrap_or_default(),
active_contexts: self.active_contexts,
})
}
}
}
#[doc(hidden)]
pub type PostContentInputOperationOutputAlias = crate::operation::PostContent;
#[doc(hidden)]
pub type PostContentInputOperationRetryAlias = aws_http::retry::AwsErrorRetryPolicy;
impl PostContentInput {
/// Consumes the builder and constructs an Operation<[`PostContent`](crate::operation::PostContent)>
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
self,
_config: &crate::config::Config,
) -> std::result::Result<
aws_smithy_http::operation::Operation<
crate::operation::PostContent,
aws_http::retry::AwsErrorRetryPolicy,
>,
aws_smithy_http::operation::BuildError,
> {
let mut request = {
fn uri_base(
_input: &crate::input::PostContentInput,
output: &mut String,
) -> Result<(), aws_smithy_http::operation::BuildError> {
let input_8 = &_input.bot_name;
let input_8 = input_8.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
},
)?;
let bot_name = aws_smithy_http::label::fmt_string(input_8, false);
if bot_name.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_name",
details: "cannot be empty or unset",
});
}
let input_9 = &_input.bot_alias;
let input_9 = input_9.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
},
)?;
let bot_alias = aws_smithy_http::label::fmt_string(input_9, false);
if bot_alias.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "bot_alias",
details: "cannot be empty or unset",
});
}
let input_10 = &_input.user_id;
let input_10 = input_10.as_ref().ok_or(
aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
},
)?;
let user_id = aws_smithy_http::label::fmt_string(input_10, false);
if user_id.is_empty() {
return Err(aws_smithy_http::operation::BuildError::MissingField {
field: "user_id",
details: "cannot be empty or unset",
});
}
write!(
output,
"/bot/{botName}/alias/{botAlias}/user/{userId}/content",
botName = bot_name,
botAlias = bot_alias,
userId = user_id
)
.expect("formatting should succeed");
Ok(())
}
#[allow(clippy::unnecessary_wraps)]
fn update_http_builder(
input: &crate::input::PostContentInput,
builder: http::request::Builder,
) -> std::result::Result<http::request::Builder, aws_smithy_http::operation::BuildError>
{
let mut uri = String::new();
uri_base(input, &mut uri)?;
let builder = crate::http_serde::add_headers_post_content(input, builder)?;
Ok(builder.method("POST").uri(uri))
}
let mut builder = update_http_builder(&self, http::request::Builder::new())?;
builder = aws_smithy_http::header::set_request_header_if_absent(
builder,
http::header::CONTENT_TYPE,
"application/octet-stream",
);
builder
};
let mut properties = aws_smithy_http::property_bag::SharedPropertyBag::new();
#[allow(clippy::useless_conversion)]
let body = aws_smithy_http::body::SdkBody::from(
crate::operation_ser::serialize_payload_post_content_input(self.input_stream)?
.into_inner(),
);
if let Some(content_length) = body.content_length() {
request = aws_smithy_http::header::set_request_header_if_absent(
request,
http::header::CONTENT_LENGTH,
content_length,
);
}
let request = request.body(body).expect("should be valid request");
let mut request = aws_smithy_http::operation::Request::from_parts(request, properties);
request
.properties_mut()
.insert(aws_smithy_http::http_versions::DEFAULT_HTTP_VERSION_LIST.clone());
let mut user_agent = aws_http::user_agent::AwsUserAgent::new_from_environment(
aws_types::os_shim_internal::Env::real(),
crate::API_METADATA.clone(),
);
if let Some(app_name) = _config.app_name() {
user_agent = user_agent.with_app_name(app_name.clone());
}
request.properties_mut().insert(user_agent);
let mut signing_config = aws_sig_auth::signer::OperationSigningConfig::default_config();
signing_config.signing_options.content_sha256_header = true;
request
.properties_mut()
.insert(aws_sig_auth::signer::SignableBody::UnsignedPayload);
request.properties_mut().insert(signing_config);
request
.properties_mut()
.insert(aws_types::SigningService::from_static(
_config.signing_service(),
));
aws_endpoint::set_endpoint_resolver(
&mut request.properties_mut(),
_config.endpoint_resolver.clone(),
);
if let Some(region) = &_config.region {
request.properties_mut().insert(region.clone());
}
aws_http::auth::set_provider(
&mut request.properties_mut(),
_config.credentials_provider.clone(),
);
let op = aws_smithy_http::operation::Operation::new(
request,
crate::operation::PostContent::new(),
)
.with_metadata(aws_smithy_http::operation::Metadata::new(
"PostContent",
"lexruntimeservice",
));
let op = op.with_retry_policy(aws_http::retry::AwsErrorRetryPolicy::new());
Ok(op)
}
/// Creates a new builder-style object to manufacture [`PostContentInput`](crate::input::PostContentInput)
pub fn builder() -> crate::input::post_content_input::Builder {
crate::input::post_content_input::Builder::default()
}
}
/// See [`PostTextInput`](crate::input::PostTextInput)
pub mod post_text_input {
/// A builder for [`PostTextInput`](crate::input::PostTextInput)
#[non_exhaustive]
#[derive(std::default::Default, std::clone::Clone, std::cmp::PartialEq, std::fmt::Debug)]
pub struct Builder {
pub(crate) bot_name: std::option::Option<std::string::String>,
pub(crate) bot_alias: std::option::Option<std::string::String>,
pub(crate) user_id: std::option::Option<std::string::String>,
pub(crate) session_attributes: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
pub(crate) request_attributes: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
pub(crate) input_text: std::option::Option<std::string::String>,
pub(crate) active_contexts: std::option::Option<std::vec::Vec<crate::model::ActiveContext>>,
}
impl Builder {
/// <p>The name of the Amazon Lex bot.</p>
pub fn bot_name(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_name = Some(input.into());
self
}
/// <p>The name of the Amazon Lex bot.</p>
pub fn set_bot_name(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_name = input;
self
}
/// <p>The alias of the Amazon Lex bot.</p>
pub fn bot_alias(mut self, input: impl Into<std::string::String>) -> Self {
self.bot_alias = Some(input.into());
self
}
/// <p>The alias of the Amazon Lex bot.</p>
pub fn set_bot_alias(mut self, input: std::option::Option<std::string::String>) -> Self {
self.bot_alias = input;
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
/// <p>To decide the user ID to use for your application, consider the following factors.</p>
/// <ul>
/// <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li>
/// <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li>
/// <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li>
/// <li> <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li>
/// </ul>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.user_id = Some(input.into());
self
}
/// <p>The ID of the client application user. Amazon Lex uses this to identify a user's conversation with your bot. At runtime, each request must contain the <code>userID</code> field.</p>
/// <p>To decide the user ID to use for your application, consider the following factors.</p>
/// <ul>
/// <li> <p>The <code>userID</code> field must not contain any personally identifiable information of the user, for example, name, personal identification numbers, or other end user personal information.</p> </li>
/// <li> <p>If you want a user to start a conversation on one device and continue on another device, use a user-specific identifier.</p> </li>
/// <li> <p>If you want the same user to be able to have two independent conversations on two different devices, choose a device-specific identifier.</p> </li>
/// <li> <p>A user can't have two independent conversations with two different versions of the same bot. For example, a user can't have a conversation with the PROD and BETA versions of the same bot. If you anticipate that a user will need to have conversation with two different versions, for example, while testing, include the bot alias in the user ID to separate the two conversations.</p> </li>
/// </ul>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.user_id = input;
self
}
/// Adds a key-value pair to `session_attributes`.
///
/// To override the contents of this collection use [`set_session_attributes`](Self::set_session_attributes).
///
/// <p>Application-specific information passed between Amazon Lex and a client application.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
pub fn session_attributes(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
let mut hash_map = self.session_attributes.unwrap_or_default();
hash_map.insert(k.into(), v.into());
self.session_attributes = Some(hash_map);
self
}
/// <p>Application-specific information passed between Amazon Lex and a client application.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-session-attribs">Setting Session Attributes</a>.</p>
pub fn set_session_attributes(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.session_attributes = input;
self
}
/// Adds a key-value pair to `request_attributes`.
///
/// To override the contents of this collection use [`set_request_attributes`](Self::set_request_attributes).
///
/// <p>Request-specific information passed between Amazon Lex and a client application.</p>
/// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
pub fn request_attributes(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
let mut hash_map = self.request_attributes.unwrap_or_default();
hash_map.insert(k.into(), v.into());
self.request_attributes = Some(hash_map);
self
}
/// <p>Request-specific information passed between Amazon Lex and a client application.</p>
/// <p>The namespace <code>x-amz-lex:</code> is reserved for special attributes. Don't create any request attributes with the prefix <code>x-amz-lex:</code>.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/lex/latest/dg/context-mgmt.html#context-mgmt-request-attribs">Setting Request Attributes</a>.</p>
pub fn set_request_attributes(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.request_attributes = input;
self
}
/// <p>The text that the user entered (Amazon Lex interprets this text).</p>
pub fn input_text(mut self, input: impl Into<std::string::String>) -> Self {
self.input_text = Some(input.into());
self
}
/// <p>The text that the user entered (Amazon Lex interprets this text).</p>
pub fn set_input_text(mut self, input: std::option::Option<std::string::String>) -> Self {
self.input_text = input;
self
}
/// Appends an item to `active_contexts`.
///
/// To override the contents of this collection use [`set_active_contexts`](Self::set_active_contexts).
///
/// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
/// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
pub fn active_contexts(mut self, input: crate::model::ActiveContext) -> Self {
let mut v = self.active_contexts.unwrap_or_default();
v.push(input);
self.active_contexts = Some(v);
self
}
/// <p>A list of contexts active for the request. A context can be activated when a previous intent is fulfilled, or by including the context in the request,</p>
/// <p>If you don't specify a list of contexts, Amazon Lex will use the current list of contexts for the session. If you specify an empty list, all contexts for the session are cleared.</p>
pub fn set_active_contexts(
mut self,
input: std::option::Option<std::vec::Vec<crate::model::ActiveContext>>,
) -> Self {
self.active_contexts = input;
self
}
/// Consumes the builder and constructs a [`PostTextInput`](crate::input::PostTextInput)
pub fn build(
self,
) -> std::result::Result<crate::input::PostTextInput, aws_smithy_http::operation::BuildError>
{
Ok(crate::input::PostTextInput {
bot_name: self.bot_name,
bot_alias: self.bot_alias,
user_id: self.user_id,
session_attributes: self.session_attributes,
request_attributes: self.request_attributes,
input_text: self.input_text,
active_contexts: self.active_contexts,
})
}
}
}
#[doc(hidden)]
pub type PostTextInputOperationOutputAlias = crate::operation::PostText;
#[doc(hidden)]
pub type PostTextInputOperationRetryAlias = aws_http::retry::AwsErrorRetryPolicy;
impl PostTextInput {
/// Consumes the builder and constructs an Operation<[`PostText`](crate::operation::PostText)>
#[allow(unused_mut)]
#[allow(clippy::let_and_return)]
#[allow(clippy::needless_borrow)]
pub async fn make_operation(
&self,
_config: &crate::config::Config,
) -> std::result::Result<