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