google_cloud_tasks_v2/
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
17pub mod cloud_tasks {
18    use crate::Result;
19
20    /// A builder for [CloudTasks][crate::client::CloudTasks].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_tasks_v2::*;
25    /// # use builder::cloud_tasks::ClientBuilder;
26    /// # use client::CloudTasks;
27    /// let builder : ClientBuilder = CloudTasks::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://cloudtasks.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    pub type ClientBuilder =
34        gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36    pub(crate) mod client {
37        use super::super::super::client::CloudTasks;
38        pub struct Factory;
39        impl gax::client_builder::internal::ClientFactory for Factory {
40            type Client = CloudTasks;
41            type Credentials = gaxi::options::Credentials;
42            async fn build(
43                self,
44                config: gaxi::options::ClientConfig,
45            ) -> gax::client_builder::Result<Self::Client> {
46                Self::Client::new(config).await
47            }
48        }
49    }
50
51    /// Common implementation for [crate::client::CloudTasks] 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::CloudTasks>,
55        request: R,
56        options: gax::options::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::CloudTasks>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: gax::options::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [CloudTasks::list_queues][crate::client::CloudTasks::list_queues] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_tasks_v2::builder;
79    /// use builder::cloud_tasks::ListQueues;
80    /// # tokio_test::block_on(async {
81    /// use gax::paginator::ItemPaginator;
82    ///
83    /// let builder = prepare_request_builder();
84    /// let mut items = builder.by_item();
85    /// while let Some(result) = items.next().await {
86    ///   let item = result?;
87    /// }
88    /// # gax::Result::<()>::Ok(()) });
89    ///
90    /// fn prepare_request_builder() -> ListQueues {
91    ///   # panic!();
92    ///   // ... details omitted ...
93    /// }
94    /// ```
95    #[derive(Clone, Debug)]
96    pub struct ListQueues(RequestBuilder<crate::model::ListQueuesRequest>);
97
98    impl ListQueues {
99        pub(crate) fn new(
100            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
101        ) -> Self {
102            Self(RequestBuilder::new(stub))
103        }
104
105        /// Sets the full request, replacing any prior values.
106        pub fn with_request<V: Into<crate::model::ListQueuesRequest>>(mut self, v: V) -> Self {
107            self.0.request = v.into();
108            self
109        }
110
111        /// Sets all the options, replacing any prior values.
112        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
113            self.0.options = v.into();
114            self
115        }
116
117        /// Sends the request.
118        pub async fn send(self) -> Result<crate::model::ListQueuesResponse> {
119            (*self.0.stub)
120                .list_queues(self.0.request, self.0.options)
121                .await
122                .map(gax::response::Response::into_body)
123        }
124
125        /// Streams each page in the collection.
126        pub fn by_page(
127            self,
128        ) -> impl gax::paginator::Paginator<crate::model::ListQueuesResponse, gax::error::Error>
129        {
130            use std::clone::Clone;
131            let token = self.0.request.page_token.clone();
132            let execute = move |token: String| {
133                let mut builder = self.clone();
134                builder.0.request = builder.0.request.set_page_token(token);
135                builder.send()
136            };
137            gax::paginator::internal::new_paginator(token, execute)
138        }
139
140        /// Streams each item in the collection.
141        pub fn by_item(
142            self,
143        ) -> impl gax::paginator::ItemPaginator<crate::model::ListQueuesResponse, gax::error::Error>
144        {
145            use gax::paginator::Paginator;
146            self.by_page().items()
147        }
148
149        /// Sets the value of [parent][crate::model::ListQueuesRequest::parent].
150        ///
151        /// This is a **required** field for requests.
152        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153            self.0.request.parent = v.into();
154            self
155        }
156
157        /// Sets the value of [filter][crate::model::ListQueuesRequest::filter].
158        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
159            self.0.request.filter = v.into();
160            self
161        }
162
163        /// Sets the value of [page_size][crate::model::ListQueuesRequest::page_size].
164        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
165            self.0.request.page_size = v.into();
166            self
167        }
168
169        /// Sets the value of [page_token][crate::model::ListQueuesRequest::page_token].
170        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
171            self.0.request.page_token = v.into();
172            self
173        }
174    }
175
176    #[doc(hidden)]
177    impl gax::options::internal::RequestBuilder for ListQueues {
178        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
179            &mut self.0.options
180        }
181    }
182
183    /// The request builder for [CloudTasks::get_queue][crate::client::CloudTasks::get_queue] calls.
184    ///
185    /// # Example
186    /// ```no_run
187    /// # use google_cloud_tasks_v2::builder;
188    /// use builder::cloud_tasks::GetQueue;
189    /// # tokio_test::block_on(async {
190    ///
191    /// let builder = prepare_request_builder();
192    /// let response = builder.send().await?;
193    /// # gax::Result::<()>::Ok(()) });
194    ///
195    /// fn prepare_request_builder() -> GetQueue {
196    ///   # panic!();
197    ///   // ... details omitted ...
198    /// }
199    /// ```
200    #[derive(Clone, Debug)]
201    pub struct GetQueue(RequestBuilder<crate::model::GetQueueRequest>);
202
203    impl GetQueue {
204        pub(crate) fn new(
205            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
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::GetQueueRequest>>(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<gax::options::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::Queue> {
224            (*self.0.stub)
225                .get_queue(self.0.request, self.0.options)
226                .await
227                .map(gax::response::Response::into_body)
228        }
229
230        /// Sets the value of [name][crate::model::GetQueueRequest::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 gax::options::internal::RequestBuilder for GetQueue {
241        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
242            &mut self.0.options
243        }
244    }
245
246    /// The request builder for [CloudTasks::create_queue][crate::client::CloudTasks::create_queue] calls.
247    ///
248    /// # Example
249    /// ```no_run
250    /// # use google_cloud_tasks_v2::builder;
251    /// use builder::cloud_tasks::CreateQueue;
252    /// # tokio_test::block_on(async {
253    ///
254    /// let builder = prepare_request_builder();
255    /// let response = builder.send().await?;
256    /// # gax::Result::<()>::Ok(()) });
257    ///
258    /// fn prepare_request_builder() -> CreateQueue {
259    ///   # panic!();
260    ///   // ... details omitted ...
261    /// }
262    /// ```
263    #[derive(Clone, Debug)]
264    pub struct CreateQueue(RequestBuilder<crate::model::CreateQueueRequest>);
265
266    impl CreateQueue {
267        pub(crate) fn new(
268            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
269        ) -> Self {
270            Self(RequestBuilder::new(stub))
271        }
272
273        /// Sets the full request, replacing any prior values.
274        pub fn with_request<V: Into<crate::model::CreateQueueRequest>>(mut self, v: V) -> Self {
275            self.0.request = v.into();
276            self
277        }
278
279        /// Sets all the options, replacing any prior values.
280        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
281            self.0.options = v.into();
282            self
283        }
284
285        /// Sends the request.
286        pub async fn send(self) -> Result<crate::model::Queue> {
287            (*self.0.stub)
288                .create_queue(self.0.request, self.0.options)
289                .await
290                .map(gax::response::Response::into_body)
291        }
292
293        /// Sets the value of [parent][crate::model::CreateQueueRequest::parent].
294        ///
295        /// This is a **required** field for requests.
296        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
297            self.0.request.parent = v.into();
298            self
299        }
300
301        /// Sets the value of [queue][crate::model::CreateQueueRequest::queue].
302        ///
303        /// This is a **required** field for requests.
304        pub fn set_queue<T>(mut self, v: T) -> Self
305        where
306            T: std::convert::Into<crate::model::Queue>,
307        {
308            self.0.request.queue = std::option::Option::Some(v.into());
309            self
310        }
311
312        /// Sets or clears the value of [queue][crate::model::CreateQueueRequest::queue].
313        ///
314        /// This is a **required** field for requests.
315        pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
316        where
317            T: std::convert::Into<crate::model::Queue>,
318        {
319            self.0.request.queue = v.map(|x| x.into());
320            self
321        }
322    }
323
324    #[doc(hidden)]
325    impl gax::options::internal::RequestBuilder for CreateQueue {
326        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
327            &mut self.0.options
328        }
329    }
330
331    /// The request builder for [CloudTasks::update_queue][crate::client::CloudTasks::update_queue] calls.
332    ///
333    /// # Example
334    /// ```no_run
335    /// # use google_cloud_tasks_v2::builder;
336    /// use builder::cloud_tasks::UpdateQueue;
337    /// # tokio_test::block_on(async {
338    ///
339    /// let builder = prepare_request_builder();
340    /// let response = builder.send().await?;
341    /// # gax::Result::<()>::Ok(()) });
342    ///
343    /// fn prepare_request_builder() -> UpdateQueue {
344    ///   # panic!();
345    ///   // ... details omitted ...
346    /// }
347    /// ```
348    #[derive(Clone, Debug)]
349    pub struct UpdateQueue(RequestBuilder<crate::model::UpdateQueueRequest>);
350
351    impl UpdateQueue {
352        pub(crate) fn new(
353            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
354        ) -> Self {
355            Self(RequestBuilder::new(stub))
356        }
357
358        /// Sets the full request, replacing any prior values.
359        pub fn with_request<V: Into<crate::model::UpdateQueueRequest>>(mut self, v: V) -> Self {
360            self.0.request = v.into();
361            self
362        }
363
364        /// Sets all the options, replacing any prior values.
365        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
366            self.0.options = v.into();
367            self
368        }
369
370        /// Sends the request.
371        pub async fn send(self) -> Result<crate::model::Queue> {
372            (*self.0.stub)
373                .update_queue(self.0.request, self.0.options)
374                .await
375                .map(gax::response::Response::into_body)
376        }
377
378        /// Sets the value of [queue][crate::model::UpdateQueueRequest::queue].
379        ///
380        /// This is a **required** field for requests.
381        pub fn set_queue<T>(mut self, v: T) -> Self
382        where
383            T: std::convert::Into<crate::model::Queue>,
384        {
385            self.0.request.queue = std::option::Option::Some(v.into());
386            self
387        }
388
389        /// Sets or clears the value of [queue][crate::model::UpdateQueueRequest::queue].
390        ///
391        /// This is a **required** field for requests.
392        pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
393        where
394            T: std::convert::Into<crate::model::Queue>,
395        {
396            self.0.request.queue = v.map(|x| x.into());
397            self
398        }
399
400        /// Sets the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
401        pub fn set_update_mask<T>(mut self, v: T) -> Self
402        where
403            T: std::convert::Into<wkt::FieldMask>,
404        {
405            self.0.request.update_mask = std::option::Option::Some(v.into());
406            self
407        }
408
409        /// Sets or clears the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
410        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
411        where
412            T: std::convert::Into<wkt::FieldMask>,
413        {
414            self.0.request.update_mask = v.map(|x| x.into());
415            self
416        }
417    }
418
419    #[doc(hidden)]
420    impl gax::options::internal::RequestBuilder for UpdateQueue {
421        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
422            &mut self.0.options
423        }
424    }
425
426    /// The request builder for [CloudTasks::delete_queue][crate::client::CloudTasks::delete_queue] calls.
427    ///
428    /// # Example
429    /// ```no_run
430    /// # use google_cloud_tasks_v2::builder;
431    /// use builder::cloud_tasks::DeleteQueue;
432    /// # tokio_test::block_on(async {
433    ///
434    /// let builder = prepare_request_builder();
435    /// let response = builder.send().await?;
436    /// # gax::Result::<()>::Ok(()) });
437    ///
438    /// fn prepare_request_builder() -> DeleteQueue {
439    ///   # panic!();
440    ///   // ... details omitted ...
441    /// }
442    /// ```
443    #[derive(Clone, Debug)]
444    pub struct DeleteQueue(RequestBuilder<crate::model::DeleteQueueRequest>);
445
446    impl DeleteQueue {
447        pub(crate) fn new(
448            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
449        ) -> Self {
450            Self(RequestBuilder::new(stub))
451        }
452
453        /// Sets the full request, replacing any prior values.
454        pub fn with_request<V: Into<crate::model::DeleteQueueRequest>>(mut self, v: V) -> Self {
455            self.0.request = v.into();
456            self
457        }
458
459        /// Sets all the options, replacing any prior values.
460        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
461            self.0.options = v.into();
462            self
463        }
464
465        /// Sends the request.
466        pub async fn send(self) -> Result<()> {
467            (*self.0.stub)
468                .delete_queue(self.0.request, self.0.options)
469                .await
470                .map(gax::response::Response::into_body)
471        }
472
473        /// Sets the value of [name][crate::model::DeleteQueueRequest::name].
474        ///
475        /// This is a **required** field for requests.
476        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
477            self.0.request.name = v.into();
478            self
479        }
480    }
481
482    #[doc(hidden)]
483    impl gax::options::internal::RequestBuilder for DeleteQueue {
484        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
485            &mut self.0.options
486        }
487    }
488
489    /// The request builder for [CloudTasks::purge_queue][crate::client::CloudTasks::purge_queue] calls.
490    ///
491    /// # Example
492    /// ```no_run
493    /// # use google_cloud_tasks_v2::builder;
494    /// use builder::cloud_tasks::PurgeQueue;
495    /// # tokio_test::block_on(async {
496    ///
497    /// let builder = prepare_request_builder();
498    /// let response = builder.send().await?;
499    /// # gax::Result::<()>::Ok(()) });
500    ///
501    /// fn prepare_request_builder() -> PurgeQueue {
502    ///   # panic!();
503    ///   // ... details omitted ...
504    /// }
505    /// ```
506    #[derive(Clone, Debug)]
507    pub struct PurgeQueue(RequestBuilder<crate::model::PurgeQueueRequest>);
508
509    impl PurgeQueue {
510        pub(crate) fn new(
511            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
512        ) -> Self {
513            Self(RequestBuilder::new(stub))
514        }
515
516        /// Sets the full request, replacing any prior values.
517        pub fn with_request<V: Into<crate::model::PurgeQueueRequest>>(mut self, v: V) -> Self {
518            self.0.request = v.into();
519            self
520        }
521
522        /// Sets all the options, replacing any prior values.
523        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
524            self.0.options = v.into();
525            self
526        }
527
528        /// Sends the request.
529        pub async fn send(self) -> Result<crate::model::Queue> {
530            (*self.0.stub)
531                .purge_queue(self.0.request, self.0.options)
532                .await
533                .map(gax::response::Response::into_body)
534        }
535
536        /// Sets the value of [name][crate::model::PurgeQueueRequest::name].
537        ///
538        /// This is a **required** field for requests.
539        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
540            self.0.request.name = v.into();
541            self
542        }
543    }
544
545    #[doc(hidden)]
546    impl gax::options::internal::RequestBuilder for PurgeQueue {
547        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
548            &mut self.0.options
549        }
550    }
551
552    /// The request builder for [CloudTasks::pause_queue][crate::client::CloudTasks::pause_queue] calls.
553    ///
554    /// # Example
555    /// ```no_run
556    /// # use google_cloud_tasks_v2::builder;
557    /// use builder::cloud_tasks::PauseQueue;
558    /// # tokio_test::block_on(async {
559    ///
560    /// let builder = prepare_request_builder();
561    /// let response = builder.send().await?;
562    /// # gax::Result::<()>::Ok(()) });
563    ///
564    /// fn prepare_request_builder() -> PauseQueue {
565    ///   # panic!();
566    ///   // ... details omitted ...
567    /// }
568    /// ```
569    #[derive(Clone, Debug)]
570    pub struct PauseQueue(RequestBuilder<crate::model::PauseQueueRequest>);
571
572    impl PauseQueue {
573        pub(crate) fn new(
574            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
575        ) -> Self {
576            Self(RequestBuilder::new(stub))
577        }
578
579        /// Sets the full request, replacing any prior values.
580        pub fn with_request<V: Into<crate::model::PauseQueueRequest>>(mut self, v: V) -> Self {
581            self.0.request = v.into();
582            self
583        }
584
585        /// Sets all the options, replacing any prior values.
586        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
587            self.0.options = v.into();
588            self
589        }
590
591        /// Sends the request.
592        pub async fn send(self) -> Result<crate::model::Queue> {
593            (*self.0.stub)
594                .pause_queue(self.0.request, self.0.options)
595                .await
596                .map(gax::response::Response::into_body)
597        }
598
599        /// Sets the value of [name][crate::model::PauseQueueRequest::name].
600        ///
601        /// This is a **required** field for requests.
602        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
603            self.0.request.name = v.into();
604            self
605        }
606    }
607
608    #[doc(hidden)]
609    impl gax::options::internal::RequestBuilder for PauseQueue {
610        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
611            &mut self.0.options
612        }
613    }
614
615    /// The request builder for [CloudTasks::resume_queue][crate::client::CloudTasks::resume_queue] calls.
616    ///
617    /// # Example
618    /// ```no_run
619    /// # use google_cloud_tasks_v2::builder;
620    /// use builder::cloud_tasks::ResumeQueue;
621    /// # tokio_test::block_on(async {
622    ///
623    /// let builder = prepare_request_builder();
624    /// let response = builder.send().await?;
625    /// # gax::Result::<()>::Ok(()) });
626    ///
627    /// fn prepare_request_builder() -> ResumeQueue {
628    ///   # panic!();
629    ///   // ... details omitted ...
630    /// }
631    /// ```
632    #[derive(Clone, Debug)]
633    pub struct ResumeQueue(RequestBuilder<crate::model::ResumeQueueRequest>);
634
635    impl ResumeQueue {
636        pub(crate) fn new(
637            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
638        ) -> Self {
639            Self(RequestBuilder::new(stub))
640        }
641
642        /// Sets the full request, replacing any prior values.
643        pub fn with_request<V: Into<crate::model::ResumeQueueRequest>>(mut self, v: V) -> Self {
644            self.0.request = v.into();
645            self
646        }
647
648        /// Sets all the options, replacing any prior values.
649        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
650            self.0.options = v.into();
651            self
652        }
653
654        /// Sends the request.
655        pub async fn send(self) -> Result<crate::model::Queue> {
656            (*self.0.stub)
657                .resume_queue(self.0.request, self.0.options)
658                .await
659                .map(gax::response::Response::into_body)
660        }
661
662        /// Sets the value of [name][crate::model::ResumeQueueRequest::name].
663        ///
664        /// This is a **required** field for requests.
665        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
666            self.0.request.name = v.into();
667            self
668        }
669    }
670
671    #[doc(hidden)]
672    impl gax::options::internal::RequestBuilder for ResumeQueue {
673        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
674            &mut self.0.options
675        }
676    }
677
678    /// The request builder for [CloudTasks::get_iam_policy][crate::client::CloudTasks::get_iam_policy] calls.
679    ///
680    /// # Example
681    /// ```no_run
682    /// # use google_cloud_tasks_v2::builder;
683    /// use builder::cloud_tasks::GetIamPolicy;
684    /// # tokio_test::block_on(async {
685    ///
686    /// let builder = prepare_request_builder();
687    /// let response = builder.send().await?;
688    /// # gax::Result::<()>::Ok(()) });
689    ///
690    /// fn prepare_request_builder() -> GetIamPolicy {
691    ///   # panic!();
692    ///   // ... details omitted ...
693    /// }
694    /// ```
695    #[derive(Clone, Debug)]
696    pub struct GetIamPolicy(RequestBuilder<iam_v1::model::GetIamPolicyRequest>);
697
698    impl GetIamPolicy {
699        pub(crate) fn new(
700            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
701        ) -> Self {
702            Self(RequestBuilder::new(stub))
703        }
704
705        /// Sets the full request, replacing any prior values.
706        pub fn with_request<V: Into<iam_v1::model::GetIamPolicyRequest>>(mut self, v: V) -> Self {
707            self.0.request = v.into();
708            self
709        }
710
711        /// Sets all the options, replacing any prior values.
712        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
713            self.0.options = v.into();
714            self
715        }
716
717        /// Sends the request.
718        pub async fn send(self) -> Result<iam_v1::model::Policy> {
719            (*self.0.stub)
720                .get_iam_policy(self.0.request, self.0.options)
721                .await
722                .map(gax::response::Response::into_body)
723        }
724
725        /// Sets the value of [resource][iam_v1::model::GetIamPolicyRequest::resource].
726        ///
727        /// This is a **required** field for requests.
728        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
729            self.0.request.resource = v.into();
730            self
731        }
732
733        /// Sets the value of [options][iam_v1::model::GetIamPolicyRequest::options].
734        pub fn set_options<T>(mut self, v: T) -> Self
735        where
736            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
737        {
738            self.0.request.options = std::option::Option::Some(v.into());
739            self
740        }
741
742        /// Sets or clears the value of [options][iam_v1::model::GetIamPolicyRequest::options].
743        pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
744        where
745            T: std::convert::Into<iam_v1::model::GetPolicyOptions>,
746        {
747            self.0.request.options = v.map(|x| x.into());
748            self
749        }
750    }
751
752    #[doc(hidden)]
753    impl gax::options::internal::RequestBuilder for GetIamPolicy {
754        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
755            &mut self.0.options
756        }
757    }
758
759    /// The request builder for [CloudTasks::set_iam_policy][crate::client::CloudTasks::set_iam_policy] calls.
760    ///
761    /// # Example
762    /// ```no_run
763    /// # use google_cloud_tasks_v2::builder;
764    /// use builder::cloud_tasks::SetIamPolicy;
765    /// # tokio_test::block_on(async {
766    ///
767    /// let builder = prepare_request_builder();
768    /// let response = builder.send().await?;
769    /// # gax::Result::<()>::Ok(()) });
770    ///
771    /// fn prepare_request_builder() -> SetIamPolicy {
772    ///   # panic!();
773    ///   // ... details omitted ...
774    /// }
775    /// ```
776    #[derive(Clone, Debug)]
777    pub struct SetIamPolicy(RequestBuilder<iam_v1::model::SetIamPolicyRequest>);
778
779    impl SetIamPolicy {
780        pub(crate) fn new(
781            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
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<iam_v1::model::SetIamPolicyRequest>>(mut self, v: V) -> Self {
788            self.0.request = v.into();
789            self
790        }
791
792        /// Sets all the options, replacing any prior values.
793        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
794            self.0.options = v.into();
795            self
796        }
797
798        /// Sends the request.
799        pub async fn send(self) -> Result<iam_v1::model::Policy> {
800            (*self.0.stub)
801                .set_iam_policy(self.0.request, self.0.options)
802                .await
803                .map(gax::response::Response::into_body)
804        }
805
806        /// Sets the value of [resource][iam_v1::model::SetIamPolicyRequest::resource].
807        ///
808        /// This is a **required** field for requests.
809        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
810            self.0.request.resource = v.into();
811            self
812        }
813
814        /// Sets the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
815        ///
816        /// This is a **required** field for requests.
817        pub fn set_policy<T>(mut self, v: T) -> Self
818        where
819            T: std::convert::Into<iam_v1::model::Policy>,
820        {
821            self.0.request.policy = std::option::Option::Some(v.into());
822            self
823        }
824
825        /// Sets or clears the value of [policy][iam_v1::model::SetIamPolicyRequest::policy].
826        ///
827        /// This is a **required** field for requests.
828        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
829        where
830            T: std::convert::Into<iam_v1::model::Policy>,
831        {
832            self.0.request.policy = v.map(|x| x.into());
833            self
834        }
835
836        /// Sets the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
837        pub fn set_update_mask<T>(mut self, v: T) -> Self
838        where
839            T: std::convert::Into<wkt::FieldMask>,
840        {
841            self.0.request.update_mask = std::option::Option::Some(v.into());
842            self
843        }
844
845        /// Sets or clears the value of [update_mask][iam_v1::model::SetIamPolicyRequest::update_mask].
846        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
847        where
848            T: std::convert::Into<wkt::FieldMask>,
849        {
850            self.0.request.update_mask = v.map(|x| x.into());
851            self
852        }
853    }
854
855    #[doc(hidden)]
856    impl gax::options::internal::RequestBuilder for SetIamPolicy {
857        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
858            &mut self.0.options
859        }
860    }
861
862    /// The request builder for [CloudTasks::test_iam_permissions][crate::client::CloudTasks::test_iam_permissions] calls.
863    ///
864    /// # Example
865    /// ```no_run
866    /// # use google_cloud_tasks_v2::builder;
867    /// use builder::cloud_tasks::TestIamPermissions;
868    /// # tokio_test::block_on(async {
869    ///
870    /// let builder = prepare_request_builder();
871    /// let response = builder.send().await?;
872    /// # gax::Result::<()>::Ok(()) });
873    ///
874    /// fn prepare_request_builder() -> TestIamPermissions {
875    ///   # panic!();
876    ///   // ... details omitted ...
877    /// }
878    /// ```
879    #[derive(Clone, Debug)]
880    pub struct TestIamPermissions(RequestBuilder<iam_v1::model::TestIamPermissionsRequest>);
881
882    impl TestIamPermissions {
883        pub(crate) fn new(
884            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
885        ) -> Self {
886            Self(RequestBuilder::new(stub))
887        }
888
889        /// Sets the full request, replacing any prior values.
890        pub fn with_request<V: Into<iam_v1::model::TestIamPermissionsRequest>>(
891            mut self,
892            v: V,
893        ) -> Self {
894            self.0.request = v.into();
895            self
896        }
897
898        /// Sets all the options, replacing any prior values.
899        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
900            self.0.options = v.into();
901            self
902        }
903
904        /// Sends the request.
905        pub async fn send(self) -> Result<iam_v1::model::TestIamPermissionsResponse> {
906            (*self.0.stub)
907                .test_iam_permissions(self.0.request, self.0.options)
908                .await
909                .map(gax::response::Response::into_body)
910        }
911
912        /// Sets the value of [resource][iam_v1::model::TestIamPermissionsRequest::resource].
913        ///
914        /// This is a **required** field for requests.
915        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
916            self.0.request.resource = v.into();
917            self
918        }
919
920        /// Sets the value of [permissions][iam_v1::model::TestIamPermissionsRequest::permissions].
921        ///
922        /// This is a **required** field for requests.
923        pub fn set_permissions<T, V>(mut self, v: T) -> Self
924        where
925            T: std::iter::IntoIterator<Item = V>,
926            V: std::convert::Into<std::string::String>,
927        {
928            use std::iter::Iterator;
929            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
930            self
931        }
932    }
933
934    #[doc(hidden)]
935    impl gax::options::internal::RequestBuilder for TestIamPermissions {
936        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
937            &mut self.0.options
938        }
939    }
940
941    /// The request builder for [CloudTasks::list_tasks][crate::client::CloudTasks::list_tasks] calls.
942    ///
943    /// # Example
944    /// ```no_run
945    /// # use google_cloud_tasks_v2::builder;
946    /// use builder::cloud_tasks::ListTasks;
947    /// # tokio_test::block_on(async {
948    /// use gax::paginator::ItemPaginator;
949    ///
950    /// let builder = prepare_request_builder();
951    /// let mut items = builder.by_item();
952    /// while let Some(result) = items.next().await {
953    ///   let item = result?;
954    /// }
955    /// # gax::Result::<()>::Ok(()) });
956    ///
957    /// fn prepare_request_builder() -> ListTasks {
958    ///   # panic!();
959    ///   // ... details omitted ...
960    /// }
961    /// ```
962    #[derive(Clone, Debug)]
963    pub struct ListTasks(RequestBuilder<crate::model::ListTasksRequest>);
964
965    impl ListTasks {
966        pub(crate) fn new(
967            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
968        ) -> Self {
969            Self(RequestBuilder::new(stub))
970        }
971
972        /// Sets the full request, replacing any prior values.
973        pub fn with_request<V: Into<crate::model::ListTasksRequest>>(mut self, v: V) -> Self {
974            self.0.request = v.into();
975            self
976        }
977
978        /// Sets all the options, replacing any prior values.
979        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
980            self.0.options = v.into();
981            self
982        }
983
984        /// Sends the request.
985        pub async fn send(self) -> Result<crate::model::ListTasksResponse> {
986            (*self.0.stub)
987                .list_tasks(self.0.request, self.0.options)
988                .await
989                .map(gax::response::Response::into_body)
990        }
991
992        /// Streams each page in the collection.
993        pub fn by_page(
994            self,
995        ) -> impl gax::paginator::Paginator<crate::model::ListTasksResponse, gax::error::Error>
996        {
997            use std::clone::Clone;
998            let token = self.0.request.page_token.clone();
999            let execute = move |token: String| {
1000                let mut builder = self.clone();
1001                builder.0.request = builder.0.request.set_page_token(token);
1002                builder.send()
1003            };
1004            gax::paginator::internal::new_paginator(token, execute)
1005        }
1006
1007        /// Streams each item in the collection.
1008        pub fn by_item(
1009            self,
1010        ) -> impl gax::paginator::ItemPaginator<crate::model::ListTasksResponse, gax::error::Error>
1011        {
1012            use gax::paginator::Paginator;
1013            self.by_page().items()
1014        }
1015
1016        /// Sets the value of [parent][crate::model::ListTasksRequest::parent].
1017        ///
1018        /// This is a **required** field for requests.
1019        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1020            self.0.request.parent = v.into();
1021            self
1022        }
1023
1024        /// Sets the value of [response_view][crate::model::ListTasksRequest::response_view].
1025        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1026            self.0.request.response_view = v.into();
1027            self
1028        }
1029
1030        /// Sets the value of [page_size][crate::model::ListTasksRequest::page_size].
1031        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1032            self.0.request.page_size = v.into();
1033            self
1034        }
1035
1036        /// Sets the value of [page_token][crate::model::ListTasksRequest::page_token].
1037        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1038            self.0.request.page_token = v.into();
1039            self
1040        }
1041    }
1042
1043    #[doc(hidden)]
1044    impl gax::options::internal::RequestBuilder for ListTasks {
1045        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1046            &mut self.0.options
1047        }
1048    }
1049
1050    /// The request builder for [CloudTasks::get_task][crate::client::CloudTasks::get_task] calls.
1051    ///
1052    /// # Example
1053    /// ```no_run
1054    /// # use google_cloud_tasks_v2::builder;
1055    /// use builder::cloud_tasks::GetTask;
1056    /// # tokio_test::block_on(async {
1057    ///
1058    /// let builder = prepare_request_builder();
1059    /// let response = builder.send().await?;
1060    /// # gax::Result::<()>::Ok(()) });
1061    ///
1062    /// fn prepare_request_builder() -> GetTask {
1063    ///   # panic!();
1064    ///   // ... details omitted ...
1065    /// }
1066    /// ```
1067    #[derive(Clone, Debug)]
1068    pub struct GetTask(RequestBuilder<crate::model::GetTaskRequest>);
1069
1070    impl GetTask {
1071        pub(crate) fn new(
1072            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1073        ) -> Self {
1074            Self(RequestBuilder::new(stub))
1075        }
1076
1077        /// Sets the full request, replacing any prior values.
1078        pub fn with_request<V: Into<crate::model::GetTaskRequest>>(mut self, v: V) -> Self {
1079            self.0.request = v.into();
1080            self
1081        }
1082
1083        /// Sets all the options, replacing any prior values.
1084        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1085            self.0.options = v.into();
1086            self
1087        }
1088
1089        /// Sends the request.
1090        pub async fn send(self) -> Result<crate::model::Task> {
1091            (*self.0.stub)
1092                .get_task(self.0.request, self.0.options)
1093                .await
1094                .map(gax::response::Response::into_body)
1095        }
1096
1097        /// Sets the value of [name][crate::model::GetTaskRequest::name].
1098        ///
1099        /// This is a **required** field for requests.
1100        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1101            self.0.request.name = v.into();
1102            self
1103        }
1104
1105        /// Sets the value of [response_view][crate::model::GetTaskRequest::response_view].
1106        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1107            self.0.request.response_view = v.into();
1108            self
1109        }
1110    }
1111
1112    #[doc(hidden)]
1113    impl gax::options::internal::RequestBuilder for GetTask {
1114        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1115            &mut self.0.options
1116        }
1117    }
1118
1119    /// The request builder for [CloudTasks::create_task][crate::client::CloudTasks::create_task] calls.
1120    ///
1121    /// # Example
1122    /// ```no_run
1123    /// # use google_cloud_tasks_v2::builder;
1124    /// use builder::cloud_tasks::CreateTask;
1125    /// # tokio_test::block_on(async {
1126    ///
1127    /// let builder = prepare_request_builder();
1128    /// let response = builder.send().await?;
1129    /// # gax::Result::<()>::Ok(()) });
1130    ///
1131    /// fn prepare_request_builder() -> CreateTask {
1132    ///   # panic!();
1133    ///   // ... details omitted ...
1134    /// }
1135    /// ```
1136    #[derive(Clone, Debug)]
1137    pub struct CreateTask(RequestBuilder<crate::model::CreateTaskRequest>);
1138
1139    impl CreateTask {
1140        pub(crate) fn new(
1141            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1142        ) -> Self {
1143            Self(RequestBuilder::new(stub))
1144        }
1145
1146        /// Sets the full request, replacing any prior values.
1147        pub fn with_request<V: Into<crate::model::CreateTaskRequest>>(mut self, v: V) -> Self {
1148            self.0.request = v.into();
1149            self
1150        }
1151
1152        /// Sets all the options, replacing any prior values.
1153        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1154            self.0.options = v.into();
1155            self
1156        }
1157
1158        /// Sends the request.
1159        pub async fn send(self) -> Result<crate::model::Task> {
1160            (*self.0.stub)
1161                .create_task(self.0.request, self.0.options)
1162                .await
1163                .map(gax::response::Response::into_body)
1164        }
1165
1166        /// Sets the value of [parent][crate::model::CreateTaskRequest::parent].
1167        ///
1168        /// This is a **required** field for requests.
1169        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1170            self.0.request.parent = v.into();
1171            self
1172        }
1173
1174        /// Sets the value of [task][crate::model::CreateTaskRequest::task].
1175        ///
1176        /// This is a **required** field for requests.
1177        pub fn set_task<T>(mut self, v: T) -> Self
1178        where
1179            T: std::convert::Into<crate::model::Task>,
1180        {
1181            self.0.request.task = std::option::Option::Some(v.into());
1182            self
1183        }
1184
1185        /// Sets or clears the value of [task][crate::model::CreateTaskRequest::task].
1186        ///
1187        /// This is a **required** field for requests.
1188        pub fn set_or_clear_task<T>(mut self, v: std::option::Option<T>) -> Self
1189        where
1190            T: std::convert::Into<crate::model::Task>,
1191        {
1192            self.0.request.task = v.map(|x| x.into());
1193            self
1194        }
1195
1196        /// Sets the value of [response_view][crate::model::CreateTaskRequest::response_view].
1197        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1198            self.0.request.response_view = v.into();
1199            self
1200        }
1201    }
1202
1203    #[doc(hidden)]
1204    impl gax::options::internal::RequestBuilder for CreateTask {
1205        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1206            &mut self.0.options
1207        }
1208    }
1209
1210    /// The request builder for [CloudTasks::delete_task][crate::client::CloudTasks::delete_task] calls.
1211    ///
1212    /// # Example
1213    /// ```no_run
1214    /// # use google_cloud_tasks_v2::builder;
1215    /// use builder::cloud_tasks::DeleteTask;
1216    /// # tokio_test::block_on(async {
1217    ///
1218    /// let builder = prepare_request_builder();
1219    /// let response = builder.send().await?;
1220    /// # gax::Result::<()>::Ok(()) });
1221    ///
1222    /// fn prepare_request_builder() -> DeleteTask {
1223    ///   # panic!();
1224    ///   // ... details omitted ...
1225    /// }
1226    /// ```
1227    #[derive(Clone, Debug)]
1228    pub struct DeleteTask(RequestBuilder<crate::model::DeleteTaskRequest>);
1229
1230    impl DeleteTask {
1231        pub(crate) fn new(
1232            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1233        ) -> Self {
1234            Self(RequestBuilder::new(stub))
1235        }
1236
1237        /// Sets the full request, replacing any prior values.
1238        pub fn with_request<V: Into<crate::model::DeleteTaskRequest>>(mut self, v: V) -> Self {
1239            self.0.request = v.into();
1240            self
1241        }
1242
1243        /// Sets all the options, replacing any prior values.
1244        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1245            self.0.options = v.into();
1246            self
1247        }
1248
1249        /// Sends the request.
1250        pub async fn send(self) -> Result<()> {
1251            (*self.0.stub)
1252                .delete_task(self.0.request, self.0.options)
1253                .await
1254                .map(gax::response::Response::into_body)
1255        }
1256
1257        /// Sets the value of [name][crate::model::DeleteTaskRequest::name].
1258        ///
1259        /// This is a **required** field for requests.
1260        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1261            self.0.request.name = v.into();
1262            self
1263        }
1264    }
1265
1266    #[doc(hidden)]
1267    impl gax::options::internal::RequestBuilder for DeleteTask {
1268        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1269            &mut self.0.options
1270        }
1271    }
1272
1273    /// The request builder for [CloudTasks::run_task][crate::client::CloudTasks::run_task] calls.
1274    ///
1275    /// # Example
1276    /// ```no_run
1277    /// # use google_cloud_tasks_v2::builder;
1278    /// use builder::cloud_tasks::RunTask;
1279    /// # tokio_test::block_on(async {
1280    ///
1281    /// let builder = prepare_request_builder();
1282    /// let response = builder.send().await?;
1283    /// # gax::Result::<()>::Ok(()) });
1284    ///
1285    /// fn prepare_request_builder() -> RunTask {
1286    ///   # panic!();
1287    ///   // ... details omitted ...
1288    /// }
1289    /// ```
1290    #[derive(Clone, Debug)]
1291    pub struct RunTask(RequestBuilder<crate::model::RunTaskRequest>);
1292
1293    impl RunTask {
1294        pub(crate) fn new(
1295            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1296        ) -> Self {
1297            Self(RequestBuilder::new(stub))
1298        }
1299
1300        /// Sets the full request, replacing any prior values.
1301        pub fn with_request<V: Into<crate::model::RunTaskRequest>>(mut self, v: V) -> Self {
1302            self.0.request = v.into();
1303            self
1304        }
1305
1306        /// Sets all the options, replacing any prior values.
1307        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1308            self.0.options = v.into();
1309            self
1310        }
1311
1312        /// Sends the request.
1313        pub async fn send(self) -> Result<crate::model::Task> {
1314            (*self.0.stub)
1315                .run_task(self.0.request, self.0.options)
1316                .await
1317                .map(gax::response::Response::into_body)
1318        }
1319
1320        /// Sets the value of [name][crate::model::RunTaskRequest::name].
1321        ///
1322        /// This is a **required** field for requests.
1323        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1324            self.0.request.name = v.into();
1325            self
1326        }
1327
1328        /// Sets the value of [response_view][crate::model::RunTaskRequest::response_view].
1329        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1330            self.0.request.response_view = v.into();
1331            self
1332        }
1333    }
1334
1335    #[doc(hidden)]
1336    impl gax::options::internal::RequestBuilder for RunTask {
1337        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1338            &mut self.0.options
1339        }
1340    }
1341
1342    /// The request builder for [CloudTasks::list_locations][crate::client::CloudTasks::list_locations] calls.
1343    ///
1344    /// # Example
1345    /// ```no_run
1346    /// # use google_cloud_tasks_v2::builder;
1347    /// use builder::cloud_tasks::ListLocations;
1348    /// # tokio_test::block_on(async {
1349    /// use gax::paginator::ItemPaginator;
1350    ///
1351    /// let builder = prepare_request_builder();
1352    /// let mut items = builder.by_item();
1353    /// while let Some(result) = items.next().await {
1354    ///   let item = result?;
1355    /// }
1356    /// # gax::Result::<()>::Ok(()) });
1357    ///
1358    /// fn prepare_request_builder() -> ListLocations {
1359    ///   # panic!();
1360    ///   // ... details omitted ...
1361    /// }
1362    /// ```
1363    #[derive(Clone, Debug)]
1364    pub struct ListLocations(RequestBuilder<location::model::ListLocationsRequest>);
1365
1366    impl ListLocations {
1367        pub(crate) fn new(
1368            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1369        ) -> Self {
1370            Self(RequestBuilder::new(stub))
1371        }
1372
1373        /// Sets the full request, replacing any prior values.
1374        pub fn with_request<V: Into<location::model::ListLocationsRequest>>(
1375            mut self,
1376            v: V,
1377        ) -> Self {
1378            self.0.request = v.into();
1379            self
1380        }
1381
1382        /// Sets all the options, replacing any prior values.
1383        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1384            self.0.options = v.into();
1385            self
1386        }
1387
1388        /// Sends the request.
1389        pub async fn send(self) -> Result<location::model::ListLocationsResponse> {
1390            (*self.0.stub)
1391                .list_locations(self.0.request, self.0.options)
1392                .await
1393                .map(gax::response::Response::into_body)
1394        }
1395
1396        /// Streams each page in the collection.
1397        pub fn by_page(
1398            self,
1399        ) -> impl gax::paginator::Paginator<location::model::ListLocationsResponse, gax::error::Error>
1400        {
1401            use std::clone::Clone;
1402            let token = self.0.request.page_token.clone();
1403            let execute = move |token: String| {
1404                let mut builder = self.clone();
1405                builder.0.request = builder.0.request.set_page_token(token);
1406                builder.send()
1407            };
1408            gax::paginator::internal::new_paginator(token, execute)
1409        }
1410
1411        /// Streams each item in the collection.
1412        pub fn by_item(
1413            self,
1414        ) -> impl gax::paginator::ItemPaginator<location::model::ListLocationsResponse, gax::error::Error>
1415        {
1416            use gax::paginator::Paginator;
1417            self.by_page().items()
1418        }
1419
1420        /// Sets the value of [name][location::model::ListLocationsRequest::name].
1421        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1422            self.0.request.name = v.into();
1423            self
1424        }
1425
1426        /// Sets the value of [filter][location::model::ListLocationsRequest::filter].
1427        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1428            self.0.request.filter = v.into();
1429            self
1430        }
1431
1432        /// Sets the value of [page_size][location::model::ListLocationsRequest::page_size].
1433        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1434            self.0.request.page_size = v.into();
1435            self
1436        }
1437
1438        /// Sets the value of [page_token][location::model::ListLocationsRequest::page_token].
1439        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1440            self.0.request.page_token = v.into();
1441            self
1442        }
1443    }
1444
1445    #[doc(hidden)]
1446    impl gax::options::internal::RequestBuilder for ListLocations {
1447        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1448            &mut self.0.options
1449        }
1450    }
1451
1452    /// The request builder for [CloudTasks::get_location][crate::client::CloudTasks::get_location] calls.
1453    ///
1454    /// # Example
1455    /// ```no_run
1456    /// # use google_cloud_tasks_v2::builder;
1457    /// use builder::cloud_tasks::GetLocation;
1458    /// # tokio_test::block_on(async {
1459    ///
1460    /// let builder = prepare_request_builder();
1461    /// let response = builder.send().await?;
1462    /// # gax::Result::<()>::Ok(()) });
1463    ///
1464    /// fn prepare_request_builder() -> GetLocation {
1465    ///   # panic!();
1466    ///   // ... details omitted ...
1467    /// }
1468    /// ```
1469    #[derive(Clone, Debug)]
1470    pub struct GetLocation(RequestBuilder<location::model::GetLocationRequest>);
1471
1472    impl GetLocation {
1473        pub(crate) fn new(
1474            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1475        ) -> Self {
1476            Self(RequestBuilder::new(stub))
1477        }
1478
1479        /// Sets the full request, replacing any prior values.
1480        pub fn with_request<V: Into<location::model::GetLocationRequest>>(mut self, v: V) -> Self {
1481            self.0.request = v.into();
1482            self
1483        }
1484
1485        /// Sets all the options, replacing any prior values.
1486        pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1487            self.0.options = v.into();
1488            self
1489        }
1490
1491        /// Sends the request.
1492        pub async fn send(self) -> Result<location::model::Location> {
1493            (*self.0.stub)
1494                .get_location(self.0.request, self.0.options)
1495                .await
1496                .map(gax::response::Response::into_body)
1497        }
1498
1499        /// Sets the value of [name][location::model::GetLocationRequest::name].
1500        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1501            self.0.request.name = v.into();
1502            self
1503        }
1504    }
1505
1506    #[doc(hidden)]
1507    impl gax::options::internal::RequestBuilder for GetLocation {
1508        fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1509            &mut self.0.options
1510        }
1511    }
1512}