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::delete_task][crate::client::CloudTasks::delete_task] calls.
1207 ///
1208 /// # Example
1209 /// ```
1210 /// # use google_cloud_tasks_v2::builder::cloud_tasks::DeleteTask;
1211 /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1212 ///
1213 /// let builder = prepare_request_builder();
1214 /// let response = builder.send().await?;
1215 /// # Ok(()) }
1216 ///
1217 /// fn prepare_request_builder() -> DeleteTask {
1218 /// # panic!();
1219 /// // ... details omitted ...
1220 /// }
1221 /// ```
1222 #[derive(Clone, Debug)]
1223 pub struct DeleteTask(RequestBuilder<crate::model::DeleteTaskRequest>);
1224
1225 impl DeleteTask {
1226 pub(crate) fn new(
1227 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1228 ) -> Self {
1229 Self(RequestBuilder::new(stub))
1230 }
1231
1232 /// Sets the full request, replacing any prior values.
1233 pub fn with_request<V: Into<crate::model::DeleteTaskRequest>>(mut self, v: V) -> Self {
1234 self.0.request = v.into();
1235 self
1236 }
1237
1238 /// Sets all the options, replacing any prior values.
1239 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1240 self.0.options = v.into();
1241 self
1242 }
1243
1244 /// Sends the request.
1245 pub async fn send(self) -> Result<()> {
1246 (*self.0.stub)
1247 .delete_task(self.0.request, self.0.options)
1248 .await
1249 .map(crate::Response::into_body)
1250 }
1251
1252 /// Sets the value of [name][crate::model::DeleteTaskRequest::name].
1253 ///
1254 /// This is a **required** field for requests.
1255 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1256 self.0.request.name = v.into();
1257 self
1258 }
1259 }
1260
1261 #[doc(hidden)]
1262 impl crate::RequestBuilder for DeleteTask {
1263 fn request_options(&mut self) -> &mut crate::RequestOptions {
1264 &mut self.0.options
1265 }
1266 }
1267
1268 /// The request builder for [CloudTasks::run_task][crate::client::CloudTasks::run_task] calls.
1269 ///
1270 /// # Example
1271 /// ```
1272 /// # use google_cloud_tasks_v2::builder::cloud_tasks::RunTask;
1273 /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1274 ///
1275 /// let builder = prepare_request_builder();
1276 /// let response = builder.send().await?;
1277 /// # Ok(()) }
1278 ///
1279 /// fn prepare_request_builder() -> RunTask {
1280 /// # panic!();
1281 /// // ... details omitted ...
1282 /// }
1283 /// ```
1284 #[derive(Clone, Debug)]
1285 pub struct RunTask(RequestBuilder<crate::model::RunTaskRequest>);
1286
1287 impl RunTask {
1288 pub(crate) fn new(
1289 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1290 ) -> Self {
1291 Self(RequestBuilder::new(stub))
1292 }
1293
1294 /// Sets the full request, replacing any prior values.
1295 pub fn with_request<V: Into<crate::model::RunTaskRequest>>(mut self, v: V) -> Self {
1296 self.0.request = v.into();
1297 self
1298 }
1299
1300 /// Sets all the options, replacing any prior values.
1301 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1302 self.0.options = v.into();
1303 self
1304 }
1305
1306 /// Sends the request.
1307 pub async fn send(self) -> Result<crate::model::Task> {
1308 (*self.0.stub)
1309 .run_task(self.0.request, self.0.options)
1310 .await
1311 .map(crate::Response::into_body)
1312 }
1313
1314 /// Sets the value of [name][crate::model::RunTaskRequest::name].
1315 ///
1316 /// This is a **required** field for requests.
1317 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1318 self.0.request.name = v.into();
1319 self
1320 }
1321
1322 /// Sets the value of [response_view][crate::model::RunTaskRequest::response_view].
1323 pub fn set_response_view<T: Into<crate::model::task::View>>(mut self, v: T) -> Self {
1324 self.0.request.response_view = v.into();
1325 self
1326 }
1327 }
1328
1329 #[doc(hidden)]
1330 impl crate::RequestBuilder for RunTask {
1331 fn request_options(&mut self) -> &mut crate::RequestOptions {
1332 &mut self.0.options
1333 }
1334 }
1335
1336 /// The request builder for [CloudTasks::list_locations][crate::client::CloudTasks::list_locations] calls.
1337 ///
1338 /// # Example
1339 /// ```
1340 /// # use google_cloud_tasks_v2::builder::cloud_tasks::ListLocations;
1341 /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1342 /// use google_cloud_gax::paginator::ItemPaginator;
1343 ///
1344 /// let builder = prepare_request_builder();
1345 /// let mut items = builder.by_item();
1346 /// while let Some(result) = items.next().await {
1347 /// let item = result?;
1348 /// }
1349 /// # Ok(()) }
1350 ///
1351 /// fn prepare_request_builder() -> ListLocations {
1352 /// # panic!();
1353 /// // ... details omitted ...
1354 /// }
1355 /// ```
1356 #[derive(Clone, Debug)]
1357 pub struct ListLocations(RequestBuilder<google_cloud_location::model::ListLocationsRequest>);
1358
1359 impl ListLocations {
1360 pub(crate) fn new(
1361 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1362 ) -> Self {
1363 Self(RequestBuilder::new(stub))
1364 }
1365
1366 /// Sets the full request, replacing any prior values.
1367 pub fn with_request<V: Into<google_cloud_location::model::ListLocationsRequest>>(
1368 mut self,
1369 v: V,
1370 ) -> Self {
1371 self.0.request = v.into();
1372 self
1373 }
1374
1375 /// Sets all the options, replacing any prior values.
1376 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1377 self.0.options = v.into();
1378 self
1379 }
1380
1381 /// Sends the request.
1382 pub async fn send(self) -> Result<google_cloud_location::model::ListLocationsResponse> {
1383 (*self.0.stub)
1384 .list_locations(self.0.request, self.0.options)
1385 .await
1386 .map(crate::Response::into_body)
1387 }
1388
1389 /// Streams each page in the collection.
1390 pub fn by_page(
1391 self,
1392 ) -> impl google_cloud_gax::paginator::Paginator<
1393 google_cloud_location::model::ListLocationsResponse,
1394 crate::Error,
1395 > {
1396 use std::clone::Clone;
1397 let token = self.0.request.page_token.clone();
1398 let execute = move |token: String| {
1399 let mut builder = self.clone();
1400 builder.0.request = builder.0.request.set_page_token(token);
1401 builder.send()
1402 };
1403 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1404 }
1405
1406 /// Streams each item in the collection.
1407 pub fn by_item(
1408 self,
1409 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1410 google_cloud_location::model::ListLocationsResponse,
1411 crate::Error,
1412 > {
1413 use google_cloud_gax::paginator::Paginator;
1414 self.by_page().items()
1415 }
1416
1417 /// Sets the value of [name][google_cloud_location::model::ListLocationsRequest::name].
1418 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1419 self.0.request.name = v.into();
1420 self
1421 }
1422
1423 /// Sets the value of [filter][google_cloud_location::model::ListLocationsRequest::filter].
1424 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1425 self.0.request.filter = v.into();
1426 self
1427 }
1428
1429 /// Sets the value of [page_size][google_cloud_location::model::ListLocationsRequest::page_size].
1430 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1431 self.0.request.page_size = v.into();
1432 self
1433 }
1434
1435 /// Sets the value of [page_token][google_cloud_location::model::ListLocationsRequest::page_token].
1436 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1437 self.0.request.page_token = v.into();
1438 self
1439 }
1440 }
1441
1442 #[doc(hidden)]
1443 impl crate::RequestBuilder for ListLocations {
1444 fn request_options(&mut self) -> &mut crate::RequestOptions {
1445 &mut self.0.options
1446 }
1447 }
1448
1449 /// The request builder for [CloudTasks::get_location][crate::client::CloudTasks::get_location] calls.
1450 ///
1451 /// # Example
1452 /// ```
1453 /// # use google_cloud_tasks_v2::builder::cloud_tasks::GetLocation;
1454 /// # async fn sample() -> google_cloud_tasks_v2::Result<()> {
1455 ///
1456 /// let builder = prepare_request_builder();
1457 /// let response = builder.send().await?;
1458 /// # Ok(()) }
1459 ///
1460 /// fn prepare_request_builder() -> GetLocation {
1461 /// # panic!();
1462 /// // ... details omitted ...
1463 /// }
1464 /// ```
1465 #[derive(Clone, Debug)]
1466 pub struct GetLocation(RequestBuilder<google_cloud_location::model::GetLocationRequest>);
1467
1468 impl GetLocation {
1469 pub(crate) fn new(
1470 stub: std::sync::Arc<dyn super::super::stub::dynamic::CloudTasks>,
1471 ) -> Self {
1472 Self(RequestBuilder::new(stub))
1473 }
1474
1475 /// Sets the full request, replacing any prior values.
1476 pub fn with_request<V: Into<google_cloud_location::model::GetLocationRequest>>(
1477 mut self,
1478 v: V,
1479 ) -> Self {
1480 self.0.request = v.into();
1481 self
1482 }
1483
1484 /// Sets all the options, replacing any prior values.
1485 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1486 self.0.options = v.into();
1487 self
1488 }
1489
1490 /// Sends the request.
1491 pub async fn send(self) -> Result<google_cloud_location::model::Location> {
1492 (*self.0.stub)
1493 .get_location(self.0.request, self.0.options)
1494 .await
1495 .map(crate::Response::into_body)
1496 }
1497
1498 /// Sets the value of [name][google_cloud_location::model::GetLocationRequest::name].
1499 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1500 self.0.request.name = v.into();
1501 self
1502 }
1503 }
1504
1505 #[doc(hidden)]
1506 impl crate::RequestBuilder for GetLocation {
1507 fn request_options(&mut self) -> &mut crate::RequestOptions {
1508 &mut self.0.options
1509 }
1510 }
1511}