Skip to main content

google_cloud_tasks_v2/
client.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#![allow(rustdoc::redundant_explicit_links)]
17#![allow(rustdoc::broken_intra_doc_links)]
18
19/// Implements a client for the Cloud Tasks API.
20///
21/// # Example
22/// ```
23/// # use google_cloud_tasks_v2::client::CloudTasks;
24/// use google_cloud_gax::paginator::ItemPaginator as _;
25/// # async fn sample() -> Result<(), Box<dyn std::error::Error>> {
26///     let client = CloudTasks::builder().build().await?;
27///     let parent = "parent_value";
28///     let mut list = client.list_queues()
29///         .set_parent(parent)
30///         .by_item();
31///     while let Some(item) = list.next().await.transpose()? {
32///         println!("{:?}", item);
33///     }
34/// # Ok(()) }
35/// ```
36///
37/// # Service Description
38///
39/// Cloud Tasks allows developers to manage the execution of background
40/// work in their applications.
41///
42/// # Configuration
43///
44/// To configure `CloudTasks` use the `with_*` methods in the type returned
45/// by [builder()][CloudTasks::builder]. The default configuration should
46/// work for most applications. Common configuration changes include
47///
48/// * [with_endpoint()]: by default this client uses the global default endpoint
49///   (`https://cloudtasks.googleapis.com`). Applications using regional
50///   endpoints or running in restricted networks (e.g. a network configured
51//    with [Private Google Access with VPC Service Controls]) may want to
52///   override this default.
53/// * [with_credentials()]: by default this client uses
54///   [Application Default Credentials]. Applications using custom
55///   authentication may need to override this default.
56///
57/// [with_endpoint()]: super::builder::cloud_tasks::ClientBuilder::with_endpoint
58/// [with_credentials()]: super::builder::cloud_tasks::ClientBuilder::with_credentials
59/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
60/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
61///
62/// # Pooling and Cloning
63///
64/// `CloudTasks` holds a connection pool internally, it is advised to
65/// create one and reuse it. You do not need to wrap `CloudTasks` in
66/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
67/// already uses an `Arc` internally.
68#[derive(Clone, Debug)]
69pub struct CloudTasks {
70    inner: std::sync::Arc<dyn super::stub::dynamic::CloudTasks>,
71}
72
73impl CloudTasks {
74    /// Returns a builder for [CloudTasks].
75    ///
76    /// ```
77    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
78    /// # use google_cloud_tasks_v2::client::CloudTasks;
79    /// let client = CloudTasks::builder().build().await?;
80    /// # Ok(()) }
81    /// ```
82    pub fn builder() -> super::builder::cloud_tasks::ClientBuilder {
83        crate::new_client_builder(super::builder::cloud_tasks::client::Factory)
84    }
85
86    /// Creates a new client from the provided stub.
87    ///
88    /// The most common case for calling this function is in tests mocking the
89    /// client's behavior.
90    pub fn from_stub<T>(stub: T) -> Self
91    where
92        T: super::stub::CloudTasks + 'static,
93    {
94        Self {
95            inner: std::sync::Arc::new(stub),
96        }
97    }
98
99    pub(crate) async fn new(
100        config: gaxi::options::ClientConfig,
101    ) -> crate::ClientBuilderResult<Self> {
102        let inner = Self::build_inner(config).await?;
103        Ok(Self { inner })
104    }
105
106    async fn build_inner(
107        conf: gaxi::options::ClientConfig,
108    ) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::CloudTasks>> {
109        if gaxi::options::tracing_enabled(&conf) {
110            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
111        }
112        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
113    }
114
115    async fn build_transport(
116        conf: gaxi::options::ClientConfig,
117    ) -> crate::ClientBuilderResult<impl super::stub::CloudTasks> {
118        super::transport::CloudTasks::new(conf).await
119    }
120
121    async fn build_with_tracing(
122        conf: gaxi::options::ClientConfig,
123    ) -> crate::ClientBuilderResult<impl super::stub::CloudTasks> {
124        Self::build_transport(conf)
125            .await
126            .map(super::tracing::CloudTasks::new)
127    }
128
129    /// Lists queues.
130    ///
131    /// Queues are returned in lexicographical order.
132    ///
133    /// # Example
134    /// ```
135    /// # use google_cloud_tasks_v2::client::CloudTasks;
136    /// use google_cloud_gax::paginator::ItemPaginator as _;
137    /// use google_cloud_tasks_v2::Result;
138    /// async fn sample(
139    ///    client: &CloudTasks, parent: &str
140    /// ) -> Result<()> {
141    ///     let mut list = client.list_queues()
142    ///         .set_parent(parent)
143    ///         .by_item();
144    ///     while let Some(item) = list.next().await.transpose()? {
145    ///         println!("{:?}", item);
146    ///     }
147    ///     Ok(())
148    /// }
149    /// ```
150    pub fn list_queues(&self) -> super::builder::cloud_tasks::ListQueues {
151        super::builder::cloud_tasks::ListQueues::new(self.inner.clone())
152    }
153
154    /// Gets a queue.
155    ///
156    /// # Example
157    /// ```
158    /// # use google_cloud_tasks_v2::client::CloudTasks;
159    /// use google_cloud_tasks_v2::Result;
160    /// async fn sample(
161    ///    client: &CloudTasks, name: &str
162    /// ) -> Result<()> {
163    ///     let response = client.get_queue()
164    ///         .set_name(name)
165    ///         .send().await?;
166    ///     println!("response {:?}", response);
167    ///     Ok(())
168    /// }
169    /// ```
170    pub fn get_queue(&self) -> super::builder::cloud_tasks::GetQueue {
171        super::builder::cloud_tasks::GetQueue::new(self.inner.clone())
172    }
173
174    /// Creates a queue.
175    ///
176    /// Queues created with this method allow tasks to live for a maximum of 31
177    /// days. After a task is 31 days old, the task will be deleted regardless of
178    /// whether it was dispatched or not.
179    ///
180    /// WARNING: Using this method may have unintended side effects if you are
181    /// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
182    /// Read
183    /// [Overview of Queue Management and
184    /// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
185    /// this method.
186    ///
187    /// # Example
188    /// ```
189    /// # use google_cloud_tasks_v2::client::CloudTasks;
190    /// use google_cloud_tasks_v2::model::Queue;
191    /// use google_cloud_tasks_v2::Result;
192    /// async fn sample(
193    ///    client: &CloudTasks, parent: &str
194    /// ) -> Result<()> {
195    ///     let response = client.create_queue()
196    ///         .set_parent(parent)
197    ///         .set_queue(
198    ///             Queue::new()/* set fields */
199    ///         )
200    ///         .send().await?;
201    ///     println!("response {:?}", response);
202    ///     Ok(())
203    /// }
204    /// ```
205    pub fn create_queue(&self) -> super::builder::cloud_tasks::CreateQueue {
206        super::builder::cloud_tasks::CreateQueue::new(self.inner.clone())
207    }
208
209    /// Updates a queue.
210    ///
211    /// This method creates the queue if it does not exist and updates
212    /// the queue if it does exist.
213    ///
214    /// Queues created with this method allow tasks to live for a maximum of 31
215    /// days. After a task is 31 days old, the task will be deleted regardless of
216    /// whether it was dispatched or not.
217    ///
218    /// WARNING: Using this method may have unintended side effects if you are
219    /// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
220    /// Read
221    /// [Overview of Queue Management and
222    /// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
223    /// this method.
224    ///
225    /// # Example
226    /// ```
227    /// # use google_cloud_tasks_v2::client::CloudTasks;
228    /// # extern crate wkt as google_cloud_wkt;
229    /// use google_cloud_wkt::FieldMask;
230    /// use google_cloud_tasks_v2::model::Queue;
231    /// use google_cloud_tasks_v2::Result;
232    /// async fn sample(
233    ///    client: &CloudTasks, name: &str
234    /// ) -> Result<()> {
235    ///     let response = client.update_queue()
236    ///         .set_queue(
237    ///             Queue::new().set_name(name)/* set fields */
238    ///         )
239    ///         .set_update_mask(FieldMask::default().set_paths(["updated.field.path1", "updated.field.path2"]))
240    ///         .send().await?;
241    ///     println!("response {:?}", response);
242    ///     Ok(())
243    /// }
244    /// ```
245    pub fn update_queue(&self) -> super::builder::cloud_tasks::UpdateQueue {
246        super::builder::cloud_tasks::UpdateQueue::new(self.inner.clone())
247    }
248
249    /// Deletes a queue.
250    ///
251    /// This command will delete the queue even if it has tasks in it.
252    ///
253    /// Note: If you delete a queue, a queue with the same name can't be created
254    /// for 7 days.
255    ///
256    /// WARNING: Using this method may have unintended side effects if you are
257    /// using an App Engine `queue.yaml` or `queue.xml` file to manage your queues.
258    /// Read
259    /// [Overview of Queue Management and
260    /// queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using
261    /// this method.
262    ///
263    /// # Example
264    /// ```
265    /// # use google_cloud_tasks_v2::client::CloudTasks;
266    /// use google_cloud_tasks_v2::Result;
267    /// async fn sample(
268    ///    client: &CloudTasks, name: &str
269    /// ) -> Result<()> {
270    ///     client.delete_queue()
271    ///         .set_name(name)
272    ///         .send().await?;
273    ///     Ok(())
274    /// }
275    /// ```
276    pub fn delete_queue(&self) -> super::builder::cloud_tasks::DeleteQueue {
277        super::builder::cloud_tasks::DeleteQueue::new(self.inner.clone())
278    }
279
280    /// Purges a queue by deleting all of its tasks.
281    ///
282    /// All tasks created before this method is called are permanently deleted.
283    ///
284    /// Purge operations can take up to one minute to take effect. Tasks
285    /// might be dispatched before the purge takes effect. A purge is irreversible.
286    ///
287    /// # Example
288    /// ```
289    /// # use google_cloud_tasks_v2::client::CloudTasks;
290    /// use google_cloud_tasks_v2::Result;
291    /// async fn sample(
292    ///    client: &CloudTasks
293    /// ) -> Result<()> {
294    ///     let response = client.purge_queue()
295    ///         /* set fields */
296    ///         .send().await?;
297    ///     println!("response {:?}", response);
298    ///     Ok(())
299    /// }
300    /// ```
301    pub fn purge_queue(&self) -> super::builder::cloud_tasks::PurgeQueue {
302        super::builder::cloud_tasks::PurgeQueue::new(self.inner.clone())
303    }
304
305    /// Pauses the queue.
306    ///
307    /// If a queue is paused then the system will stop dispatching tasks
308    /// until the queue is resumed via
309    /// [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. Tasks can
310    /// still be added when the queue is paused. A queue is paused if its
311    /// [state][google.cloud.tasks.v2.Queue.state] is
312    /// [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED].
313    ///
314    /// [google.cloud.tasks.v2.CloudTasks.ResumeQueue]: crate::client::CloudTasks::resume_queue
315    /// [google.cloud.tasks.v2.Queue.State.PAUSED]: crate::model::queue::State::Paused
316    /// [google.cloud.tasks.v2.Queue.state]: crate::model::Queue::state
317    ///
318    /// # Example
319    /// ```
320    /// # use google_cloud_tasks_v2::client::CloudTasks;
321    /// use google_cloud_tasks_v2::Result;
322    /// async fn sample(
323    ///    client: &CloudTasks
324    /// ) -> Result<()> {
325    ///     let response = client.pause_queue()
326    ///         /* set fields */
327    ///         .send().await?;
328    ///     println!("response {:?}", response);
329    ///     Ok(())
330    /// }
331    /// ```
332    pub fn pause_queue(&self) -> super::builder::cloud_tasks::PauseQueue {
333        super::builder::cloud_tasks::PauseQueue::new(self.inner.clone())
334    }
335
336    /// Resume a queue.
337    ///
338    /// This method resumes a queue after it has been
339    /// [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED] or
340    /// [DISABLED][google.cloud.tasks.v2.Queue.State.DISABLED]. The state of a
341    /// queue is stored in the queue's [state][google.cloud.tasks.v2.Queue.state];
342    /// after calling this method it will be set to
343    /// [RUNNING][google.cloud.tasks.v2.Queue.State.RUNNING].
344    ///
345    /// WARNING: Resuming many high-QPS queues at the same time can
346    /// lead to target overloading. If you are resuming high-QPS
347    /// queues, follow the 500/50/5 pattern described in
348    /// [Managing Cloud Tasks Scaling
349    /// Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling).
350    ///
351    /// [google.cloud.tasks.v2.Queue.State.DISABLED]: crate::model::queue::State::Disabled
352    /// [google.cloud.tasks.v2.Queue.State.PAUSED]: crate::model::queue::State::Paused
353    /// [google.cloud.tasks.v2.Queue.State.RUNNING]: crate::model::queue::State::Running
354    /// [google.cloud.tasks.v2.Queue.state]: crate::model::Queue::state
355    ///
356    /// # Example
357    /// ```
358    /// # use google_cloud_tasks_v2::client::CloudTasks;
359    /// use google_cloud_tasks_v2::Result;
360    /// async fn sample(
361    ///    client: &CloudTasks
362    /// ) -> Result<()> {
363    ///     let response = client.resume_queue()
364    ///         /* set fields */
365    ///         .send().await?;
366    ///     println!("response {:?}", response);
367    ///     Ok(())
368    /// }
369    /// ```
370    pub fn resume_queue(&self) -> super::builder::cloud_tasks::ResumeQueue {
371        super::builder::cloud_tasks::ResumeQueue::new(self.inner.clone())
372    }
373
374    /// Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue].
375    /// Returns an empty policy if the resource exists and does not have a policy
376    /// set.
377    ///
378    /// Authorization requires the following
379    /// [Google IAM](https://cloud.google.com/iam) permission on the specified
380    /// resource parent:
381    ///
382    /// * `cloudtasks.queues.getIamPolicy`
383    ///
384    /// [google.cloud.tasks.v2.Queue]: crate::model::Queue
385    ///
386    /// # Example
387    /// ```
388    /// # use google_cloud_tasks_v2::client::CloudTasks;
389    /// use google_cloud_tasks_v2::Result;
390    /// async fn sample(
391    ///    client: &CloudTasks
392    /// ) -> Result<()> {
393    ///     let response = client.get_iam_policy()
394    ///         /* set fields */
395    ///         .send().await?;
396    ///     println!("response {:?}", response);
397    ///     Ok(())
398    /// }
399    /// ```
400    pub fn get_iam_policy(&self) -> super::builder::cloud_tasks::GetIamPolicy {
401        super::builder::cloud_tasks::GetIamPolicy::new(self.inner.clone())
402    }
403
404    /// Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue].
405    /// Replaces any existing policy.
406    ///
407    /// Note: The Cloud Console does not check queue-level IAM permissions yet.
408    /// Project-level permissions are required to use the Cloud Console.
409    ///
410    /// Authorization requires the following
411    /// [Google IAM](https://cloud.google.com/iam) permission on the specified
412    /// resource parent:
413    ///
414    /// * `cloudtasks.queues.setIamPolicy`
415    ///
416    /// [google.cloud.tasks.v2.Queue]: crate::model::Queue
417    ///
418    /// # Example
419    /// ```
420    /// # use google_cloud_tasks_v2::client::CloudTasks;
421    /// use google_cloud_tasks_v2::Result;
422    /// async fn sample(
423    ///    client: &CloudTasks
424    /// ) -> Result<()> {
425    ///     let response = client.set_iam_policy()
426    ///         /* set fields */
427    ///         .send().await?;
428    ///     println!("response {:?}", response);
429    ///     Ok(())
430    /// }
431    /// ```
432    pub fn set_iam_policy(&self) -> super::builder::cloud_tasks::SetIamPolicy {
433        super::builder::cloud_tasks::SetIamPolicy::new(self.inner.clone())
434    }
435
436    /// Returns permissions that a caller has on a
437    /// [Queue][google.cloud.tasks.v2.Queue]. If the resource does not exist, this
438    /// will return an empty set of permissions, not a
439    /// [NOT_FOUND][google.rpc.Code.NOT_FOUND] error.
440    ///
441    /// Note: This operation is designed to be used for building permission-aware
442    /// UIs and command-line tools, not for authorization checking. This operation
443    /// may "fail open" without warning.
444    ///
445    /// [google.cloud.tasks.v2.Queue]: crate::model::Queue
446    ///
447    /// # Example
448    /// ```
449    /// # use google_cloud_tasks_v2::client::CloudTasks;
450    /// use google_cloud_tasks_v2::Result;
451    /// async fn sample(
452    ///    client: &CloudTasks
453    /// ) -> Result<()> {
454    ///     let response = client.test_iam_permissions()
455    ///         /* set fields */
456    ///         .send().await?;
457    ///     println!("response {:?}", response);
458    ///     Ok(())
459    /// }
460    /// ```
461    pub fn test_iam_permissions(&self) -> super::builder::cloud_tasks::TestIamPermissions {
462        super::builder::cloud_tasks::TestIamPermissions::new(self.inner.clone())
463    }
464
465    /// Lists the tasks in a queue.
466    ///
467    /// By default, only the [BASIC][google.cloud.tasks.v2.Task.View.BASIC] view is
468    /// retrieved due to performance considerations;
469    /// [response_view][google.cloud.tasks.v2.ListTasksRequest.response_view]
470    /// controls the subset of information which is returned.
471    ///
472    /// The tasks may be returned in any order. The ordering may change at any
473    /// time.
474    ///
475    /// [google.cloud.tasks.v2.ListTasksRequest.response_view]: crate::model::ListTasksRequest::response_view
476    /// [google.cloud.tasks.v2.Task.View.BASIC]: crate::model::task::View::Basic
477    ///
478    /// # Example
479    /// ```
480    /// # use google_cloud_tasks_v2::client::CloudTasks;
481    /// use google_cloud_gax::paginator::ItemPaginator as _;
482    /// use google_cloud_tasks_v2::Result;
483    /// async fn sample(
484    ///    client: &CloudTasks, parent: &str
485    /// ) -> Result<()> {
486    ///     let mut list = client.list_tasks()
487    ///         .set_parent(parent)
488    ///         .by_item();
489    ///     while let Some(item) = list.next().await.transpose()? {
490    ///         println!("{:?}", item);
491    ///     }
492    ///     Ok(())
493    /// }
494    /// ```
495    pub fn list_tasks(&self) -> super::builder::cloud_tasks::ListTasks {
496        super::builder::cloud_tasks::ListTasks::new(self.inner.clone())
497    }
498
499    /// Gets a task.
500    ///
501    /// # Example
502    /// ```
503    /// # use google_cloud_tasks_v2::client::CloudTasks;
504    /// use google_cloud_tasks_v2::Result;
505    /// async fn sample(
506    ///    client: &CloudTasks, name: &str
507    /// ) -> Result<()> {
508    ///     let response = client.get_task()
509    ///         .set_name(name)
510    ///         .send().await?;
511    ///     println!("response {:?}", response);
512    ///     Ok(())
513    /// }
514    /// ```
515    pub fn get_task(&self) -> super::builder::cloud_tasks::GetTask {
516        super::builder::cloud_tasks::GetTask::new(self.inner.clone())
517    }
518
519    /// Creates a task and adds it to a queue.
520    ///
521    /// Tasks cannot be updated after creation; there is no UpdateTask command.
522    ///
523    /// * The maximum task size is 100KB.
524    ///
525    /// # Example
526    /// ```
527    /// # use google_cloud_tasks_v2::client::CloudTasks;
528    /// use google_cloud_tasks_v2::model::Task;
529    /// use google_cloud_tasks_v2::Result;
530    /// async fn sample(
531    ///    client: &CloudTasks, parent: &str
532    /// ) -> Result<()> {
533    ///     let response = client.create_task()
534    ///         .set_parent(parent)
535    ///         .set_task(
536    ///             Task::new()/* set fields */
537    ///         )
538    ///         .send().await?;
539    ///     println!("response {:?}", response);
540    ///     Ok(())
541    /// }
542    /// ```
543    pub fn create_task(&self) -> super::builder::cloud_tasks::CreateTask {
544        super::builder::cloud_tasks::CreateTask::new(self.inner.clone())
545    }
546
547    /// Deletes a task.
548    ///
549    /// A task can be deleted if it is scheduled or dispatched. A task
550    /// cannot be deleted if it has executed successfully or permanently
551    /// failed.
552    ///
553    /// # Example
554    /// ```
555    /// # use google_cloud_tasks_v2::client::CloudTasks;
556    /// use google_cloud_tasks_v2::Result;
557    /// async fn sample(
558    ///    client: &CloudTasks, name: &str
559    /// ) -> Result<()> {
560    ///     client.delete_task()
561    ///         .set_name(name)
562    ///         .send().await?;
563    ///     Ok(())
564    /// }
565    /// ```
566    pub fn delete_task(&self) -> super::builder::cloud_tasks::DeleteTask {
567        super::builder::cloud_tasks::DeleteTask::new(self.inner.clone())
568    }
569
570    /// Forces a task to run now.
571    ///
572    /// When this method is called, Cloud Tasks will dispatch the task, even if
573    /// the task is already running, the queue has reached its
574    /// [RateLimits][google.cloud.tasks.v2.RateLimits] or is
575    /// [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED].
576    ///
577    /// This command is meant to be used for manual debugging. For
578    /// example, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] can be used to
579    /// retry a failed task after a fix has been made or to manually force a task
580    /// to be dispatched now.
581    ///
582    /// The dispatched task is returned. That is, the task that is returned
583    /// contains the [status][Task.status] after the task is dispatched but
584    /// before the task is received by its target.
585    ///
586    /// If Cloud Tasks receives a successful response from the task's
587    /// target, then the task will be deleted; otherwise the task's
588    /// [schedule_time][google.cloud.tasks.v2.Task.schedule_time] will be reset to
589    /// the time that [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] was
590    /// called plus the retry delay specified in the queue's
591    /// [RetryConfig][google.cloud.tasks.v2.RetryConfig].
592    ///
593    /// [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] returns
594    /// [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a
595    /// task that has already succeeded or permanently failed.
596    ///
597    /// [google.cloud.tasks.v2.CloudTasks.RunTask]: crate::client::CloudTasks::run_task
598    /// [google.cloud.tasks.v2.Queue.State.PAUSED]: crate::model::queue::State::Paused
599    /// [google.cloud.tasks.v2.RateLimits]: crate::model::RateLimits
600    /// [google.cloud.tasks.v2.RetryConfig]: crate::model::RetryConfig
601    /// [google.cloud.tasks.v2.Task.schedule_time]: crate::model::Task::schedule_time
602    ///
603    /// # Example
604    /// ```
605    /// # use google_cloud_tasks_v2::client::CloudTasks;
606    /// use google_cloud_tasks_v2::Result;
607    /// async fn sample(
608    ///    client: &CloudTasks
609    /// ) -> Result<()> {
610    ///     let response = client.run_task()
611    ///         /* set fields */
612    ///         .send().await?;
613    ///     println!("response {:?}", response);
614    ///     Ok(())
615    /// }
616    /// ```
617    pub fn run_task(&self) -> super::builder::cloud_tasks::RunTask {
618        super::builder::cloud_tasks::RunTask::new(self.inner.clone())
619    }
620
621    /// Lists information about the supported locations for this service.
622    ///
623    /// # Example
624    /// ```
625    /// # use google_cloud_tasks_v2::client::CloudTasks;
626    /// use google_cloud_gax::paginator::ItemPaginator as _;
627    /// use google_cloud_tasks_v2::Result;
628    /// async fn sample(
629    ///    client: &CloudTasks
630    /// ) -> Result<()> {
631    ///     let mut list = client.list_locations()
632    ///         /* set fields */
633    ///         .by_item();
634    ///     while let Some(item) = list.next().await.transpose()? {
635    ///         println!("{:?}", item);
636    ///     }
637    ///     Ok(())
638    /// }
639    /// ```
640    pub fn list_locations(&self) -> super::builder::cloud_tasks::ListLocations {
641        super::builder::cloud_tasks::ListLocations::new(self.inner.clone())
642    }
643
644    /// Gets information about a location.
645    ///
646    /// # Example
647    /// ```
648    /// # use google_cloud_tasks_v2::client::CloudTasks;
649    /// use google_cloud_tasks_v2::Result;
650    /// async fn sample(
651    ///    client: &CloudTasks
652    /// ) -> Result<()> {
653    ///     let response = client.get_location()
654    ///         /* set fields */
655    ///         .send().await?;
656    ///     println!("response {:?}", response);
657    ///     Ok(())
658    /// }
659    /// ```
660    pub fn get_location(&self) -> super::builder::cloud_tasks::GetLocation {
661        super::builder::cloud_tasks::GetLocation::new(self.inner.clone())
662    }
663}