-
Notifications
You must be signed in to change notification settings - Fork 244
/
client.rs
530 lines (519 loc) · 34.2 KB
/
client.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
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[derive(Debug)]
pub(crate) struct Handle<
C = aws_smithy_client::erase::DynConnector,
M = crate::middleware::DefaultMiddleware,
R = aws_smithy_client::retry::Standard,
> {
pub(crate) client: aws_smithy_client::Client<C, M, R>,
pub(crate) conf: crate::Config,
}
/// Client for Amazon Personalize Runtime
///
/// Client for invoking operations on Amazon Personalize Runtime. Each operation on Amazon Personalize Runtime is a method on this
/// this struct. `.send()` MUST be invoked on the generated operations to dispatch the request to the service.
///
/// # Examples
/// **Constructing a client and invoking an operation**
/// ```rust,no_run
/// # async fn docs() {
/// // create a shared configuration. This can be used & shared between multiple service clients.
/// let shared_config = aws_config::load_from_env().await;
/// let client = aws_sdk_personalizeruntime::Client::new(&shared_config);
/// // invoke an operation
/// /* let rsp = client
/// .<operation_name>().
/// .<param>("some value")
/// .send().await; */
/// # }
/// ```
/// **Constructing a client with custom configuration**
/// ```rust,no_run
/// use aws_config::RetryConfig;
/// # async fn docs() {
/// let shared_config = aws_config::load_from_env().await;
/// let config = aws_sdk_personalizeruntime::config::Builder::from(&shared_config)
/// .retry_config(RetryConfig::disabled())
/// .build();
/// let client = aws_sdk_personalizeruntime::Client::from_conf(config);
/// # }
#[derive(std::fmt::Debug)]
pub struct Client<
C = aws_smithy_client::erase::DynConnector,
M = crate::middleware::DefaultMiddleware,
R = aws_smithy_client::retry::Standard,
> {
handle: std::sync::Arc<Handle<C, M, R>>,
}
impl<C, M, R> std::clone::Clone for Client<C, M, R> {
fn clone(&self) -> Self {
Self {
handle: self.handle.clone(),
}
}
}
#[doc(inline)]
pub use aws_smithy_client::Builder;
impl<C, M, R> From<aws_smithy_client::Client<C, M, R>> for Client<C, M, R> {
fn from(client: aws_smithy_client::Client<C, M, R>) -> Self {
Self::with_config(client, crate::Config::builder().build())
}
}
impl<C, M, R> Client<C, M, R> {
/// Creates a client with the given service configuration.
pub fn with_config(client: aws_smithy_client::Client<C, M, R>, conf: crate::Config) -> Self {
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
/// Returns the client's configuration.
pub fn conf(&self) -> &crate::Config {
&self.handle.conf
}
}
impl<C, M, R> Client<C, M, R>
where
C: aws_smithy_client::bounds::SmithyConnector,
M: aws_smithy_client::bounds::SmithyMiddleware<C>,
R: aws_smithy_client::retry::NewRequestPolicy,
{
/// Constructs a fluent builder for the [`GetPersonalizedRanking`](crate::client::fluent_builders::GetPersonalizedRanking) operation.
///
/// - The fluent builder is configurable:
/// - [`campaign_arn(impl Into<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::campaign_arn) / [`set_campaign_arn(Option<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_campaign_arn): <p>The Amazon Resource Name (ARN) of the campaign to use for generating the personalized ranking.</p>
/// - [`input_list(Vec<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::input_list) / [`set_input_list(Option<Vec<String>>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_input_list): <p>A list of items (by <code>itemId</code>) to rank. If an item was not included in the training dataset, the item is appended to the end of the reranked list. The maximum is 500.</p>
/// - [`user_id(impl Into<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::user_id) / [`set_user_id(Option<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_user_id): <p>The user for which you want the campaign to provide a personalized ranking.</p>
/// - [`context(HashMap<String, String>)`](crate::client::fluent_builders::GetPersonalizedRanking::context) / [`set_context(Option<HashMap<String, String>>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_context): <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
/// - [`filter_arn(impl Into<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::filter_arn) / [`set_filter_arn(Option<String>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_filter_arn): <p>The Amazon Resource Name (ARN) of a filter you created to include items or exclude items from recommendations for a given user. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
/// - [`filter_values(HashMap<String, String>)`](crate::client::fluent_builders::GetPersonalizedRanking::filter_values) / [`set_filter_values(Option<HashMap<String, String>>)`](crate::client::fluent_builders::GetPersonalizedRanking::set_filter_values): <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p> <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
/// - On success, responds with [`GetPersonalizedRankingOutput`](crate::output::GetPersonalizedRankingOutput) with field(s):
/// - [`personalized_ranking(Option<Vec<PredictedItem>>)`](crate::output::GetPersonalizedRankingOutput::personalized_ranking): <p>A list of items in order of most likely interest to the user. The maximum is 500.</p>
/// - [`recommendation_id(Option<String>)`](crate::output::GetPersonalizedRankingOutput::recommendation_id): <p>The ID of the recommendation.</p>
/// - On failure, responds with [`SdkError<GetPersonalizedRankingError>`](crate::error::GetPersonalizedRankingError)
pub fn get_personalized_ranking(&self) -> fluent_builders::GetPersonalizedRanking<C, M, R> {
fluent_builders::GetPersonalizedRanking::new(self.handle.clone())
}
/// Constructs a fluent builder for the [`GetRecommendations`](crate::client::fluent_builders::GetRecommendations) operation.
///
/// - The fluent builder is configurable:
/// - [`campaign_arn(impl Into<String>)`](crate::client::fluent_builders::GetRecommendations::campaign_arn) / [`set_campaign_arn(Option<String>)`](crate::client::fluent_builders::GetRecommendations::set_campaign_arn): <p>The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.</p>
/// - [`item_id(impl Into<String>)`](crate::client::fluent_builders::GetRecommendations::item_id) / [`set_item_id(Option<String>)`](crate::client::fluent_builders::GetRecommendations::set_item_id): <p>The item ID to provide recommendations for.</p> <p>Required for <code>RELATED_ITEMS</code> recipe type.</p>
/// - [`user_id(impl Into<String>)`](crate::client::fluent_builders::GetRecommendations::user_id) / [`set_user_id(Option<String>)`](crate::client::fluent_builders::GetRecommendations::set_user_id): <p>The user ID to provide recommendations for.</p> <p>Required for <code>USER_PERSONALIZATION</code> recipe type.</p>
/// - [`num_results(i32)`](crate::client::fluent_builders::GetRecommendations::num_results) / [`set_num_results(i32)`](crate::client::fluent_builders::GetRecommendations::set_num_results): <p>The number of results to return. The default is 25. The maximum is 500.</p>
/// - [`context(HashMap<String, String>)`](crate::client::fluent_builders::GetRecommendations::context) / [`set_context(Option<HashMap<String, String>>)`](crate::client::fluent_builders::GetRecommendations::set_context): <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
/// - [`filter_arn(impl Into<String>)`](crate::client::fluent_builders::GetRecommendations::filter_arn) / [`set_filter_arn(Option<String>)`](crate::client::fluent_builders::GetRecommendations::set_filter_arn): <p>The ARN of the filter to apply to the returned recommendations. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p> <p>When using this parameter, be sure the filter resource is <code>ACTIVE</code>.</p>
/// - [`filter_values(HashMap<String, String>)`](crate::client::fluent_builders::GetRecommendations::filter_values) / [`set_filter_values(Option<HashMap<String, String>>)`](crate::client::fluent_builders::GetRecommendations::set_filter_values): <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p> <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
/// - [`recommender_arn(impl Into<String>)`](crate::client::fluent_builders::GetRecommendations::recommender_arn) / [`set_recommender_arn(Option<String>)`](crate::client::fluent_builders::GetRecommendations::set_recommender_arn): <p>The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case.</p>
/// - On success, responds with [`GetRecommendationsOutput`](crate::output::GetRecommendationsOutput) with field(s):
/// - [`item_list(Option<Vec<PredictedItem>>)`](crate::output::GetRecommendationsOutput::item_list): <p>A list of recommendations sorted in descending order by prediction score. There can be a maximum of 500 items in the list.</p>
/// - [`recommendation_id(Option<String>)`](crate::output::GetRecommendationsOutput::recommendation_id): <p>The ID of the recommendation.</p>
/// - On failure, responds with [`SdkError<GetRecommendationsError>`](crate::error::GetRecommendationsError)
pub fn get_recommendations(&self) -> fluent_builders::GetRecommendations<C, M, R> {
fluent_builders::GetRecommendations::new(self.handle.clone())
}
}
pub mod fluent_builders {
//!
//! Utilities to ergonomically construct a request to the service.
//!
//! Fluent builders are created through the [`Client`](crate::client::Client) by calling
//! one if its operation methods. After parameters are set using the builder methods,
//! the `send` method can be called to initiate the request.
//!
/// Fluent builder constructing a request to `GetPersonalizedRanking`.
///
/// <p>Re-ranks a list of recommended items for the given user. The first item in the list is deemed the most likely item to be of interest to the user.</p> <note>
/// <p>The solution backing the campaign must have been created using a recipe of type PERSONALIZED_RANKING.</p>
/// </note>
#[derive(std::clone::Clone, std::fmt::Debug)]
pub struct GetPersonalizedRanking<
C = aws_smithy_client::erase::DynConnector,
M = crate::middleware::DefaultMiddleware,
R = aws_smithy_client::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C, M, R>>,
inner: crate::input::get_personalized_ranking_input::Builder,
}
impl<C, M, R> GetPersonalizedRanking<C, M, R>
where
C: aws_smithy_client::bounds::SmithyConnector,
M: aws_smithy_client::bounds::SmithyMiddleware<C>,
R: aws_smithy_client::retry::NewRequestPolicy,
{
/// Creates a new `GetPersonalizedRanking`.
pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
Self {
handle,
inner: Default::default(),
}
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> std::result::Result<
crate::output::GetPersonalizedRankingOutput,
aws_smithy_http::result::SdkError<crate::error::GetPersonalizedRankingError>,
>
where
R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
crate::input::GetPersonalizedRankingInputOperationOutputAlias,
crate::output::GetPersonalizedRankingOutput,
crate::error::GetPersonalizedRankingError,
crate::input::GetPersonalizedRankingInputOperationRetryAlias,
>,
{
let op = self
.inner
.build()
.map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
.make_operation(&self.handle.conf)
.await
.map_err(|err| {
aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
})?;
self.handle.client.call(op).await
}
/// <p>The Amazon Resource Name (ARN) of the campaign to use for generating the personalized ranking.</p>
pub fn campaign_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.campaign_arn(input.into());
self
}
/// <p>The Amazon Resource Name (ARN) of the campaign to use for generating the personalized ranking.</p>
pub fn set_campaign_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_campaign_arn(input);
self
}
/// Appends an item to `inputList`.
///
/// To override the contents of this collection use [`set_input_list`](Self::set_input_list).
///
/// <p>A list of items (by <code>itemId</code>) to rank. If an item was not included in the training dataset, the item is appended to the end of the reranked list. The maximum is 500.</p>
pub fn input_list(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.input_list(input.into());
self
}
/// <p>A list of items (by <code>itemId</code>) to rank. If an item was not included in the training dataset, the item is appended to the end of the reranked list. The maximum is 500.</p>
pub fn set_input_list(
mut self,
input: std::option::Option<std::vec::Vec<std::string::String>>,
) -> Self {
self.inner = self.inner.set_input_list(input);
self
}
/// <p>The user for which you want the campaign to provide a personalized ranking.</p>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.user_id(input.into());
self
}
/// <p>The user for which you want the campaign to provide a personalized ranking.</p>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_user_id(input);
self
}
/// Adds a key-value pair to `context`.
///
/// To override the contents of this collection use [`set_context`](Self::set_context).
///
/// <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
pub fn context(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
self.inner = self.inner.context(k.into(), v.into());
self
}
/// <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
pub fn set_context(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.inner = self.inner.set_context(input);
self
}
/// <p>The Amazon Resource Name (ARN) of a filter you created to include items or exclude items from recommendations for a given user. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn filter_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.filter_arn(input.into());
self
}
/// <p>The Amazon Resource Name (ARN) of a filter you created to include items or exclude items from recommendations for a given user. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn set_filter_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_filter_arn(input);
self
}
/// Adds a key-value pair to `filterValues`.
///
/// To override the contents of this collection use [`set_filter_values`](Self::set_filter_values).
///
/// <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p>
/// <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn filter_values(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
self.inner = self.inner.filter_values(k.into(), v.into());
self
}
/// <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p>
/// <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn set_filter_values(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.inner = self.inner.set_filter_values(input);
self
}
}
/// Fluent builder constructing a request to `GetRecommendations`.
///
/// <p>Returns a list of recommended items. For campaigns, the campaign's Amazon Resource Name (ARN) is required and the required user and item input depends on the recipe type used to create the solution backing the campaign as follows:</p>
/// <ul>
/// <li> <p>USER_PERSONALIZATION - <code>userId</code> required, <code>itemId</code> not used</p> </li>
/// <li> <p>RELATED_ITEMS - <code>itemId</code> required, <code>userId</code> not used</p> </li>
/// </ul> <note>
/// <p>Campaigns that are backed by a solution created using a recipe of type PERSONALIZED_RANKING use the API.</p>
/// </note>
/// <p> For recommenders, the recommender's ARN is required and the required item and user input depends on the use case (domain-based recipe) backing the recommender. For information on use case requirements see <a href="https://docs.aws.amazon.com/personalize/latest/dg/domain-use-cases.html">Choosing recommender use cases</a>. </p>
#[derive(std::clone::Clone, std::fmt::Debug)]
pub struct GetRecommendations<
C = aws_smithy_client::erase::DynConnector,
M = crate::middleware::DefaultMiddleware,
R = aws_smithy_client::retry::Standard,
> {
handle: std::sync::Arc<super::Handle<C, M, R>>,
inner: crate::input::get_recommendations_input::Builder,
}
impl<C, M, R> GetRecommendations<C, M, R>
where
C: aws_smithy_client::bounds::SmithyConnector,
M: aws_smithy_client::bounds::SmithyMiddleware<C>,
R: aws_smithy_client::retry::NewRequestPolicy,
{
/// Creates a new `GetRecommendations`.
pub(crate) fn new(handle: std::sync::Arc<super::Handle<C, M, R>>) -> Self {
Self {
handle,
inner: Default::default(),
}
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> std::result::Result<
crate::output::GetRecommendationsOutput,
aws_smithy_http::result::SdkError<crate::error::GetRecommendationsError>,
>
where
R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
crate::input::GetRecommendationsInputOperationOutputAlias,
crate::output::GetRecommendationsOutput,
crate::error::GetRecommendationsError,
crate::input::GetRecommendationsInputOperationRetryAlias,
>,
{
let op = self
.inner
.build()
.map_err(|err| aws_smithy_http::result::SdkError::ConstructionFailure(err.into()))?
.make_operation(&self.handle.conf)
.await
.map_err(|err| {
aws_smithy_http::result::SdkError::ConstructionFailure(err.into())
})?;
self.handle.client.call(op).await
}
/// <p>The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.</p>
pub fn campaign_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.campaign_arn(input.into());
self
}
/// <p>The Amazon Resource Name (ARN) of the campaign to use for getting recommendations.</p>
pub fn set_campaign_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_campaign_arn(input);
self
}
/// <p>The item ID to provide recommendations for.</p>
/// <p>Required for <code>RELATED_ITEMS</code> recipe type.</p>
pub fn item_id(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.item_id(input.into());
self
}
/// <p>The item ID to provide recommendations for.</p>
/// <p>Required for <code>RELATED_ITEMS</code> recipe type.</p>
pub fn set_item_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_item_id(input);
self
}
/// <p>The user ID to provide recommendations for.</p>
/// <p>Required for <code>USER_PERSONALIZATION</code> recipe type.</p>
pub fn user_id(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.user_id(input.into());
self
}
/// <p>The user ID to provide recommendations for.</p>
/// <p>Required for <code>USER_PERSONALIZATION</code> recipe type.</p>
pub fn set_user_id(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_user_id(input);
self
}
/// <p>The number of results to return. The default is 25. The maximum is 500.</p>
pub fn num_results(mut self, input: i32) -> Self {
self.inner = self.inner.num_results(input);
self
}
/// <p>The number of results to return. The default is 25. The maximum is 500.</p>
pub fn set_num_results(mut self, input: std::option::Option<i32>) -> Self {
self.inner = self.inner.set_num_results(input);
self
}
/// Adds a key-value pair to `context`.
///
/// To override the contents of this collection use [`set_context`](Self::set_context).
///
/// <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
pub fn context(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
self.inner = self.inner.context(k.into(), v.into());
self
}
/// <p>The contextual metadata to use when getting recommendations. Contextual metadata includes any interaction information that might be relevant when getting a user's recommendations, such as the user's current location or device type.</p>
pub fn set_context(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.inner = self.inner.set_context(input);
self
}
/// <p>The ARN of the filter to apply to the returned recommendations. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
/// <p>When using this parameter, be sure the filter resource is <code>ACTIVE</code>.</p>
pub fn filter_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.filter_arn(input.into());
self
}
/// <p>The ARN of the filter to apply to the returned recommendations. For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
/// <p>When using this parameter, be sure the filter resource is <code>ACTIVE</code>.</p>
pub fn set_filter_arn(mut self, input: std::option::Option<std::string::String>) -> Self {
self.inner = self.inner.set_filter_arn(input);
self
}
/// Adds a key-value pair to `filterValues`.
///
/// To override the contents of this collection use [`set_filter_values`](Self::set_filter_values).
///
/// <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p>
/// <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn filter_values(
mut self,
k: impl Into<std::string::String>,
v: impl Into<std::string::String>,
) -> Self {
self.inner = self.inner.filter_values(k.into(), v.into());
self
}
/// <p>The values to use when filtering recommendations. For each placeholder parameter in your filter expression, provide the parameter name (in matching case) as a key and the filter value(s) as the corresponding value. Separate multiple values for one parameter with a comma. </p>
/// <p>For filter expressions that use an <code>INCLUDE</code> element to include items, you must provide values for all parameters that are defined in the expression. For filters with expressions that use an <code>EXCLUDE</code> element to exclude items, you can omit the <code>filter-values</code>.In this case, Amazon Personalize doesn't use that portion of the expression to filter recommendations.</p>
/// <p>For more information, see <a href="https://docs.aws.amazon.com/personalize/latest/dg/filter.html">Filtering Recommendations</a>.</p>
pub fn set_filter_values(
mut self,
input: std::option::Option<
std::collections::HashMap<std::string::String, std::string::String>,
>,
) -> Self {
self.inner = self.inner.set_filter_values(input);
self
}
/// <p>The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case.</p>
pub fn recommender_arn(mut self, input: impl Into<std::string::String>) -> Self {
self.inner = self.inner.recommender_arn(input.into());
self
}
/// <p>The Amazon Resource Name (ARN) of the recommender to use to get recommendations. Provide a recommender ARN if you created a Domain dataset group with a recommender for a domain use case.</p>
pub fn set_recommender_arn(
mut self,
input: std::option::Option<std::string::String>,
) -> Self {
self.inner = self.inner.set_recommender_arn(input);
self
}
}
}
impl<C> Client<C, crate::middleware::DefaultMiddleware, aws_smithy_client::retry::Standard> {
/// Creates a client with the given service config and connector override.
pub fn from_conf_conn(conf: crate::Config, conn: C) -> Self {
let retry_config = conf.retry_config.as_ref().cloned().unwrap_or_default();
let timeout_config = conf.timeout_config.as_ref().cloned().unwrap_or_default();
let sleep_impl = conf.sleep_impl.clone();
let mut builder = aws_smithy_client::Builder::new()
.connector(conn)
.middleware(crate::middleware::DefaultMiddleware::new());
builder.set_retry_config(retry_config.into());
builder.set_timeout_config(timeout_config);
if let Some(sleep_impl) = sleep_impl {
builder.set_sleep_impl(Some(sleep_impl));
}
let client = builder.build();
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
}
impl
Client<
aws_smithy_client::erase::DynConnector,
crate::middleware::DefaultMiddleware,
aws_smithy_client::retry::Standard,
>
{
/// Creates a new client from a shared config.
#[cfg(any(feature = "rustls", feature = "native-tls"))]
pub fn new(config: &aws_types::config::Config) -> Self {
Self::from_conf(config.into())
}
/// Creates a new client from the service [`Config`](crate::Config).
#[cfg(any(feature = "rustls", feature = "native-tls"))]
pub fn from_conf(conf: crate::Config) -> Self {
let retry_config = conf.retry_config.as_ref().cloned().unwrap_or_default();
let timeout_config = conf.timeout_config.as_ref().cloned().unwrap_or_default();
let sleep_impl = conf.sleep_impl.clone();
let mut builder = aws_smithy_client::Builder::dyn_https()
.middleware(crate::middleware::DefaultMiddleware::new());
builder.set_retry_config(retry_config.into());
builder.set_timeout_config(timeout_config);
// the builder maintains a try-state. To avoid suppressing the warning when sleep is unset,
// only set it if we actually have a sleep impl.
if let Some(sleep_impl) = sleep_impl {
builder.set_sleep_impl(Some(sleep_impl));
}
let client = builder.build();
Self {
handle: std::sync::Arc::new(Handle { client, conf }),
}
}
}