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