google_cloud_recommender_v1/builder.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17/// Request and client builders for [Recommender][crate::client::Recommender].
18pub mod recommender {
19 use crate::Result;
20
21 /// A builder for [Recommender][crate::client::Recommender].
22 ///
23 /// ```
24 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25 /// # use google_cloud_recommender_v1::*;
26 /// # use builder::recommender::ClientBuilder;
27 /// # use client::Recommender;
28 /// let builder : ClientBuilder = Recommender::builder();
29 /// let client = builder
30 /// .with_endpoint("https://recommender.googleapis.com")
31 /// .build().await?;
32 /// # Ok(()) }
33 /// ```
34 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::Recommender;
38 pub struct Factory;
39 impl crate::ClientFactory for Factory {
40 type Client = Recommender;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> crate::ClientBuilderResult<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 /// Common implementation for [crate::client::Recommender] request builders.
52 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
55 request: R,
56 options: crate::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: crate::RequestOptions::default(),
70 }
71 }
72 }
73
74 /// The request builder for [Recommender::list_insights][crate::client::Recommender::list_insights] calls.
75 ///
76 /// # Example
77 /// ```
78 /// # use google_cloud_recommender_v1::builder::recommender::ListInsights;
79 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
80 /// use google_cloud_gax::paginator::ItemPaginator;
81 ///
82 /// let builder = prepare_request_builder();
83 /// let mut items = builder.by_item();
84 /// while let Some(result) = items.next().await {
85 /// let item = result?;
86 /// }
87 /// # Ok(()) }
88 ///
89 /// fn prepare_request_builder() -> ListInsights {
90 /// # panic!();
91 /// // ... details omitted ...
92 /// }
93 /// ```
94 #[derive(Clone, Debug)]
95 pub struct ListInsights(RequestBuilder<crate::model::ListInsightsRequest>);
96
97 impl ListInsights {
98 pub(crate) fn new(
99 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
100 ) -> Self {
101 Self(RequestBuilder::new(stub))
102 }
103
104 /// Sets the full request, replacing any prior values.
105 pub fn with_request<V: Into<crate::model::ListInsightsRequest>>(mut self, v: V) -> Self {
106 self.0.request = v.into();
107 self
108 }
109
110 /// Sets all the options, replacing any prior values.
111 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
112 self.0.options = v.into();
113 self
114 }
115
116 /// Sends the request.
117 pub async fn send(self) -> Result<crate::model::ListInsightsResponse> {
118 (*self.0.stub)
119 .list_insights(self.0.request, self.0.options)
120 .await
121 .map(crate::Response::into_body)
122 }
123
124 /// Streams each page in the collection.
125 pub fn by_page(
126 self,
127 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListInsightsResponse, crate::Error>
128 {
129 use std::clone::Clone;
130 let token = self.0.request.page_token.clone();
131 let execute = move |token: String| {
132 let mut builder = self.clone();
133 builder.0.request = builder.0.request.set_page_token(token);
134 builder.send()
135 };
136 google_cloud_gax::paginator::internal::new_paginator(token, execute)
137 }
138
139 /// Streams each item in the collection.
140 pub fn by_item(
141 self,
142 ) -> impl google_cloud_gax::paginator::ItemPaginator<
143 crate::model::ListInsightsResponse,
144 crate::Error,
145 > {
146 use google_cloud_gax::paginator::Paginator;
147 self.by_page().items()
148 }
149
150 /// Sets the value of [parent][crate::model::ListInsightsRequest::parent].
151 ///
152 /// This is a **required** field for requests.
153 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
154 self.0.request.parent = v.into();
155 self
156 }
157
158 /// Sets the value of [page_size][crate::model::ListInsightsRequest::page_size].
159 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
160 self.0.request.page_size = v.into();
161 self
162 }
163
164 /// Sets the value of [page_token][crate::model::ListInsightsRequest::page_token].
165 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
166 self.0.request.page_token = v.into();
167 self
168 }
169
170 /// Sets the value of [filter][crate::model::ListInsightsRequest::filter].
171 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
172 self.0.request.filter = v.into();
173 self
174 }
175 }
176
177 #[doc(hidden)]
178 impl crate::RequestBuilder for ListInsights {
179 fn request_options(&mut self) -> &mut crate::RequestOptions {
180 &mut self.0.options
181 }
182 }
183
184 /// The request builder for [Recommender::get_insight][crate::client::Recommender::get_insight] calls.
185 ///
186 /// # Example
187 /// ```
188 /// # use google_cloud_recommender_v1::builder::recommender::GetInsight;
189 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
190 ///
191 /// let builder = prepare_request_builder();
192 /// let response = builder.send().await?;
193 /// # Ok(()) }
194 ///
195 /// fn prepare_request_builder() -> GetInsight {
196 /// # panic!();
197 /// // ... details omitted ...
198 /// }
199 /// ```
200 #[derive(Clone, Debug)]
201 pub struct GetInsight(RequestBuilder<crate::model::GetInsightRequest>);
202
203 impl GetInsight {
204 pub(crate) fn new(
205 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
206 ) -> Self {
207 Self(RequestBuilder::new(stub))
208 }
209
210 /// Sets the full request, replacing any prior values.
211 pub fn with_request<V: Into<crate::model::GetInsightRequest>>(mut self, v: V) -> Self {
212 self.0.request = v.into();
213 self
214 }
215
216 /// Sets all the options, replacing any prior values.
217 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
218 self.0.options = v.into();
219 self
220 }
221
222 /// Sends the request.
223 pub async fn send(self) -> Result<crate::model::Insight> {
224 (*self.0.stub)
225 .get_insight(self.0.request, self.0.options)
226 .await
227 .map(crate::Response::into_body)
228 }
229
230 /// Sets the value of [name][crate::model::GetInsightRequest::name].
231 ///
232 /// This is a **required** field for requests.
233 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
234 self.0.request.name = v.into();
235 self
236 }
237 }
238
239 #[doc(hidden)]
240 impl crate::RequestBuilder for GetInsight {
241 fn request_options(&mut self) -> &mut crate::RequestOptions {
242 &mut self.0.options
243 }
244 }
245
246 /// The request builder for [Recommender::mark_insight_accepted][crate::client::Recommender::mark_insight_accepted] calls.
247 ///
248 /// # Example
249 /// ```
250 /// # use google_cloud_recommender_v1::builder::recommender::MarkInsightAccepted;
251 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
252 ///
253 /// let builder = prepare_request_builder();
254 /// let response = builder.send().await?;
255 /// # Ok(()) }
256 ///
257 /// fn prepare_request_builder() -> MarkInsightAccepted {
258 /// # panic!();
259 /// // ... details omitted ...
260 /// }
261 /// ```
262 #[derive(Clone, Debug)]
263 pub struct MarkInsightAccepted(RequestBuilder<crate::model::MarkInsightAcceptedRequest>);
264
265 impl MarkInsightAccepted {
266 pub(crate) fn new(
267 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
268 ) -> Self {
269 Self(RequestBuilder::new(stub))
270 }
271
272 /// Sets the full request, replacing any prior values.
273 pub fn with_request<V: Into<crate::model::MarkInsightAcceptedRequest>>(
274 mut self,
275 v: V,
276 ) -> Self {
277 self.0.request = v.into();
278 self
279 }
280
281 /// Sets all the options, replacing any prior values.
282 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
283 self.0.options = v.into();
284 self
285 }
286
287 /// Sends the request.
288 pub async fn send(self) -> Result<crate::model::Insight> {
289 (*self.0.stub)
290 .mark_insight_accepted(self.0.request, self.0.options)
291 .await
292 .map(crate::Response::into_body)
293 }
294
295 /// Sets the value of [name][crate::model::MarkInsightAcceptedRequest::name].
296 ///
297 /// This is a **required** field for requests.
298 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
299 self.0.request.name = v.into();
300 self
301 }
302
303 /// Sets the value of [state_metadata][crate::model::MarkInsightAcceptedRequest::state_metadata].
304 pub fn set_state_metadata<T, K, V>(mut self, v: T) -> Self
305 where
306 T: std::iter::IntoIterator<Item = (K, V)>,
307 K: std::convert::Into<std::string::String>,
308 V: std::convert::Into<std::string::String>,
309 {
310 self.0.request.state_metadata =
311 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
312 self
313 }
314
315 /// Sets the value of [etag][crate::model::MarkInsightAcceptedRequest::etag].
316 ///
317 /// This is a **required** field for requests.
318 pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
319 self.0.request.etag = v.into();
320 self
321 }
322 }
323
324 #[doc(hidden)]
325 impl crate::RequestBuilder for MarkInsightAccepted {
326 fn request_options(&mut self) -> &mut crate::RequestOptions {
327 &mut self.0.options
328 }
329 }
330
331 /// The request builder for [Recommender::list_recommendations][crate::client::Recommender::list_recommendations] calls.
332 ///
333 /// # Example
334 /// ```
335 /// # use google_cloud_recommender_v1::builder::recommender::ListRecommendations;
336 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
337 /// use google_cloud_gax::paginator::ItemPaginator;
338 ///
339 /// let builder = prepare_request_builder();
340 /// let mut items = builder.by_item();
341 /// while let Some(result) = items.next().await {
342 /// let item = result?;
343 /// }
344 /// # Ok(()) }
345 ///
346 /// fn prepare_request_builder() -> ListRecommendations {
347 /// # panic!();
348 /// // ... details omitted ...
349 /// }
350 /// ```
351 #[derive(Clone, Debug)]
352 pub struct ListRecommendations(RequestBuilder<crate::model::ListRecommendationsRequest>);
353
354 impl ListRecommendations {
355 pub(crate) fn new(
356 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
357 ) -> Self {
358 Self(RequestBuilder::new(stub))
359 }
360
361 /// Sets the full request, replacing any prior values.
362 pub fn with_request<V: Into<crate::model::ListRecommendationsRequest>>(
363 mut self,
364 v: V,
365 ) -> Self {
366 self.0.request = v.into();
367 self
368 }
369
370 /// Sets all the options, replacing any prior values.
371 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
372 self.0.options = v.into();
373 self
374 }
375
376 /// Sends the request.
377 pub async fn send(self) -> Result<crate::model::ListRecommendationsResponse> {
378 (*self.0.stub)
379 .list_recommendations(self.0.request, self.0.options)
380 .await
381 .map(crate::Response::into_body)
382 }
383
384 /// Streams each page in the collection.
385 pub fn by_page(
386 self,
387 ) -> impl google_cloud_gax::paginator::Paginator<
388 crate::model::ListRecommendationsResponse,
389 crate::Error,
390 > {
391 use std::clone::Clone;
392 let token = self.0.request.page_token.clone();
393 let execute = move |token: String| {
394 let mut builder = self.clone();
395 builder.0.request = builder.0.request.set_page_token(token);
396 builder.send()
397 };
398 google_cloud_gax::paginator::internal::new_paginator(token, execute)
399 }
400
401 /// Streams each item in the collection.
402 pub fn by_item(
403 self,
404 ) -> impl google_cloud_gax::paginator::ItemPaginator<
405 crate::model::ListRecommendationsResponse,
406 crate::Error,
407 > {
408 use google_cloud_gax::paginator::Paginator;
409 self.by_page().items()
410 }
411
412 /// Sets the value of [parent][crate::model::ListRecommendationsRequest::parent].
413 ///
414 /// This is a **required** field for requests.
415 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
416 self.0.request.parent = v.into();
417 self
418 }
419
420 /// Sets the value of [page_size][crate::model::ListRecommendationsRequest::page_size].
421 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
422 self.0.request.page_size = v.into();
423 self
424 }
425
426 /// Sets the value of [page_token][crate::model::ListRecommendationsRequest::page_token].
427 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
428 self.0.request.page_token = v.into();
429 self
430 }
431
432 /// Sets the value of [filter][crate::model::ListRecommendationsRequest::filter].
433 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
434 self.0.request.filter = v.into();
435 self
436 }
437 }
438
439 #[doc(hidden)]
440 impl crate::RequestBuilder for ListRecommendations {
441 fn request_options(&mut self) -> &mut crate::RequestOptions {
442 &mut self.0.options
443 }
444 }
445
446 /// The request builder for [Recommender::get_recommendation][crate::client::Recommender::get_recommendation] calls.
447 ///
448 /// # Example
449 /// ```
450 /// # use google_cloud_recommender_v1::builder::recommender::GetRecommendation;
451 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
452 ///
453 /// let builder = prepare_request_builder();
454 /// let response = builder.send().await?;
455 /// # Ok(()) }
456 ///
457 /// fn prepare_request_builder() -> GetRecommendation {
458 /// # panic!();
459 /// // ... details omitted ...
460 /// }
461 /// ```
462 #[derive(Clone, Debug)]
463 pub struct GetRecommendation(RequestBuilder<crate::model::GetRecommendationRequest>);
464
465 impl GetRecommendation {
466 pub(crate) fn new(
467 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
468 ) -> Self {
469 Self(RequestBuilder::new(stub))
470 }
471
472 /// Sets the full request, replacing any prior values.
473 pub fn with_request<V: Into<crate::model::GetRecommendationRequest>>(
474 mut self,
475 v: V,
476 ) -> Self {
477 self.0.request = v.into();
478 self
479 }
480
481 /// Sets all the options, replacing any prior values.
482 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
483 self.0.options = v.into();
484 self
485 }
486
487 /// Sends the request.
488 pub async fn send(self) -> Result<crate::model::Recommendation> {
489 (*self.0.stub)
490 .get_recommendation(self.0.request, self.0.options)
491 .await
492 .map(crate::Response::into_body)
493 }
494
495 /// Sets the value of [name][crate::model::GetRecommendationRequest::name].
496 ///
497 /// This is a **required** field for requests.
498 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
499 self.0.request.name = v.into();
500 self
501 }
502 }
503
504 #[doc(hidden)]
505 impl crate::RequestBuilder for GetRecommendation {
506 fn request_options(&mut self) -> &mut crate::RequestOptions {
507 &mut self.0.options
508 }
509 }
510
511 /// The request builder for [Recommender::mark_recommendation_dismissed][crate::client::Recommender::mark_recommendation_dismissed] calls.
512 ///
513 /// # Example
514 /// ```
515 /// # use google_cloud_recommender_v1::builder::recommender::MarkRecommendationDismissed;
516 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
517 ///
518 /// let builder = prepare_request_builder();
519 /// let response = builder.send().await?;
520 /// # Ok(()) }
521 ///
522 /// fn prepare_request_builder() -> MarkRecommendationDismissed {
523 /// # panic!();
524 /// // ... details omitted ...
525 /// }
526 /// ```
527 #[derive(Clone, Debug)]
528 pub struct MarkRecommendationDismissed(
529 RequestBuilder<crate::model::MarkRecommendationDismissedRequest>,
530 );
531
532 impl MarkRecommendationDismissed {
533 pub(crate) fn new(
534 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
535 ) -> Self {
536 Self(RequestBuilder::new(stub))
537 }
538
539 /// Sets the full request, replacing any prior values.
540 pub fn with_request<V: Into<crate::model::MarkRecommendationDismissedRequest>>(
541 mut self,
542 v: V,
543 ) -> Self {
544 self.0.request = v.into();
545 self
546 }
547
548 /// Sets all the options, replacing any prior values.
549 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
550 self.0.options = v.into();
551 self
552 }
553
554 /// Sends the request.
555 pub async fn send(self) -> Result<crate::model::Recommendation> {
556 (*self.0.stub)
557 .mark_recommendation_dismissed(self.0.request, self.0.options)
558 .await
559 .map(crate::Response::into_body)
560 }
561
562 /// Sets the value of [name][crate::model::MarkRecommendationDismissedRequest::name].
563 ///
564 /// This is a **required** field for requests.
565 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
566 self.0.request.name = v.into();
567 self
568 }
569
570 /// Sets the value of [etag][crate::model::MarkRecommendationDismissedRequest::etag].
571 pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
572 self.0.request.etag = v.into();
573 self
574 }
575 }
576
577 #[doc(hidden)]
578 impl crate::RequestBuilder for MarkRecommendationDismissed {
579 fn request_options(&mut self) -> &mut crate::RequestOptions {
580 &mut self.0.options
581 }
582 }
583
584 /// The request builder for [Recommender::mark_recommendation_claimed][crate::client::Recommender::mark_recommendation_claimed] calls.
585 ///
586 /// # Example
587 /// ```
588 /// # use google_cloud_recommender_v1::builder::recommender::MarkRecommendationClaimed;
589 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
590 ///
591 /// let builder = prepare_request_builder();
592 /// let response = builder.send().await?;
593 /// # Ok(()) }
594 ///
595 /// fn prepare_request_builder() -> MarkRecommendationClaimed {
596 /// # panic!();
597 /// // ... details omitted ...
598 /// }
599 /// ```
600 #[derive(Clone, Debug)]
601 pub struct MarkRecommendationClaimed(
602 RequestBuilder<crate::model::MarkRecommendationClaimedRequest>,
603 );
604
605 impl MarkRecommendationClaimed {
606 pub(crate) fn new(
607 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
608 ) -> Self {
609 Self(RequestBuilder::new(stub))
610 }
611
612 /// Sets the full request, replacing any prior values.
613 pub fn with_request<V: Into<crate::model::MarkRecommendationClaimedRequest>>(
614 mut self,
615 v: V,
616 ) -> Self {
617 self.0.request = v.into();
618 self
619 }
620
621 /// Sets all the options, replacing any prior values.
622 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
623 self.0.options = v.into();
624 self
625 }
626
627 /// Sends the request.
628 pub async fn send(self) -> Result<crate::model::Recommendation> {
629 (*self.0.stub)
630 .mark_recommendation_claimed(self.0.request, self.0.options)
631 .await
632 .map(crate::Response::into_body)
633 }
634
635 /// Sets the value of [name][crate::model::MarkRecommendationClaimedRequest::name].
636 ///
637 /// This is a **required** field for requests.
638 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
639 self.0.request.name = v.into();
640 self
641 }
642
643 /// Sets the value of [state_metadata][crate::model::MarkRecommendationClaimedRequest::state_metadata].
644 pub fn set_state_metadata<T, K, V>(mut self, v: T) -> Self
645 where
646 T: std::iter::IntoIterator<Item = (K, V)>,
647 K: std::convert::Into<std::string::String>,
648 V: std::convert::Into<std::string::String>,
649 {
650 self.0.request.state_metadata =
651 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
652 self
653 }
654
655 /// Sets the value of [etag][crate::model::MarkRecommendationClaimedRequest::etag].
656 ///
657 /// This is a **required** field for requests.
658 pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
659 self.0.request.etag = v.into();
660 self
661 }
662 }
663
664 #[doc(hidden)]
665 impl crate::RequestBuilder for MarkRecommendationClaimed {
666 fn request_options(&mut self) -> &mut crate::RequestOptions {
667 &mut self.0.options
668 }
669 }
670
671 /// The request builder for [Recommender::mark_recommendation_succeeded][crate::client::Recommender::mark_recommendation_succeeded] calls.
672 ///
673 /// # Example
674 /// ```
675 /// # use google_cloud_recommender_v1::builder::recommender::MarkRecommendationSucceeded;
676 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
677 ///
678 /// let builder = prepare_request_builder();
679 /// let response = builder.send().await?;
680 /// # Ok(()) }
681 ///
682 /// fn prepare_request_builder() -> MarkRecommendationSucceeded {
683 /// # panic!();
684 /// // ... details omitted ...
685 /// }
686 /// ```
687 #[derive(Clone, Debug)]
688 pub struct MarkRecommendationSucceeded(
689 RequestBuilder<crate::model::MarkRecommendationSucceededRequest>,
690 );
691
692 impl MarkRecommendationSucceeded {
693 pub(crate) fn new(
694 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
695 ) -> Self {
696 Self(RequestBuilder::new(stub))
697 }
698
699 /// Sets the full request, replacing any prior values.
700 pub fn with_request<V: Into<crate::model::MarkRecommendationSucceededRequest>>(
701 mut self,
702 v: V,
703 ) -> Self {
704 self.0.request = v.into();
705 self
706 }
707
708 /// Sets all the options, replacing any prior values.
709 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
710 self.0.options = v.into();
711 self
712 }
713
714 /// Sends the request.
715 pub async fn send(self) -> Result<crate::model::Recommendation> {
716 (*self.0.stub)
717 .mark_recommendation_succeeded(self.0.request, self.0.options)
718 .await
719 .map(crate::Response::into_body)
720 }
721
722 /// Sets the value of [name][crate::model::MarkRecommendationSucceededRequest::name].
723 ///
724 /// This is a **required** field for requests.
725 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
726 self.0.request.name = v.into();
727 self
728 }
729
730 /// Sets the value of [state_metadata][crate::model::MarkRecommendationSucceededRequest::state_metadata].
731 pub fn set_state_metadata<T, K, V>(mut self, v: T) -> Self
732 where
733 T: std::iter::IntoIterator<Item = (K, V)>,
734 K: std::convert::Into<std::string::String>,
735 V: std::convert::Into<std::string::String>,
736 {
737 self.0.request.state_metadata =
738 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
739 self
740 }
741
742 /// Sets the value of [etag][crate::model::MarkRecommendationSucceededRequest::etag].
743 ///
744 /// This is a **required** field for requests.
745 pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
746 self.0.request.etag = v.into();
747 self
748 }
749 }
750
751 #[doc(hidden)]
752 impl crate::RequestBuilder for MarkRecommendationSucceeded {
753 fn request_options(&mut self) -> &mut crate::RequestOptions {
754 &mut self.0.options
755 }
756 }
757
758 /// The request builder for [Recommender::mark_recommendation_failed][crate::client::Recommender::mark_recommendation_failed] calls.
759 ///
760 /// # Example
761 /// ```
762 /// # use google_cloud_recommender_v1::builder::recommender::MarkRecommendationFailed;
763 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
764 ///
765 /// let builder = prepare_request_builder();
766 /// let response = builder.send().await?;
767 /// # Ok(()) }
768 ///
769 /// fn prepare_request_builder() -> MarkRecommendationFailed {
770 /// # panic!();
771 /// // ... details omitted ...
772 /// }
773 /// ```
774 #[derive(Clone, Debug)]
775 pub struct MarkRecommendationFailed(
776 RequestBuilder<crate::model::MarkRecommendationFailedRequest>,
777 );
778
779 impl MarkRecommendationFailed {
780 pub(crate) fn new(
781 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
782 ) -> Self {
783 Self(RequestBuilder::new(stub))
784 }
785
786 /// Sets the full request, replacing any prior values.
787 pub fn with_request<V: Into<crate::model::MarkRecommendationFailedRequest>>(
788 mut self,
789 v: V,
790 ) -> Self {
791 self.0.request = v.into();
792 self
793 }
794
795 /// Sets all the options, replacing any prior values.
796 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
797 self.0.options = v.into();
798 self
799 }
800
801 /// Sends the request.
802 pub async fn send(self) -> Result<crate::model::Recommendation> {
803 (*self.0.stub)
804 .mark_recommendation_failed(self.0.request, self.0.options)
805 .await
806 .map(crate::Response::into_body)
807 }
808
809 /// Sets the value of [name][crate::model::MarkRecommendationFailedRequest::name].
810 ///
811 /// This is a **required** field for requests.
812 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
813 self.0.request.name = v.into();
814 self
815 }
816
817 /// Sets the value of [state_metadata][crate::model::MarkRecommendationFailedRequest::state_metadata].
818 pub fn set_state_metadata<T, K, V>(mut self, v: T) -> Self
819 where
820 T: std::iter::IntoIterator<Item = (K, V)>,
821 K: std::convert::Into<std::string::String>,
822 V: std::convert::Into<std::string::String>,
823 {
824 self.0.request.state_metadata =
825 v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
826 self
827 }
828
829 /// Sets the value of [etag][crate::model::MarkRecommendationFailedRequest::etag].
830 ///
831 /// This is a **required** field for requests.
832 pub fn set_etag<T: Into<std::string::String>>(mut self, v: T) -> Self {
833 self.0.request.etag = v.into();
834 self
835 }
836 }
837
838 #[doc(hidden)]
839 impl crate::RequestBuilder for MarkRecommendationFailed {
840 fn request_options(&mut self) -> &mut crate::RequestOptions {
841 &mut self.0.options
842 }
843 }
844
845 /// The request builder for [Recommender::get_recommender_config][crate::client::Recommender::get_recommender_config] calls.
846 ///
847 /// # Example
848 /// ```
849 /// # use google_cloud_recommender_v1::builder::recommender::GetRecommenderConfig;
850 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
851 ///
852 /// let builder = prepare_request_builder();
853 /// let response = builder.send().await?;
854 /// # Ok(()) }
855 ///
856 /// fn prepare_request_builder() -> GetRecommenderConfig {
857 /// # panic!();
858 /// // ... details omitted ...
859 /// }
860 /// ```
861 #[derive(Clone, Debug)]
862 pub struct GetRecommenderConfig(RequestBuilder<crate::model::GetRecommenderConfigRequest>);
863
864 impl GetRecommenderConfig {
865 pub(crate) fn new(
866 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
867 ) -> Self {
868 Self(RequestBuilder::new(stub))
869 }
870
871 /// Sets the full request, replacing any prior values.
872 pub fn with_request<V: Into<crate::model::GetRecommenderConfigRequest>>(
873 mut self,
874 v: V,
875 ) -> Self {
876 self.0.request = v.into();
877 self
878 }
879
880 /// Sets all the options, replacing any prior values.
881 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
882 self.0.options = v.into();
883 self
884 }
885
886 /// Sends the request.
887 pub async fn send(self) -> Result<crate::model::RecommenderConfig> {
888 (*self.0.stub)
889 .get_recommender_config(self.0.request, self.0.options)
890 .await
891 .map(crate::Response::into_body)
892 }
893
894 /// Sets the value of [name][crate::model::GetRecommenderConfigRequest::name].
895 ///
896 /// This is a **required** field for requests.
897 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
898 self.0.request.name = v.into();
899 self
900 }
901 }
902
903 #[doc(hidden)]
904 impl crate::RequestBuilder for GetRecommenderConfig {
905 fn request_options(&mut self) -> &mut crate::RequestOptions {
906 &mut self.0.options
907 }
908 }
909
910 /// The request builder for [Recommender::update_recommender_config][crate::client::Recommender::update_recommender_config] calls.
911 ///
912 /// # Example
913 /// ```
914 /// # use google_cloud_recommender_v1::builder::recommender::UpdateRecommenderConfig;
915 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
916 ///
917 /// let builder = prepare_request_builder();
918 /// let response = builder.send().await?;
919 /// # Ok(()) }
920 ///
921 /// fn prepare_request_builder() -> UpdateRecommenderConfig {
922 /// # panic!();
923 /// // ... details omitted ...
924 /// }
925 /// ```
926 #[derive(Clone, Debug)]
927 pub struct UpdateRecommenderConfig(
928 RequestBuilder<crate::model::UpdateRecommenderConfigRequest>,
929 );
930
931 impl UpdateRecommenderConfig {
932 pub(crate) fn new(
933 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
934 ) -> Self {
935 Self(RequestBuilder::new(stub))
936 }
937
938 /// Sets the full request, replacing any prior values.
939 pub fn with_request<V: Into<crate::model::UpdateRecommenderConfigRequest>>(
940 mut self,
941 v: V,
942 ) -> Self {
943 self.0.request = v.into();
944 self
945 }
946
947 /// Sets all the options, replacing any prior values.
948 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
949 self.0.options = v.into();
950 self
951 }
952
953 /// Sends the request.
954 pub async fn send(self) -> Result<crate::model::RecommenderConfig> {
955 (*self.0.stub)
956 .update_recommender_config(self.0.request, self.0.options)
957 .await
958 .map(crate::Response::into_body)
959 }
960
961 /// Sets the value of [recommender_config][crate::model::UpdateRecommenderConfigRequest::recommender_config].
962 ///
963 /// This is a **required** field for requests.
964 pub fn set_recommender_config<T>(mut self, v: T) -> Self
965 where
966 T: std::convert::Into<crate::model::RecommenderConfig>,
967 {
968 self.0.request.recommender_config = std::option::Option::Some(v.into());
969 self
970 }
971
972 /// Sets or clears the value of [recommender_config][crate::model::UpdateRecommenderConfigRequest::recommender_config].
973 ///
974 /// This is a **required** field for requests.
975 pub fn set_or_clear_recommender_config<T>(mut self, v: std::option::Option<T>) -> Self
976 where
977 T: std::convert::Into<crate::model::RecommenderConfig>,
978 {
979 self.0.request.recommender_config = v.map(|x| x.into());
980 self
981 }
982
983 /// Sets the value of [update_mask][crate::model::UpdateRecommenderConfigRequest::update_mask].
984 pub fn set_update_mask<T>(mut self, v: T) -> Self
985 where
986 T: std::convert::Into<wkt::FieldMask>,
987 {
988 self.0.request.update_mask = std::option::Option::Some(v.into());
989 self
990 }
991
992 /// Sets or clears the value of [update_mask][crate::model::UpdateRecommenderConfigRequest::update_mask].
993 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
994 where
995 T: std::convert::Into<wkt::FieldMask>,
996 {
997 self.0.request.update_mask = v.map(|x| x.into());
998 self
999 }
1000
1001 /// Sets the value of [validate_only][crate::model::UpdateRecommenderConfigRequest::validate_only].
1002 pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
1003 self.0.request.validate_only = v.into();
1004 self
1005 }
1006 }
1007
1008 #[doc(hidden)]
1009 impl crate::RequestBuilder for UpdateRecommenderConfig {
1010 fn request_options(&mut self) -> &mut crate::RequestOptions {
1011 &mut self.0.options
1012 }
1013 }
1014
1015 /// The request builder for [Recommender::get_insight_type_config][crate::client::Recommender::get_insight_type_config] calls.
1016 ///
1017 /// # Example
1018 /// ```
1019 /// # use google_cloud_recommender_v1::builder::recommender::GetInsightTypeConfig;
1020 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
1021 ///
1022 /// let builder = prepare_request_builder();
1023 /// let response = builder.send().await?;
1024 /// # Ok(()) }
1025 ///
1026 /// fn prepare_request_builder() -> GetInsightTypeConfig {
1027 /// # panic!();
1028 /// // ... details omitted ...
1029 /// }
1030 /// ```
1031 #[derive(Clone, Debug)]
1032 pub struct GetInsightTypeConfig(RequestBuilder<crate::model::GetInsightTypeConfigRequest>);
1033
1034 impl GetInsightTypeConfig {
1035 pub(crate) fn new(
1036 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
1037 ) -> Self {
1038 Self(RequestBuilder::new(stub))
1039 }
1040
1041 /// Sets the full request, replacing any prior values.
1042 pub fn with_request<V: Into<crate::model::GetInsightTypeConfigRequest>>(
1043 mut self,
1044 v: V,
1045 ) -> Self {
1046 self.0.request = v.into();
1047 self
1048 }
1049
1050 /// Sets all the options, replacing any prior values.
1051 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1052 self.0.options = v.into();
1053 self
1054 }
1055
1056 /// Sends the request.
1057 pub async fn send(self) -> Result<crate::model::InsightTypeConfig> {
1058 (*self.0.stub)
1059 .get_insight_type_config(self.0.request, self.0.options)
1060 .await
1061 .map(crate::Response::into_body)
1062 }
1063
1064 /// Sets the value of [name][crate::model::GetInsightTypeConfigRequest::name].
1065 ///
1066 /// This is a **required** field for requests.
1067 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1068 self.0.request.name = v.into();
1069 self
1070 }
1071 }
1072
1073 #[doc(hidden)]
1074 impl crate::RequestBuilder for GetInsightTypeConfig {
1075 fn request_options(&mut self) -> &mut crate::RequestOptions {
1076 &mut self.0.options
1077 }
1078 }
1079
1080 /// The request builder for [Recommender::update_insight_type_config][crate::client::Recommender::update_insight_type_config] calls.
1081 ///
1082 /// # Example
1083 /// ```
1084 /// # use google_cloud_recommender_v1::builder::recommender::UpdateInsightTypeConfig;
1085 /// # async fn sample() -> google_cloud_recommender_v1::Result<()> {
1086 ///
1087 /// let builder = prepare_request_builder();
1088 /// let response = builder.send().await?;
1089 /// # Ok(()) }
1090 ///
1091 /// fn prepare_request_builder() -> UpdateInsightTypeConfig {
1092 /// # panic!();
1093 /// // ... details omitted ...
1094 /// }
1095 /// ```
1096 #[derive(Clone, Debug)]
1097 pub struct UpdateInsightTypeConfig(
1098 RequestBuilder<crate::model::UpdateInsightTypeConfigRequest>,
1099 );
1100
1101 impl UpdateInsightTypeConfig {
1102 pub(crate) fn new(
1103 stub: std::sync::Arc<dyn super::super::stub::dynamic::Recommender>,
1104 ) -> Self {
1105 Self(RequestBuilder::new(stub))
1106 }
1107
1108 /// Sets the full request, replacing any prior values.
1109 pub fn with_request<V: Into<crate::model::UpdateInsightTypeConfigRequest>>(
1110 mut self,
1111 v: V,
1112 ) -> Self {
1113 self.0.request = v.into();
1114 self
1115 }
1116
1117 /// Sets all the options, replacing any prior values.
1118 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1119 self.0.options = v.into();
1120 self
1121 }
1122
1123 /// Sends the request.
1124 pub async fn send(self) -> Result<crate::model::InsightTypeConfig> {
1125 (*self.0.stub)
1126 .update_insight_type_config(self.0.request, self.0.options)
1127 .await
1128 .map(crate::Response::into_body)
1129 }
1130
1131 /// Sets the value of [insight_type_config][crate::model::UpdateInsightTypeConfigRequest::insight_type_config].
1132 ///
1133 /// This is a **required** field for requests.
1134 pub fn set_insight_type_config<T>(mut self, v: T) -> Self
1135 where
1136 T: std::convert::Into<crate::model::InsightTypeConfig>,
1137 {
1138 self.0.request.insight_type_config = std::option::Option::Some(v.into());
1139 self
1140 }
1141
1142 /// Sets or clears the value of [insight_type_config][crate::model::UpdateInsightTypeConfigRequest::insight_type_config].
1143 ///
1144 /// This is a **required** field for requests.
1145 pub fn set_or_clear_insight_type_config<T>(mut self, v: std::option::Option<T>) -> Self
1146 where
1147 T: std::convert::Into<crate::model::InsightTypeConfig>,
1148 {
1149 self.0.request.insight_type_config = v.map(|x| x.into());
1150 self
1151 }
1152
1153 /// Sets the value of [update_mask][crate::model::UpdateInsightTypeConfigRequest::update_mask].
1154 pub fn set_update_mask<T>(mut self, v: T) -> Self
1155 where
1156 T: std::convert::Into<wkt::FieldMask>,
1157 {
1158 self.0.request.update_mask = std::option::Option::Some(v.into());
1159 self
1160 }
1161
1162 /// Sets or clears the value of [update_mask][crate::model::UpdateInsightTypeConfigRequest::update_mask].
1163 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1164 where
1165 T: std::convert::Into<wkt::FieldMask>,
1166 {
1167 self.0.request.update_mask = v.map(|x| x.into());
1168 self
1169 }
1170
1171 /// Sets the value of [validate_only][crate::model::UpdateInsightTypeConfigRequest::validate_only].
1172 pub fn set_validate_only<T: Into<bool>>(mut self, v: T) -> Self {
1173 self.0.request.validate_only = v.into();
1174 self
1175 }
1176 }
1177
1178 #[doc(hidden)]
1179 impl crate::RequestBuilder for UpdateInsightTypeConfig {
1180 fn request_options(&mut self) -> &mut crate::RequestOptions {
1181 &mut self.0.options
1182 }
1183 }
1184}