Skip to main content

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
17/// Request and client builders for [CloudTasks][crate::client::CloudTasks].
18pub mod cloud_tasks {
19    use crate::Result;
20
21    /// A builder for [CloudTasks][crate::client::CloudTasks].
22    ///
23    /// ```
24    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25    /// # use google_cloud_tasks_v2::*;
26    /// # use builder::cloud_tasks::ClientBuilder;
27    /// # use client::CloudTasks;
28    /// let builder : ClientBuilder = CloudTasks::builder();
29    /// let client = builder
30    ///     .with_endpoint("https://cloudtasks.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::CloudTasks;
38        pub struct Factory;
39        impl crate::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            ) -> crate::ClientBuilderResult<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: 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::CloudTasks>,
65        ) -> Self {
66            Self {
67                stub,
68                request: R::default(),
69                options: crate::RequestOptions::default(),
70            }
71        }
72    }
73
74    /// The request builder for [CloudTasks::list_queues][crate::client::CloudTasks::list_queues] calls.
75    ///
76    /// # Example
77    /// ```
78    /// # use google_cloud_tasks_v2::builder::cloud_tasks::ListQueues;
79    /// # async fn sample() -> google_cloud_tasks_v2::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() -> ListQueues {
90    ///   # panic!();
91    ///   // ... details omitted ...
92    /// }
93    /// ```
94    #[derive(Clone, Debug)]
95    pub struct ListQueues(RequestBuilder<crate::model::ListQueuesRequest>);
96
97    impl ListQueues {
98        pub(crate) fn new(
99            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
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::ListQueuesRequest>>(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::ListQueuesResponse> {
118            (*self.0.stub)
119                .list_queues(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::ListQueuesResponse, 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::ListQueuesResponse,
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::ListQueuesRequest::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 [filter][crate::model::ListQueuesRequest::filter].
159        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
160            self.0.request.filter = v.into();
161            self
162        }
163
164        /// Sets the value of [page_size][crate::model::ListQueuesRequest::page_size].
165        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
166            self.0.request.page_size = v.into();
167            self
168        }
169
170        /// Sets the value of [page_token][crate::model::ListQueuesRequest::page_token].
171        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
172            self.0.request.page_token = v.into();
173            self
174        }
175    }
176
177    #[doc(hidden)]
178    impl crate::RequestBuilder for ListQueues {
179        fn request_options(&mut self) -> &mut crate::RequestOptions {
180            &mut self.0.options
181        }
182    }
183
184    /// The request builder for [CloudTasks::get_queue][crate::client::CloudTasks::get_queue] calls.
185    ///
186    /// # Example
187    /// ```
188    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetQueue;
189    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
190    ///
191    /// let builder = prepare_request_builder();
192    /// let response = builder.send().await?;
193    /// # 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<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::Queue> {
224            (*self.0.stub)
225                .get_queue(self.0.request, self.0.options)
226                .await
227                .map(crate::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 crate::RequestBuilder for GetQueue {
241        fn request_options(&mut self) -> &mut crate::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    /// ```
250    /// # use google_cloud_tasks_v2::builder::cloud_tasks::CreateQueue;
251    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
252    ///
253    /// let builder = prepare_request_builder();
254    /// let response = builder.send().await?;
255    /// # Ok(()) }
256    ///
257    /// fn prepare_request_builder() -> CreateQueue {
258    ///   # panic!();
259    ///   // ... details omitted ...
260    /// }
261    /// ```
262    #[derive(Clone, Debug)]
263    pub struct CreateQueue(RequestBuilder<crate::model::CreateQueueRequest>);
264
265    impl CreateQueue {
266        pub(crate) fn new(
267            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
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::CreateQueueRequest>>(mut self, v: V) -> Self {
274            self.0.request = v.into();
275            self
276        }
277
278        /// Sets all the options, replacing any prior values.
279        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
280            self.0.options = v.into();
281            self
282        }
283
284        /// Sends the request.
285        pub async fn send(self) -> Result<crate::model::Queue> {
286            (*self.0.stub)
287                .create_queue(self.0.request, self.0.options)
288                .await
289                .map(crate::Response::into_body)
290        }
291
292        /// Sets the value of [parent][crate::model::CreateQueueRequest::parent].
293        ///
294        /// This is a **required** field for requests.
295        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
296            self.0.request.parent = v.into();
297            self
298        }
299
300        /// Sets the value of [queue][crate::model::CreateQueueRequest::queue].
301        ///
302        /// This is a **required** field for requests.
303        pub fn set_queue<T>(mut self, v: T) -> Self
304        where
305            T: std::convert::Into<crate::model::Queue>,
306        {
307            self.0.request.queue = std::option::Option::Some(v.into());
308            self
309        }
310
311        /// Sets or clears the value of [queue][crate::model::CreateQueueRequest::queue].
312        ///
313        /// This is a **required** field for requests.
314        pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
315        where
316            T: std::convert::Into<crate::model::Queue>,
317        {
318            self.0.request.queue = v.map(|x| x.into());
319            self
320        }
321    }
322
323    #[doc(hidden)]
324    impl crate::RequestBuilder for CreateQueue {
325        fn request_options(&mut self) -> &mut crate::RequestOptions {
326            &mut self.0.options
327        }
328    }
329
330    /// The request builder for [CloudTasks::update_queue][crate::client::CloudTasks::update_queue] calls.
331    ///
332    /// # Example
333    /// ```
334    /// # use google_cloud_tasks_v2::builder::cloud_tasks::UpdateQueue;
335    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
336    ///
337    /// let builder = prepare_request_builder();
338    /// let response = builder.send().await?;
339    /// # Ok(()) }
340    ///
341    /// fn prepare_request_builder() -> UpdateQueue {
342    ///   # panic!();
343    ///   // ... details omitted ...
344    /// }
345    /// ```
346    #[derive(Clone, Debug)]
347    pub struct UpdateQueue(RequestBuilder<crate::model::UpdateQueueRequest>);
348
349    impl UpdateQueue {
350        pub(crate) fn new(
351            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
352        ) -> Self {
353            Self(RequestBuilder::new(stub))
354        }
355
356        /// Sets the full request, replacing any prior values.
357        pub fn with_request<V: Into<crate::model::UpdateQueueRequest>>(mut self, v: V) -> Self {
358            self.0.request = v.into();
359            self
360        }
361
362        /// Sets all the options, replacing any prior values.
363        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
364            self.0.options = v.into();
365            self
366        }
367
368        /// Sends the request.
369        pub async fn send(self) -> Result<crate::model::Queue> {
370            (*self.0.stub)
371                .update_queue(self.0.request, self.0.options)
372                .await
373                .map(crate::Response::into_body)
374        }
375
376        /// Sets the value of [queue][crate::model::UpdateQueueRequest::queue].
377        ///
378        /// This is a **required** field for requests.
379        pub fn set_queue<T>(mut self, v: T) -> Self
380        where
381            T: std::convert::Into<crate::model::Queue>,
382        {
383            self.0.request.queue = std::option::Option::Some(v.into());
384            self
385        }
386
387        /// Sets or clears the value of [queue][crate::model::UpdateQueueRequest::queue].
388        ///
389        /// This is a **required** field for requests.
390        pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
391        where
392            T: std::convert::Into<crate::model::Queue>,
393        {
394            self.0.request.queue = v.map(|x| x.into());
395            self
396        }
397
398        /// Sets the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
399        pub fn set_update_mask<T>(mut self, v: T) -> Self
400        where
401            T: std::convert::Into<wkt::FieldMask>,
402        {
403            self.0.request.update_mask = std::option::Option::Some(v.into());
404            self
405        }
406
407        /// Sets or clears the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
408        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
409        where
410            T: std::convert::Into<wkt::FieldMask>,
411        {
412            self.0.request.update_mask = v.map(|x| x.into());
413            self
414        }
415    }
416
417    #[doc(hidden)]
418    impl crate::RequestBuilder for UpdateQueue {
419        fn request_options(&mut self) -> &mut crate::RequestOptions {
420            &mut self.0.options
421        }
422    }
423
424    /// The request builder for [CloudTasks::delete_queue][crate::client::CloudTasks::delete_queue] calls.
425    ///
426    /// # Example
427    /// ```
428    /// # use google_cloud_tasks_v2::builder::cloud_tasks::DeleteQueue;
429    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
430    ///
431    /// let builder = prepare_request_builder();
432    /// let response = builder.send().await?;
433    /// # Ok(()) }
434    ///
435    /// fn prepare_request_builder() -> DeleteQueue {
436    ///   # panic!();
437    ///   // ... details omitted ...
438    /// }
439    /// ```
440    #[derive(Clone, Debug)]
441    pub struct DeleteQueue(RequestBuilder<crate::model::DeleteQueueRequest>);
442
443    impl DeleteQueue {
444        pub(crate) fn new(
445            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
446        ) -> Self {
447            Self(RequestBuilder::new(stub))
448        }
449
450        /// Sets the full request, replacing any prior values.
451        pub fn with_request<V: Into<crate::model::DeleteQueueRequest>>(mut self, v: V) -> Self {
452            self.0.request = v.into();
453            self
454        }
455
456        /// Sets all the options, replacing any prior values.
457        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
458            self.0.options = v.into();
459            self
460        }
461
462        /// Sends the request.
463        pub async fn send(self) -> Result<()> {
464            (*self.0.stub)
465                .delete_queue(self.0.request, self.0.options)
466                .await
467                .map(crate::Response::into_body)
468        }
469
470        /// Sets the value of [name][crate::model::DeleteQueueRequest::name].
471        ///
472        /// This is a **required** field for requests.
473        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
474            self.0.request.name = v.into();
475            self
476        }
477    }
478
479    #[doc(hidden)]
480    impl crate::RequestBuilder for DeleteQueue {
481        fn request_options(&mut self) -> &mut crate::RequestOptions {
482            &mut self.0.options
483        }
484    }
485
486    /// The request builder for [CloudTasks::purge_queue][crate::client::CloudTasks::purge_queue] calls.
487    ///
488    /// # Example
489    /// ```
490    /// # use google_cloud_tasks_v2::builder::cloud_tasks::PurgeQueue;
491    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
492    ///
493    /// let builder = prepare_request_builder();
494    /// let response = builder.send().await?;
495    /// # Ok(()) }
496    ///
497    /// fn prepare_request_builder() -> PurgeQueue {
498    ///   # panic!();
499    ///   // ... details omitted ...
500    /// }
501    /// ```
502    #[derive(Clone, Debug)]
503    pub struct PurgeQueue(RequestBuilder<crate::model::PurgeQueueRequest>);
504
505    impl PurgeQueue {
506        pub(crate) fn new(
507            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
508        ) -> Self {
509            Self(RequestBuilder::new(stub))
510        }
511
512        /// Sets the full request, replacing any prior values.
513        pub fn with_request<V: Into<crate::model::PurgeQueueRequest>>(mut self, v: V) -> Self {
514            self.0.request = v.into();
515            self
516        }
517
518        /// Sets all the options, replacing any prior values.
519        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
520            self.0.options = v.into();
521            self
522        }
523
524        /// Sends the request.
525        pub async fn send(self) -> Result<crate::model::Queue> {
526            (*self.0.stub)
527                .purge_queue(self.0.request, self.0.options)
528                .await
529                .map(crate::Response::into_body)
530        }
531
532        /// Sets the value of [name][crate::model::PurgeQueueRequest::name].
533        ///
534        /// This is a **required** field for requests.
535        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
536            self.0.request.name = v.into();
537            self
538        }
539    }
540
541    #[doc(hidden)]
542    impl crate::RequestBuilder for PurgeQueue {
543        fn request_options(&mut self) -> &mut crate::RequestOptions {
544            &mut self.0.options
545        }
546    }
547
548    /// The request builder for [CloudTasks::pause_queue][crate::client::CloudTasks::pause_queue] calls.
549    ///
550    /// # Example
551    /// ```
552    /// # use google_cloud_tasks_v2::builder::cloud_tasks::PauseQueue;
553    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
554    ///
555    /// let builder = prepare_request_builder();
556    /// let response = builder.send().await?;
557    /// # Ok(()) }
558    ///
559    /// fn prepare_request_builder() -> PauseQueue {
560    ///   # panic!();
561    ///   // ... details omitted ...
562    /// }
563    /// ```
564    #[derive(Clone, Debug)]
565    pub struct PauseQueue(RequestBuilder<crate::model::PauseQueueRequest>);
566
567    impl PauseQueue {
568        pub(crate) fn new(
569            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
570        ) -> Self {
571            Self(RequestBuilder::new(stub))
572        }
573
574        /// Sets the full request, replacing any prior values.
575        pub fn with_request<V: Into<crate::model::PauseQueueRequest>>(mut self, v: V) -> Self {
576            self.0.request = v.into();
577            self
578        }
579
580        /// Sets all the options, replacing any prior values.
581        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
582            self.0.options = v.into();
583            self
584        }
585
586        /// Sends the request.
587        pub async fn send(self) -> Result<crate::model::Queue> {
588            (*self.0.stub)
589                .pause_queue(self.0.request, self.0.options)
590                .await
591                .map(crate::Response::into_body)
592        }
593
594        /// Sets the value of [name][crate::model::PauseQueueRequest::name].
595        ///
596        /// This is a **required** field for requests.
597        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
598            self.0.request.name = v.into();
599            self
600        }
601    }
602
603    #[doc(hidden)]
604    impl crate::RequestBuilder for PauseQueue {
605        fn request_options(&mut self) -> &mut crate::RequestOptions {
606            &mut self.0.options
607        }
608    }
609
610    /// The request builder for [CloudTasks::resume_queue][crate::client::CloudTasks::resume_queue] calls.
611    ///
612    /// # Example
613    /// ```
614    /// # use google_cloud_tasks_v2::builder::cloud_tasks::ResumeQueue;
615    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
616    ///
617    /// let builder = prepare_request_builder();
618    /// let response = builder.send().await?;
619    /// # Ok(()) }
620    ///
621    /// fn prepare_request_builder() -> ResumeQueue {
622    ///   # panic!();
623    ///   // ... details omitted ...
624    /// }
625    /// ```
626    #[derive(Clone, Debug)]
627    pub struct ResumeQueue(RequestBuilder<crate::model::ResumeQueueRequest>);
628
629    impl ResumeQueue {
630        pub(crate) fn new(
631            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
632        ) -> Self {
633            Self(RequestBuilder::new(stub))
634        }
635
636        /// Sets the full request, replacing any prior values.
637        pub fn with_request<V: Into<crate::model::ResumeQueueRequest>>(mut self, v: V) -> Self {
638            self.0.request = v.into();
639            self
640        }
641
642        /// Sets all the options, replacing any prior values.
643        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
644            self.0.options = v.into();
645            self
646        }
647
648        /// Sends the request.
649        pub async fn send(self) -> Result<crate::model::Queue> {
650            (*self.0.stub)
651                .resume_queue(self.0.request, self.0.options)
652                .await
653                .map(crate::Response::into_body)
654        }
655
656        /// Sets the value of [name][crate::model::ResumeQueueRequest::name].
657        ///
658        /// This is a **required** field for requests.
659        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
660            self.0.request.name = v.into();
661            self
662        }
663    }
664
665    #[doc(hidden)]
666    impl crate::RequestBuilder for ResumeQueue {
667        fn request_options(&mut self) -> &mut crate::RequestOptions {
668            &mut self.0.options
669        }
670    }
671
672    /// The request builder for [CloudTasks::get_iam_policy][crate::client::CloudTasks::get_iam_policy] calls.
673    ///
674    /// # Example
675    /// ```
676    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetIamPolicy;
677    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
678    ///
679    /// let builder = prepare_request_builder();
680    /// let response = builder.send().await?;
681    /// # Ok(()) }
682    ///
683    /// fn prepare_request_builder() -> GetIamPolicy {
684    ///   # panic!();
685    ///   // ... details omitted ...
686    /// }
687    /// ```
688    #[derive(Clone, Debug)]
689    pub struct GetIamPolicy(RequestBuilder<google_cloud_iam_v1::model::GetIamPolicyRequest>);
690
691    impl GetIamPolicy {
692        pub(crate) fn new(
693            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
694        ) -> Self {
695            Self(RequestBuilder::new(stub))
696        }
697
698        /// Sets the full request, replacing any prior values.
699        pub fn with_request<V: Into<google_cloud_iam_v1::model::GetIamPolicyRequest>>(
700            mut self,
701            v: V,
702        ) -> Self {
703            self.0.request = v.into();
704            self
705        }
706
707        /// Sets all the options, replacing any prior values.
708        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
709            self.0.options = v.into();
710            self
711        }
712
713        /// Sends the request.
714        pub async fn send(self) -> Result<google_cloud_iam_v1::model::Policy> {
715            (*self.0.stub)
716                .get_iam_policy(self.0.request, self.0.options)
717                .await
718                .map(crate::Response::into_body)
719        }
720
721        /// Sets the value of [resource][google_cloud_iam_v1::model::GetIamPolicyRequest::resource].
722        ///
723        /// This is a **required** field for requests.
724        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
725            self.0.request.resource = v.into();
726            self
727        }
728
729        /// Sets the value of [options][google_cloud_iam_v1::model::GetIamPolicyRequest::options].
730        pub fn set_options<T>(mut self, v: T) -> Self
731        where
732            T: std::convert::Into<google_cloud_iam_v1::model::GetPolicyOptions>,
733        {
734            self.0.request.options = std::option::Option::Some(v.into());
735            self
736        }
737
738        /// Sets or clears the value of [options][google_cloud_iam_v1::model::GetIamPolicyRequest::options].
739        pub fn set_or_clear_options<T>(mut self, v: std::option::Option<T>) -> Self
740        where
741            T: std::convert::Into<google_cloud_iam_v1::model::GetPolicyOptions>,
742        {
743            self.0.request.options = v.map(|x| x.into());
744            self
745        }
746    }
747
748    #[doc(hidden)]
749    impl crate::RequestBuilder for GetIamPolicy {
750        fn request_options(&mut self) -> &mut crate::RequestOptions {
751            &mut self.0.options
752        }
753    }
754
755    /// The request builder for [CloudTasks::set_iam_policy][crate::client::CloudTasks::set_iam_policy] calls.
756    ///
757    /// # Example
758    /// ```
759    /// # use google_cloud_tasks_v2::builder::cloud_tasks::SetIamPolicy;
760    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
761    ///
762    /// let builder = prepare_request_builder();
763    /// let response = builder.send().await?;
764    /// # Ok(()) }
765    ///
766    /// fn prepare_request_builder() -> SetIamPolicy {
767    ///   # panic!();
768    ///   // ... details omitted ...
769    /// }
770    /// ```
771    #[derive(Clone, Debug)]
772    pub struct SetIamPolicy(RequestBuilder<google_cloud_iam_v1::model::SetIamPolicyRequest>);
773
774    impl SetIamPolicy {
775        pub(crate) fn new(
776            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
777        ) -> Self {
778            Self(RequestBuilder::new(stub))
779        }
780
781        /// Sets the full request, replacing any prior values.
782        pub fn with_request<V: Into<google_cloud_iam_v1::model::SetIamPolicyRequest>>(
783            mut self,
784            v: V,
785        ) -> Self {
786            self.0.request = v.into();
787            self
788        }
789
790        /// Sets all the options, replacing any prior values.
791        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
792            self.0.options = v.into();
793            self
794        }
795
796        /// Sends the request.
797        pub async fn send(self) -> Result<google_cloud_iam_v1::model::Policy> {
798            (*self.0.stub)
799                .set_iam_policy(self.0.request, self.0.options)
800                .await
801                .map(crate::Response::into_body)
802        }
803
804        /// Sets the value of [resource][google_cloud_iam_v1::model::SetIamPolicyRequest::resource].
805        ///
806        /// This is a **required** field for requests.
807        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
808            self.0.request.resource = v.into();
809            self
810        }
811
812        /// Sets the value of [policy][google_cloud_iam_v1::model::SetIamPolicyRequest::policy].
813        ///
814        /// This is a **required** field for requests.
815        pub fn set_policy<T>(mut self, v: T) -> Self
816        where
817            T: std::convert::Into<google_cloud_iam_v1::model::Policy>,
818        {
819            self.0.request.policy = std::option::Option::Some(v.into());
820            self
821        }
822
823        /// Sets or clears the value of [policy][google_cloud_iam_v1::model::SetIamPolicyRequest::policy].
824        ///
825        /// This is a **required** field for requests.
826        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
827        where
828            T: std::convert::Into<google_cloud_iam_v1::model::Policy>,
829        {
830            self.0.request.policy = v.map(|x| x.into());
831            self
832        }
833
834        /// Sets the value of [update_mask][google_cloud_iam_v1::model::SetIamPolicyRequest::update_mask].
835        pub fn set_update_mask<T>(mut self, v: T) -> Self
836        where
837            T: std::convert::Into<wkt::FieldMask>,
838        {
839            self.0.request.update_mask = std::option::Option::Some(v.into());
840            self
841        }
842
843        /// Sets or clears the value of [update_mask][google_cloud_iam_v1::model::SetIamPolicyRequest::update_mask].
844        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
845        where
846            T: std::convert::Into<wkt::FieldMask>,
847        {
848            self.0.request.update_mask = v.map(|x| x.into());
849            self
850        }
851    }
852
853    #[doc(hidden)]
854    impl crate::RequestBuilder for SetIamPolicy {
855        fn request_options(&mut self) -> &mut crate::RequestOptions {
856            &mut self.0.options
857        }
858    }
859
860    /// The request builder for [CloudTasks::test_iam_permissions][crate::client::CloudTasks::test_iam_permissions] calls.
861    ///
862    /// # Example
863    /// ```
864    /// # use google_cloud_tasks_v2::builder::cloud_tasks::TestIamPermissions;
865    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
866    ///
867    /// let builder = prepare_request_builder();
868    /// let response = builder.send().await?;
869    /// # Ok(()) }
870    ///
871    /// fn prepare_request_builder() -> TestIamPermissions {
872    ///   # panic!();
873    ///   // ... details omitted ...
874    /// }
875    /// ```
876    #[derive(Clone, Debug)]
877    pub struct TestIamPermissions(
878        RequestBuilder<google_cloud_iam_v1::model::TestIamPermissionsRequest>,
879    );
880
881    impl TestIamPermissions {
882        pub(crate) fn new(
883            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
884        ) -> Self {
885            Self(RequestBuilder::new(stub))
886        }
887
888        /// Sets the full request, replacing any prior values.
889        pub fn with_request<V: Into<google_cloud_iam_v1::model::TestIamPermissionsRequest>>(
890            mut self,
891            v: V,
892        ) -> Self {
893            self.0.request = v.into();
894            self
895        }
896
897        /// Sets all the options, replacing any prior values.
898        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
899            self.0.options = v.into();
900            self
901        }
902
903        /// Sends the request.
904        pub async fn send(self) -> Result<google_cloud_iam_v1::model::TestIamPermissionsResponse> {
905            (*self.0.stub)
906                .test_iam_permissions(self.0.request, self.0.options)
907                .await
908                .map(crate::Response::into_body)
909        }
910
911        /// Sets the value of [resource][google_cloud_iam_v1::model::TestIamPermissionsRequest::resource].
912        ///
913        /// This is a **required** field for requests.
914        pub fn set_resource<T: Into<std::string::String>>(mut self, v: T) -> Self {
915            self.0.request.resource = v.into();
916            self
917        }
918
919        /// Sets the value of [permissions][google_cloud_iam_v1::model::TestIamPermissionsRequest::permissions].
920        ///
921        /// This is a **required** field for requests.
922        pub fn set_permissions<T, V>(mut self, v: T) -> Self
923        where
924            T: std::iter::IntoIterator<Item = V>,
925            V: std::convert::Into<std::string::String>,
926        {
927            use std::iter::Iterator;
928            self.0.request.permissions = v.into_iter().map(|i| i.into()).collect();
929            self
930        }
931    }
932
933    #[doc(hidden)]
934    impl crate::RequestBuilder for TestIamPermissions {
935        fn request_options(&mut self) -> &mut crate::RequestOptions {
936            &mut self.0.options
937        }
938    }
939
940    /// The request builder for [CloudTasks::list_tasks][crate::client::CloudTasks::list_tasks] calls.
941    ///
942    /// # Example
943    /// ```
944    /// # use google_cloud_tasks_v2::builder::cloud_tasks::ListTasks;
945    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
946    /// use google_cloud_gax::paginator::ItemPaginator;
947    ///
948    /// let builder = prepare_request_builder();
949    /// let mut items = builder.by_item();
950    /// while let Some(result) = items.next().await {
951    ///   let item = result?;
952    /// }
953    /// # Ok(()) }
954    ///
955    /// fn prepare_request_builder() -> ListTasks {
956    ///   # panic!();
957    ///   // ... details omitted ...
958    /// }
959    /// ```
960    #[derive(Clone, Debug)]
961    pub struct ListTasks(RequestBuilder<crate::model::ListTasksRequest>);
962
963    impl ListTasks {
964        pub(crate) fn new(
965            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
966        ) -> Self {
967            Self(RequestBuilder::new(stub))
968        }
969
970        /// Sets the full request, replacing any prior values.
971        pub fn with_request<V: Into<crate::model::ListTasksRequest>>(mut self, v: V) -> Self {
972            self.0.request = v.into();
973            self
974        }
975
976        /// Sets all the options, replacing any prior values.
977        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
978            self.0.options = v.into();
979            self
980        }
981
982        /// Sends the request.
983        pub async fn send(self) -> Result<crate::model::ListTasksResponse> {
984            (*self.0.stub)
985                .list_tasks(self.0.request, self.0.options)
986                .await
987                .map(crate::Response::into_body)
988        }
989
990        /// Streams each page in the collection.
991        pub fn by_page(
992            self,
993        ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListTasksResponse, crate::Error>
994        {
995            use std::clone::Clone;
996            let token = self.0.request.page_token.clone();
997            let execute = move |token: String| {
998                let mut builder = self.clone();
999                builder.0.request = builder.0.request.set_page_token(token);
1000                builder.send()
1001            };
1002            google_cloud_gax::paginator::internal::new_paginator(token, execute)
1003        }
1004
1005        /// Streams each item in the collection.
1006        pub fn by_item(
1007            self,
1008        ) -> impl google_cloud_gax::paginator::ItemPaginator<crate::model::ListTasksResponse, crate::Error>
1009        {
1010            use google_cloud_gax::paginator::Paginator;
1011            self.by_page().items()
1012        }
1013
1014        /// Sets the value of [parent][crate::model::ListTasksRequest::parent].
1015        ///
1016        /// This is a **required** field for requests.
1017        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1018            self.0.request.parent = v.into();
1019            self
1020        }
1021
1022        /// Sets the value of [response_view][crate::model::ListTasksRequest::response_view].
1023        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1024            self.0.request.response_view = v.into();
1025            self
1026        }
1027
1028        /// Sets the value of [page_size][crate::model::ListTasksRequest::page_size].
1029        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1030            self.0.request.page_size = v.into();
1031            self
1032        }
1033
1034        /// Sets the value of [page_token][crate::model::ListTasksRequest::page_token].
1035        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1036            self.0.request.page_token = v.into();
1037            self
1038        }
1039    }
1040
1041    #[doc(hidden)]
1042    impl crate::RequestBuilder for ListTasks {
1043        fn request_options(&mut self) -> &mut crate::RequestOptions {
1044            &mut self.0.options
1045        }
1046    }
1047
1048    /// The request builder for [CloudTasks::get_task][crate::client::CloudTasks::get_task] calls.
1049    ///
1050    /// # Example
1051    /// ```
1052    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetTask;
1053    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1054    ///
1055    /// let builder = prepare_request_builder();
1056    /// let response = builder.send().await?;
1057    /// # Ok(()) }
1058    ///
1059    /// fn prepare_request_builder() -> GetTask {
1060    ///   # panic!();
1061    ///   // ... details omitted ...
1062    /// }
1063    /// ```
1064    #[derive(Clone, Debug)]
1065    pub struct GetTask(RequestBuilder<crate::model::GetTaskRequest>);
1066
1067    impl GetTask {
1068        pub(crate) fn new(
1069            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1070        ) -> Self {
1071            Self(RequestBuilder::new(stub))
1072        }
1073
1074        /// Sets the full request, replacing any prior values.
1075        pub fn with_request<V: Into<crate::model::GetTaskRequest>>(mut self, v: V) -> Self {
1076            self.0.request = v.into();
1077            self
1078        }
1079
1080        /// Sets all the options, replacing any prior values.
1081        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1082            self.0.options = v.into();
1083            self
1084        }
1085
1086        /// Sends the request.
1087        pub async fn send(self) -> Result<crate::model::Task> {
1088            (*self.0.stub)
1089                .get_task(self.0.request, self.0.options)
1090                .await
1091                .map(crate::Response::into_body)
1092        }
1093
1094        /// Sets the value of [name][crate::model::GetTaskRequest::name].
1095        ///
1096        /// This is a **required** field for requests.
1097        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1098            self.0.request.name = v.into();
1099            self
1100        }
1101
1102        /// Sets the value of [response_view][crate::model::GetTaskRequest::response_view].
1103        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1104            self.0.request.response_view = v.into();
1105            self
1106        }
1107    }
1108
1109    #[doc(hidden)]
1110    impl crate::RequestBuilder for GetTask {
1111        fn request_options(&mut self) -> &mut crate::RequestOptions {
1112            &mut self.0.options
1113        }
1114    }
1115
1116    /// The request builder for [CloudTasks::create_task][crate::client::CloudTasks::create_task] calls.
1117    ///
1118    /// # Example
1119    /// ```
1120    /// # use google_cloud_tasks_v2::builder::cloud_tasks::CreateTask;
1121    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1122    ///
1123    /// let builder = prepare_request_builder();
1124    /// let response = builder.send().await?;
1125    /// # Ok(()) }
1126    ///
1127    /// fn prepare_request_builder() -> CreateTask {
1128    ///   # panic!();
1129    ///   // ... details omitted ...
1130    /// }
1131    /// ```
1132    #[derive(Clone, Debug)]
1133    pub struct CreateTask(RequestBuilder<crate::model::CreateTaskRequest>);
1134
1135    impl CreateTask {
1136        pub(crate) fn new(
1137            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1138        ) -> Self {
1139            Self(RequestBuilder::new(stub))
1140        }
1141
1142        /// Sets the full request, replacing any prior values.
1143        pub fn with_request<V: Into<crate::model::CreateTaskRequest>>(mut self, v: V) -> Self {
1144            self.0.request = v.into();
1145            self
1146        }
1147
1148        /// Sets all the options, replacing any prior values.
1149        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1150            self.0.options = v.into();
1151            self
1152        }
1153
1154        /// Sends the request.
1155        pub async fn send(self) -> Result<crate::model::Task> {
1156            (*self.0.stub)
1157                .create_task(self.0.request, self.0.options)
1158                .await
1159                .map(crate::Response::into_body)
1160        }
1161
1162        /// Sets the value of [parent][crate::model::CreateTaskRequest::parent].
1163        ///
1164        /// This is a **required** field for requests.
1165        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1166            self.0.request.parent = v.into();
1167            self
1168        }
1169
1170        /// Sets the value of [task][crate::model::CreateTaskRequest::task].
1171        ///
1172        /// This is a **required** field for requests.
1173        pub fn set_task<T>(mut self, v: T) -> Self
1174        where
1175            T: std::convert::Into<crate::model::Task>,
1176        {
1177            self.0.request.task = std::option::Option::Some(v.into());
1178            self
1179        }
1180
1181        /// Sets or clears the value of [task][crate::model::CreateTaskRequest::task].
1182        ///
1183        /// This is a **required** field for requests.
1184        pub fn set_or_clear_task<T>(mut self, v: std::option::Option<T>) -> Self
1185        where
1186            T: std::convert::Into<crate::model::Task>,
1187        {
1188            self.0.request.task = v.map(|x| x.into());
1189            self
1190        }
1191
1192        /// Sets the value of [response_view][crate::model::CreateTaskRequest::response_view].
1193        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1194            self.0.request.response_view = v.into();
1195            self
1196        }
1197    }
1198
1199    #[doc(hidden)]
1200    impl crate::RequestBuilder for CreateTask {
1201        fn request_options(&mut self) -> &mut crate::RequestOptions {
1202            &mut self.0.options
1203        }
1204    }
1205
1206    /// The request builder for [CloudTasks::batch_create_tasks][crate::client::CloudTasks::batch_create_tasks] calls.
1207    ///
1208    /// # Example
1209    /// ```
1210    /// # use google_cloud_tasks_v2::builder::cloud_tasks::BatchCreateTasks;
1211    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1212    /// use google_cloud_lro::Poller;
1213    ///
1214    /// let builder = prepare_request_builder();
1215    /// let response = builder.poller().until_done().await?;
1216    /// # Ok(()) }
1217    ///
1218    /// fn prepare_request_builder() -> BatchCreateTasks {
1219    ///   # panic!();
1220    ///   // ... details omitted ...
1221    /// }
1222    /// ```
1223    #[derive(Clone, Debug)]
1224    pub struct BatchCreateTasks(RequestBuilder<crate::model::BatchCreateTasksRequest>);
1225
1226    impl BatchCreateTasks {
1227        pub(crate) fn new(
1228            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1229        ) -> Self {
1230            Self(RequestBuilder::new(stub))
1231        }
1232
1233        /// Sets the full request, replacing any prior values.
1234        pub fn with_request<V: Into<crate::model::BatchCreateTasksRequest>>(
1235            mut self,
1236            v: V,
1237        ) -> Self {
1238            self.0.request = v.into();
1239            self
1240        }
1241
1242        /// Sets all the options, replacing any prior values.
1243        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1244            self.0.options = v.into();
1245            self
1246        }
1247
1248        /// Sends the request.
1249        ///
1250        /// # Long running operations
1251        ///
1252        /// This starts, but does not poll, a longrunning operation. More information
1253        /// on [batch_create_tasks][crate::client::CloudTasks::batch_create_tasks].
1254        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1255            (*self.0.stub)
1256                .batch_create_tasks(self.0.request, self.0.options)
1257                .await
1258                .map(crate::Response::into_body)
1259        }
1260
1261        /// Creates a [Poller][google_cloud_lro::Poller] to work with `batch_create_tasks`.
1262        pub fn poller(
1263            self,
1264        ) -> impl google_cloud_lro::Poller<
1265            crate::model::BatchCreateTasksResponse,
1266            crate::model::BatchCreateTasksMetadata,
1267        > {
1268            type Operation = google_cloud_lro::internal::Operation<
1269                crate::model::BatchCreateTasksResponse,
1270                crate::model::BatchCreateTasksMetadata,
1271            >;
1272            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1273            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1274            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
1275            if let Some(ref mut details) = poller_options.tracing {
1276                details.method_name =
1277                    "google_cloud_tasks_v2::client::CloudTasks::batch_create_tasks::until_done";
1278            }
1279
1280            let stub = self.0.stub.clone();
1281            let mut options = self.0.options.clone();
1282            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1283            let query = move |name| {
1284                let stub = stub.clone();
1285                let options = options.clone();
1286                async {
1287                    let op = GetOperation::new(stub)
1288                        .set_name(name)
1289                        .with_options(options)
1290                        .send()
1291                        .await?;
1292                    Ok(Operation::new(op))
1293                }
1294            };
1295
1296            let start = move || async {
1297                let op = self.send().await?;
1298                Ok(Operation::new(op))
1299            };
1300
1301            use google_cloud_lro::internal::PollerExt;
1302            {
1303                google_cloud_lro::internal::new_poller(
1304                    polling_error_policy,
1305                    polling_backoff_policy,
1306                    start,
1307                    query,
1308                )
1309            }
1310            .with_options(poller_options)
1311        }
1312
1313        /// Sets the value of [parent][crate::model::BatchCreateTasksRequest::parent].
1314        ///
1315        /// This is a **required** field for requests.
1316        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1317            self.0.request.parent = v.into();
1318            self
1319        }
1320
1321        /// Sets the value of [requests][crate::model::BatchCreateTasksRequest::requests].
1322        ///
1323        /// This is a **required** field for requests.
1324        pub fn set_requests<T, V>(mut self, v: T) -> Self
1325        where
1326            T: std::iter::IntoIterator<Item = V>,
1327            V: std::convert::Into<crate::model::CreateTaskRequest>,
1328        {
1329            use std::iter::Iterator;
1330            self.0.request.requests = v.into_iter().map(|i| i.into()).collect();
1331            self
1332        }
1333
1334        /// Sets the value of [request_id][crate::model::BatchCreateTasksRequest::request_id].
1335        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1336            self.0.request.request_id = v.into();
1337            self
1338        }
1339    }
1340
1341    #[doc(hidden)]
1342    impl crate::RequestBuilder for BatchCreateTasks {
1343        fn request_options(&mut self) -> &mut crate::RequestOptions {
1344            &mut self.0.options
1345        }
1346    }
1347
1348    /// The request builder for [CloudTasks::delete_task][crate::client::CloudTasks::delete_task] calls.
1349    ///
1350    /// # Example
1351    /// ```
1352    /// # use google_cloud_tasks_v2::builder::cloud_tasks::DeleteTask;
1353    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1354    ///
1355    /// let builder = prepare_request_builder();
1356    /// let response = builder.send().await?;
1357    /// # Ok(()) }
1358    ///
1359    /// fn prepare_request_builder() -> DeleteTask {
1360    ///   # panic!();
1361    ///   // ... details omitted ...
1362    /// }
1363    /// ```
1364    #[derive(Clone, Debug)]
1365    pub struct DeleteTask(RequestBuilder<crate::model::DeleteTaskRequest>);
1366
1367    impl DeleteTask {
1368        pub(crate) fn new(
1369            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1370        ) -> Self {
1371            Self(RequestBuilder::new(stub))
1372        }
1373
1374        /// Sets the full request, replacing any prior values.
1375        pub fn with_request<V: Into<crate::model::DeleteTaskRequest>>(mut self, v: V) -> Self {
1376            self.0.request = v.into();
1377            self
1378        }
1379
1380        /// Sets all the options, replacing any prior values.
1381        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1382            self.0.options = v.into();
1383            self
1384        }
1385
1386        /// Sends the request.
1387        pub async fn send(self) -> Result<()> {
1388            (*self.0.stub)
1389                .delete_task(self.0.request, self.0.options)
1390                .await
1391                .map(crate::Response::into_body)
1392        }
1393
1394        /// Sets the value of [name][crate::model::DeleteTaskRequest::name].
1395        ///
1396        /// This is a **required** field for requests.
1397        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1398            self.0.request.name = v.into();
1399            self
1400        }
1401    }
1402
1403    #[doc(hidden)]
1404    impl crate::RequestBuilder for DeleteTask {
1405        fn request_options(&mut self) -> &mut crate::RequestOptions {
1406            &mut self.0.options
1407        }
1408    }
1409
1410    /// The request builder for [CloudTasks::batch_delete_tasks][crate::client::CloudTasks::batch_delete_tasks] calls.
1411    ///
1412    /// # Example
1413    /// ```
1414    /// # use google_cloud_tasks_v2::builder::cloud_tasks::BatchDeleteTasks;
1415    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1416    /// use google_cloud_lro::Poller;
1417    ///
1418    /// let builder = prepare_request_builder();
1419    /// let response = builder.poller().until_done().await?;
1420    /// # Ok(()) }
1421    ///
1422    /// fn prepare_request_builder() -> BatchDeleteTasks {
1423    ///   # panic!();
1424    ///   // ... details omitted ...
1425    /// }
1426    /// ```
1427    #[derive(Clone, Debug)]
1428    pub struct BatchDeleteTasks(RequestBuilder<crate::model::BatchDeleteTasksRequest>);
1429
1430    impl BatchDeleteTasks {
1431        pub(crate) fn new(
1432            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1433        ) -> Self {
1434            Self(RequestBuilder::new(stub))
1435        }
1436
1437        /// Sets the full request, replacing any prior values.
1438        pub fn with_request<V: Into<crate::model::BatchDeleteTasksRequest>>(
1439            mut self,
1440            v: V,
1441        ) -> Self {
1442            self.0.request = v.into();
1443            self
1444        }
1445
1446        /// Sets all the options, replacing any prior values.
1447        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1448            self.0.options = v.into();
1449            self
1450        }
1451
1452        /// Sends the request.
1453        ///
1454        /// # Long running operations
1455        ///
1456        /// This starts, but does not poll, a longrunning operation. More information
1457        /// on [batch_delete_tasks][crate::client::CloudTasks::batch_delete_tasks].
1458        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1459            (*self.0.stub)
1460                .batch_delete_tasks(self.0.request, self.0.options)
1461                .await
1462                .map(crate::Response::into_body)
1463        }
1464
1465        /// Creates a [Poller][google_cloud_lro::Poller] to work with `batch_delete_tasks`.
1466        pub fn poller(
1467            self,
1468        ) -> impl google_cloud_lro::Poller<(), crate::model::BatchDeleteTasksMetadata> {
1469            type Operation = google_cloud_lro::internal::Operation<
1470                wkt::Empty,
1471                crate::model::BatchDeleteTasksMetadata,
1472            >;
1473            let polling_error_policy = self.0.stub.get_polling_error_policy(&self.0.options);
1474            let polling_backoff_policy = self.0.stub.get_polling_backoff_policy(&self.0.options);
1475            let mut poller_options = self.0.stub.get_poller_options(&self.0.options);
1476            if let Some(ref mut details) = poller_options.tracing {
1477                details.method_name =
1478                    "google_cloud_tasks_v2::client::CloudTasks::batch_delete_tasks::until_done";
1479            }
1480
1481            let stub = self.0.stub.clone();
1482            let mut options = self.0.options.clone();
1483            options.set_retry_policy(google_cloud_gax::retry_policy::NeverRetry);
1484            let query = move |name| {
1485                let stub = stub.clone();
1486                let options = options.clone();
1487                async {
1488                    let op = GetOperation::new(stub)
1489                        .set_name(name)
1490                        .with_options(options)
1491                        .send()
1492                        .await?;
1493                    Ok(Operation::new(op))
1494                }
1495            };
1496
1497            let start = move || async {
1498                let op = self.send().await?;
1499                Ok(Operation::new(op))
1500            };
1501
1502            use google_cloud_lro::internal::PollerExt;
1503            {
1504                google_cloud_lro::internal::new_unit_response_poller(
1505                    polling_error_policy,
1506                    polling_backoff_policy,
1507                    start,
1508                    query,
1509                )
1510            }
1511            .with_options(poller_options)
1512        }
1513
1514        /// Sets the value of [parent][crate::model::BatchDeleteTasksRequest::parent].
1515        ///
1516        /// This is a **required** field for requests.
1517        pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1518            self.0.request.parent = v.into();
1519            self
1520        }
1521
1522        /// Sets the value of [names][crate::model::BatchDeleteTasksRequest::names].
1523        ///
1524        /// This is a **required** field for requests.
1525        pub fn set_names<T, V>(mut self, v: T) -> Self
1526        where
1527            T: std::iter::IntoIterator<Item = V>,
1528            V: std::convert::Into<std::string::String>,
1529        {
1530            use std::iter::Iterator;
1531            self.0.request.names = v.into_iter().map(|i| i.into()).collect();
1532            self
1533        }
1534
1535        /// Sets the value of [request_id][crate::model::BatchDeleteTasksRequest::request_id].
1536        pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
1537            self.0.request.request_id = v.into();
1538            self
1539        }
1540    }
1541
1542    #[doc(hidden)]
1543    impl crate::RequestBuilder for BatchDeleteTasks {
1544        fn request_options(&mut self) -> &mut crate::RequestOptions {
1545            &mut self.0.options
1546        }
1547    }
1548
1549    /// The request builder for [CloudTasks::run_task][crate::client::CloudTasks::run_task] calls.
1550    ///
1551    /// # Example
1552    /// ```
1553    /// # use google_cloud_tasks_v2::builder::cloud_tasks::RunTask;
1554    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1555    ///
1556    /// let builder = prepare_request_builder();
1557    /// let response = builder.send().await?;
1558    /// # Ok(()) }
1559    ///
1560    /// fn prepare_request_builder() -> RunTask {
1561    ///   # panic!();
1562    ///   // ... details omitted ...
1563    /// }
1564    /// ```
1565    #[derive(Clone, Debug)]
1566    pub struct RunTask(RequestBuilder<crate::model::RunTaskRequest>);
1567
1568    impl RunTask {
1569        pub(crate) fn new(
1570            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1571        ) -> Self {
1572            Self(RequestBuilder::new(stub))
1573        }
1574
1575        /// Sets the full request, replacing any prior values.
1576        pub fn with_request<V: Into<crate::model::RunTaskRequest>>(mut self, v: V) -> Self {
1577            self.0.request = v.into();
1578            self
1579        }
1580
1581        /// Sets all the options, replacing any prior values.
1582        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1583            self.0.options = v.into();
1584            self
1585        }
1586
1587        /// Sends the request.
1588        pub async fn send(self) -> Result<crate::model::Task> {
1589            (*self.0.stub)
1590                .run_task(self.0.request, self.0.options)
1591                .await
1592                .map(crate::Response::into_body)
1593        }
1594
1595        /// Sets the value of [name][crate::model::RunTaskRequest::name].
1596        ///
1597        /// This is a **required** field for requests.
1598        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1599            self.0.request.name = v.into();
1600            self
1601        }
1602
1603        /// Sets the value of [response_view][crate::model::RunTaskRequest::response_view].
1604        pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1605            self.0.request.response_view = v.into();
1606            self
1607        }
1608    }
1609
1610    #[doc(hidden)]
1611    impl crate::RequestBuilder for RunTask {
1612        fn request_options(&mut self) -> &mut crate::RequestOptions {
1613            &mut self.0.options
1614        }
1615    }
1616
1617    /// The request builder for [CloudTasks::update_cmek_config][crate::client::CloudTasks::update_cmek_config] calls.
1618    ///
1619    /// # Example
1620    /// ```
1621    /// # use google_cloud_tasks_v2::builder::cloud_tasks::UpdateCmekConfig;
1622    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1623    ///
1624    /// let builder = prepare_request_builder();
1625    /// let response = builder.send().await?;
1626    /// # Ok(()) }
1627    ///
1628    /// fn prepare_request_builder() -> UpdateCmekConfig {
1629    ///   # panic!();
1630    ///   // ... details omitted ...
1631    /// }
1632    /// ```
1633    #[derive(Clone, Debug)]
1634    pub struct UpdateCmekConfig(RequestBuilder<crate::model::UpdateCmekConfigRequest>);
1635
1636    impl UpdateCmekConfig {
1637        pub(crate) fn new(
1638            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1639        ) -> Self {
1640            Self(RequestBuilder::new(stub))
1641        }
1642
1643        /// Sets the full request, replacing any prior values.
1644        pub fn with_request<V: Into<crate::model::UpdateCmekConfigRequest>>(
1645            mut self,
1646            v: V,
1647        ) -> Self {
1648            self.0.request = v.into();
1649            self
1650        }
1651
1652        /// Sets all the options, replacing any prior values.
1653        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1654            self.0.options = v.into();
1655            self
1656        }
1657
1658        /// Sends the request.
1659        pub async fn send(self) -> Result<crate::model::CmekConfig> {
1660            (*self.0.stub)
1661                .update_cmek_config(self.0.request, self.0.options)
1662                .await
1663                .map(crate::Response::into_body)
1664        }
1665
1666        /// Sets the value of [cmek_config][crate::model::UpdateCmekConfigRequest::cmek_config].
1667        ///
1668        /// This is a **required** field for requests.
1669        pub fn set_cmek_config<T>(mut self, v: T) -> Self
1670        where
1671            T: std::convert::Into<crate::model::CmekConfig>,
1672        {
1673            self.0.request.cmek_config = std::option::Option::Some(v.into());
1674            self
1675        }
1676
1677        /// Sets or clears the value of [cmek_config][crate::model::UpdateCmekConfigRequest::cmek_config].
1678        ///
1679        /// This is a **required** field for requests.
1680        pub fn set_or_clear_cmek_config<T>(mut self, v: std::option::Option<T>) -> Self
1681        where
1682            T: std::convert::Into<crate::model::CmekConfig>,
1683        {
1684            self.0.request.cmek_config = v.map(|x| x.into());
1685            self
1686        }
1687
1688        /// Sets the value of [update_mask][crate::model::UpdateCmekConfigRequest::update_mask].
1689        pub fn set_update_mask<T>(mut self, v: T) -> Self
1690        where
1691            T: std::convert::Into<wkt::FieldMask>,
1692        {
1693            self.0.request.update_mask = std::option::Option::Some(v.into());
1694            self
1695        }
1696
1697        /// Sets or clears the value of [update_mask][crate::model::UpdateCmekConfigRequest::update_mask].
1698        pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1699        where
1700            T: std::convert::Into<wkt::FieldMask>,
1701        {
1702            self.0.request.update_mask = v.map(|x| x.into());
1703            self
1704        }
1705    }
1706
1707    #[doc(hidden)]
1708    impl crate::RequestBuilder for UpdateCmekConfig {
1709        fn request_options(&mut self) -> &mut crate::RequestOptions {
1710            &mut self.0.options
1711        }
1712    }
1713
1714    /// The request builder for [CloudTasks::get_cmek_config][crate::client::CloudTasks::get_cmek_config] calls.
1715    ///
1716    /// # Example
1717    /// ```
1718    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetCmekConfig;
1719    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1720    ///
1721    /// let builder = prepare_request_builder();
1722    /// let response = builder.send().await?;
1723    /// # Ok(()) }
1724    ///
1725    /// fn prepare_request_builder() -> GetCmekConfig {
1726    ///   # panic!();
1727    ///   // ... details omitted ...
1728    /// }
1729    /// ```
1730    #[derive(Clone, Debug)]
1731    pub struct GetCmekConfig(RequestBuilder<crate::model::GetCmekConfigRequest>);
1732
1733    impl GetCmekConfig {
1734        pub(crate) fn new(
1735            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1736        ) -> Self {
1737            Self(RequestBuilder::new(stub))
1738        }
1739
1740        /// Sets the full request, replacing any prior values.
1741        pub fn with_request<V: Into<crate::model::GetCmekConfigRequest>>(mut self, v: V) -> Self {
1742            self.0.request = v.into();
1743            self
1744        }
1745
1746        /// Sets all the options, replacing any prior values.
1747        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1748            self.0.options = v.into();
1749            self
1750        }
1751
1752        /// Sends the request.
1753        pub async fn send(self) -> Result<crate::model::CmekConfig> {
1754            (*self.0.stub)
1755                .get_cmek_config(self.0.request, self.0.options)
1756                .await
1757                .map(crate::Response::into_body)
1758        }
1759
1760        /// Sets the value of [name][crate::model::GetCmekConfigRequest::name].
1761        ///
1762        /// This is a **required** field for requests.
1763        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1764            self.0.request.name = v.into();
1765            self
1766        }
1767    }
1768
1769    #[doc(hidden)]
1770    impl crate::RequestBuilder for GetCmekConfig {
1771        fn request_options(&mut self) -> &mut crate::RequestOptions {
1772            &mut self.0.options
1773        }
1774    }
1775
1776    /// The request builder for [CloudTasks::list_locations][crate::client::CloudTasks::list_locations] calls.
1777    ///
1778    /// # Example
1779    /// ```
1780    /// # use google_cloud_tasks_v2::builder::cloud_tasks::ListLocations;
1781    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1782    /// use google_cloud_gax::paginator::ItemPaginator;
1783    ///
1784    /// let builder = prepare_request_builder();
1785    /// let mut items = builder.by_item();
1786    /// while let Some(result) = items.next().await {
1787    ///   let item = result?;
1788    /// }
1789    /// # Ok(()) }
1790    ///
1791    /// fn prepare_request_builder() -> ListLocations {
1792    ///   # panic!();
1793    ///   // ... details omitted ...
1794    /// }
1795    /// ```
1796    #[derive(Clone, Debug)]
1797    pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
1798
1799    impl ListLocations {
1800        pub(crate) fn new(
1801            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1802        ) -> Self {
1803            Self(RequestBuilder::new(stub))
1804        }
1805
1806        /// Sets the full request, replacing any prior values.
1807        pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
1808            mut self,
1809            v: V,
1810        ) -> Self {
1811            self.0.request = v.into();
1812            self
1813        }
1814
1815        /// Sets all the options, replacing any prior values.
1816        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1817            self.0.options = v.into();
1818            self
1819        }
1820
1821        /// Sends the request.
1822        pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
1823            (*self.0.stub)
1824                .list_locations(self.0.request, self.0.options)
1825                .await
1826                .map(crate::Response::into_body)
1827        }
1828
1829        /// Streams each page in the collection.
1830        pub fn by_page(
1831            self,
1832        ) -> impl google_cloud_gax::paginator::Paginator<
1833            google_cloud_location::model::ListLocationsResponse,
1834            crate::Error,
1835        > {
1836            use std::clone::Clone;
1837            let token = self.0.request.page_token.clone();
1838            let execute = move |token: String| {
1839                let mut builder = self.clone();
1840                builder.0.request = builder.0.request.set_page_token(token);
1841                builder.send()
1842            };
1843            google_cloud_gax::paginator::internal::new_paginator(token, execute)
1844        }
1845
1846        /// Streams each item in the collection.
1847        pub fn by_item(
1848            self,
1849        ) -> impl google_cloud_gax::paginator::ItemPaginator<
1850            google_cloud_location::model::ListLocationsResponse,
1851            crate::Error,
1852        > {
1853            use google_cloud_gax::paginator::Paginator;
1854            self.by_page().items()
1855        }
1856
1857        /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
1858        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1859            self.0.request.name = v.into();
1860            self
1861        }
1862
1863        /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
1864        pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1865            self.0.request.filter = v.into();
1866            self
1867        }
1868
1869        /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
1870        pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1871            self.0.request.page_size = v.into();
1872            self
1873        }
1874
1875        /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
1876        pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1877            self.0.request.page_token = v.into();
1878            self
1879        }
1880    }
1881
1882    #[doc(hidden)]
1883    impl crate::RequestBuilder for ListLocations {
1884        fn request_options(&mut self) -> &mut crate::RequestOptions {
1885            &mut self.0.options
1886        }
1887    }
1888
1889    /// The request builder for [CloudTasks::get_location][crate::client::CloudTasks::get_location] calls.
1890    ///
1891    /// # Example
1892    /// ```
1893    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetLocation;
1894    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1895    ///
1896    /// let builder = prepare_request_builder();
1897    /// let response = builder.send().await?;
1898    /// # Ok(()) }
1899    ///
1900    /// fn prepare_request_builder() -> GetLocation {
1901    ///   # panic!();
1902    ///   // ... details omitted ...
1903    /// }
1904    /// ```
1905    #[derive(Clone, Debug)]
1906    pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
1907
1908    impl GetLocation {
1909        pub(crate) fn new(
1910            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1911        ) -> Self {
1912            Self(RequestBuilder::new(stub))
1913        }
1914
1915        /// Sets the full request, replacing any prior values.
1916        pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
1917            mut self,
1918            v: V,
1919        ) -> Self {
1920            self.0.request = v.into();
1921            self
1922        }
1923
1924        /// Sets all the options, replacing any prior values.
1925        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1926            self.0.options = v.into();
1927            self
1928        }
1929
1930        /// Sends the request.
1931        pub async fn send(self) -> Result<google_cloud_location::model::Location> {
1932            (*self.0.stub)
1933                .get_location(self.0.request, self.0.options)
1934                .await
1935                .map(crate::Response::into_body)
1936        }
1937
1938        /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
1939        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1940            self.0.request.name = v.into();
1941            self
1942        }
1943    }
1944
1945    #[doc(hidden)]
1946    impl crate::RequestBuilder for GetLocation {
1947        fn request_options(&mut self) -> &mut crate::RequestOptions {
1948            &mut self.0.options
1949        }
1950    }
1951
1952    /// The request builder for [CloudTasks::get_operation][crate::client::CloudTasks::get_operation] calls.
1953    ///
1954    /// # Example
1955    /// ```
1956    /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetOperation;
1957    /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1958    ///
1959    /// let builder = prepare_request_builder();
1960    /// let response = builder.send().await?;
1961    /// # Ok(()) }
1962    ///
1963    /// fn prepare_request_builder() -> GetOperation {
1964    ///   # panic!();
1965    ///   // ... details omitted ...
1966    /// }
1967    /// ```
1968    #[derive(Clone, Debug)]
1969    pub struct GetOperation(RequestBuilder<google_cloud_longrunning::model::GetOperationRequest>);
1970
1971    impl GetOperation {
1972        pub(crate) fn new(
1973            stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1974        ) -> Self {
1975            Self(RequestBuilder::new(stub))
1976        }
1977
1978        /// Sets the full request, replacing any prior values.
1979        pub fn with_request<V: Into<google_cloud_longrunning::model::GetOperationRequest>>(
1980            mut self,
1981            v: V,
1982        ) -> Self {
1983            self.0.request = v.into();
1984            self
1985        }
1986
1987        /// Sets all the options, replacing any prior values.
1988        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1989            self.0.options = v.into();
1990            self
1991        }
1992
1993        /// Sends the request.
1994        pub async fn send(self) -> Result<google_cloud_longrunning::model::Operation> {
1995            (*self.0.stub)
1996                .get_operation(self.0.request, self.0.options)
1997                .await
1998                .map(crate::Response::into_body)
1999        }
2000
2001        /// Sets the value of [name][google_cloud_longrunning::model::GetOperationRequest::name].
2002        pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
2003            self.0.request.name = v.into();
2004            self
2005        }
2006    }
2007
2008    #[doc(hidden)]
2009    impl crate::RequestBuilder for GetOperation {
2010        fn request_options(&mut self) -> &mut crate::RequestOptions {
2011            &mut self.0.options
2012        }
2013    }
2014}