Skip to main content

google_cloud_tasks_v2/
model.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#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_iam_v1;
25extern crate google_cloud_location;
26extern crate google_cloud_rpc;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// Request message for
39/// [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues].
40///
41/// [google.cloud.tasks.v2.CloudTasks.ListQueues]: crate::client::CloudTasks::list_queues
42#[derive(Clone, Default, PartialEq)]
43#[non_exhaustive]
44pub struct ListQueuesRequest {
45    /// Required. The location name.
46    /// For example: `projects/PROJECT_ID/locations/LOCATION_ID`
47    pub parent: std::string::String,
48
49    /// `filter` can be used to specify a subset of queues. Any
50    /// [Queue][google.cloud.tasks.v2.Queue] field can be used as a filter and
51    /// several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The
52    /// filter syntax is the same as described in [Stackdriver's Advanced Logs
53    /// Filters](https://cloud.google.com/logging/docs/view/advanced_filters).
54    ///
55    /// Sample filter "state: PAUSED".
56    ///
57    /// Note that using filters might cause fewer queues than the
58    /// requested page_size to be returned.
59    ///
60    /// [google.cloud.tasks.v2.Queue]: crate::model::Queue
61    pub filter: std::string::String,
62
63    /// Requested page size.
64    ///
65    /// The maximum page size is 9800. If unspecified, the page size will
66    /// be the maximum. Fewer queues than requested might be returned,
67    /// even if more queues exist; use the
68    /// [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token]
69    /// in the response to determine if more queues exist.
70    ///
71    /// [google.cloud.tasks.v2.ListQueuesResponse.next_page_token]: crate::model::ListQueuesResponse::next_page_token
72    pub page_size: i32,
73
74    /// A token identifying the page of results to return.
75    ///
76    /// To request the first page results, page_token must be empty. To
77    /// request the next page of results, page_token must be the value of
78    /// [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token]
79    /// returned from the previous call to
80    /// [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] method. It is an
81    /// error to switch the value of the
82    /// [filter][google.cloud.tasks.v2.ListQueuesRequest.filter] while iterating
83    /// through pages.
84    ///
85    /// [google.cloud.tasks.v2.CloudTasks.ListQueues]: crate::client::CloudTasks::list_queues
86    /// [google.cloud.tasks.v2.ListQueuesRequest.filter]: crate::model::ListQueuesRequest::filter
87    /// [google.cloud.tasks.v2.ListQueuesResponse.next_page_token]: crate::model::ListQueuesResponse::next_page_token
88    pub page_token: std::string::String,
89
90    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
91}
92
93impl ListQueuesRequest {
94    pub fn new() -> Self {
95        std::default::Default::default()
96    }
97
98    /// Sets the value of [parent][crate::model::ListQueuesRequest::parent].
99    ///
100    /// # Example
101    /// ```ignore,no_run
102    /// # use google_cloud_tasks_v2::model::ListQueuesRequest;
103    /// let x = ListQueuesRequest::new().set_parent("example");
104    /// ```
105    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
106        self.parent = v.into();
107        self
108    }
109
110    /// Sets the value of [filter][crate::model::ListQueuesRequest::filter].
111    ///
112    /// # Example
113    /// ```ignore,no_run
114    /// # use google_cloud_tasks_v2::model::ListQueuesRequest;
115    /// let x = ListQueuesRequest::new().set_filter("example");
116    /// ```
117    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
118        self.filter = v.into();
119        self
120    }
121
122    /// Sets the value of [page_size][crate::model::ListQueuesRequest::page_size].
123    ///
124    /// # Example
125    /// ```ignore,no_run
126    /// # use google_cloud_tasks_v2::model::ListQueuesRequest;
127    /// let x = ListQueuesRequest::new().set_page_size(42);
128    /// ```
129    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
130        self.page_size = v.into();
131        self
132    }
133
134    /// Sets the value of [page_token][crate::model::ListQueuesRequest::page_token].
135    ///
136    /// # Example
137    /// ```ignore,no_run
138    /// # use google_cloud_tasks_v2::model::ListQueuesRequest;
139    /// let x = ListQueuesRequest::new().set_page_token("example");
140    /// ```
141    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
142        self.page_token = v.into();
143        self
144    }
145}
146
147impl wkt::message::Message for ListQueuesRequest {
148    fn typename() -> &'static str {
149        "type.googleapis.com/google.cloud.tasks.v2.ListQueuesRequest"
150    }
151}
152
153/// Response message for
154/// [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues].
155///
156/// [google.cloud.tasks.v2.CloudTasks.ListQueues]: crate::client::CloudTasks::list_queues
157#[derive(Clone, Default, PartialEq)]
158#[non_exhaustive]
159pub struct ListQueuesResponse {
160    /// The list of queues.
161    pub queues: std::vec::Vec<crate::model::Queue>,
162
163    /// A token to retrieve next page of results.
164    ///
165    /// To return the next page of results, call
166    /// [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] with this value
167    /// as the [page_token][google.cloud.tasks.v2.ListQueuesRequest.page_token].
168    ///
169    /// If the next_page_token is empty, there are no more results.
170    ///
171    /// The page token is valid for only 2 hours.
172    ///
173    /// [google.cloud.tasks.v2.CloudTasks.ListQueues]: crate::client::CloudTasks::list_queues
174    /// [google.cloud.tasks.v2.ListQueuesRequest.page_token]: crate::model::ListQueuesRequest::page_token
175    pub next_page_token: std::string::String,
176
177    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
178}
179
180impl ListQueuesResponse {
181    pub fn new() -> Self {
182        std::default::Default::default()
183    }
184
185    /// Sets the value of [queues][crate::model::ListQueuesResponse::queues].
186    ///
187    /// # Example
188    /// ```ignore,no_run
189    /// # use google_cloud_tasks_v2::model::ListQueuesResponse;
190    /// use google_cloud_tasks_v2::model::Queue;
191    /// let x = ListQueuesResponse::new()
192    ///     .set_queues([
193    ///         Queue::default()/* use setters */,
194    ///         Queue::default()/* use (different) setters */,
195    ///     ]);
196    /// ```
197    pub fn set_queues<T, V>(mut self, v: T) -> Self
198    where
199        T: std::iter::IntoIterator<Item = V>,
200        V: std::convert::Into<crate::model::Queue>,
201    {
202        use std::iter::Iterator;
203        self.queues = v.into_iter().map(|i| i.into()).collect();
204        self
205    }
206
207    /// Sets the value of [next_page_token][crate::model::ListQueuesResponse::next_page_token].
208    ///
209    /// # Example
210    /// ```ignore,no_run
211    /// # use google_cloud_tasks_v2::model::ListQueuesResponse;
212    /// let x = ListQueuesResponse::new().set_next_page_token("example");
213    /// ```
214    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
215        self.next_page_token = v.into();
216        self
217    }
218}
219
220impl wkt::message::Message for ListQueuesResponse {
221    fn typename() -> &'static str {
222        "type.googleapis.com/google.cloud.tasks.v2.ListQueuesResponse"
223    }
224}
225
226#[doc(hidden)]
227impl google_cloud_gax::paginator::internal::PageableResponse for ListQueuesResponse {
228    type PageItem = crate::model::Queue;
229
230    fn items(self) -> std::vec::Vec<Self::PageItem> {
231        self.queues
232    }
233
234    fn next_page_token(&self) -> std::string::String {
235        use std::clone::Clone;
236        self.next_page_token.clone()
237    }
238}
239
240/// Request message for [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue].
241///
242/// [google.cloud.tasks.v2.CloudTasks.GetQueue]: crate::client::CloudTasks::get_queue
243#[derive(Clone, Default, PartialEq)]
244#[non_exhaustive]
245pub struct GetQueueRequest {
246    /// Required. The resource name of the queue. For example:
247    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
248    pub name: std::string::String,
249
250    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
251}
252
253impl GetQueueRequest {
254    pub fn new() -> Self {
255        std::default::Default::default()
256    }
257
258    /// Sets the value of [name][crate::model::GetQueueRequest::name].
259    ///
260    /// # Example
261    /// ```ignore,no_run
262    /// # use google_cloud_tasks_v2::model::GetQueueRequest;
263    /// let x = GetQueueRequest::new().set_name("example");
264    /// ```
265    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
266        self.name = v.into();
267        self
268    }
269}
270
271impl wkt::message::Message for GetQueueRequest {
272    fn typename() -> &'static str {
273        "type.googleapis.com/google.cloud.tasks.v2.GetQueueRequest"
274    }
275}
276
277/// Request message for
278/// [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue].
279///
280/// [google.cloud.tasks.v2.CloudTasks.CreateQueue]: crate::client::CloudTasks::create_queue
281#[derive(Clone, Default, PartialEq)]
282#[non_exhaustive]
283pub struct CreateQueueRequest {
284    /// Required. The location name in which the queue will be created.
285    /// For example: `projects/PROJECT_ID/locations/LOCATION_ID`
286    ///
287    /// The list of allowed locations can be obtained by calling Cloud
288    /// Tasks' implementation of
289    /// [ListLocations][google.cloud.location.Locations.ListLocations].
290    pub parent: std::string::String,
291
292    /// Required. The queue to create.
293    ///
294    /// [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be the same as an
295    /// existing queue.
296    ///
297    /// [google.cloud.tasks.v2.Queue.name]: crate::model::Queue::name
298    pub queue: std::option::Option<crate::model::Queue>,
299
300    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
301}
302
303impl CreateQueueRequest {
304    pub fn new() -> Self {
305        std::default::Default::default()
306    }
307
308    /// Sets the value of [parent][crate::model::CreateQueueRequest::parent].
309    ///
310    /// # Example
311    /// ```ignore,no_run
312    /// # use google_cloud_tasks_v2::model::CreateQueueRequest;
313    /// let x = CreateQueueRequest::new().set_parent("example");
314    /// ```
315    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
316        self.parent = v.into();
317        self
318    }
319
320    /// Sets the value of [queue][crate::model::CreateQueueRequest::queue].
321    ///
322    /// # Example
323    /// ```ignore,no_run
324    /// # use google_cloud_tasks_v2::model::CreateQueueRequest;
325    /// use google_cloud_tasks_v2::model::Queue;
326    /// let x = CreateQueueRequest::new().set_queue(Queue::default()/* use setters */);
327    /// ```
328    pub fn set_queue<T>(mut self, v: T) -> Self
329    where
330        T: std::convert::Into<crate::model::Queue>,
331    {
332        self.queue = std::option::Option::Some(v.into());
333        self
334    }
335
336    /// Sets or clears the value of [queue][crate::model::CreateQueueRequest::queue].
337    ///
338    /// # Example
339    /// ```ignore,no_run
340    /// # use google_cloud_tasks_v2::model::CreateQueueRequest;
341    /// use google_cloud_tasks_v2::model::Queue;
342    /// let x = CreateQueueRequest::new().set_or_clear_queue(Some(Queue::default()/* use setters */));
343    /// let x = CreateQueueRequest::new().set_or_clear_queue(None::<Queue>);
344    /// ```
345    pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
346    where
347        T: std::convert::Into<crate::model::Queue>,
348    {
349        self.queue = v.map(|x| x.into());
350        self
351    }
352}
353
354impl wkt::message::Message for CreateQueueRequest {
355    fn typename() -> &'static str {
356        "type.googleapis.com/google.cloud.tasks.v2.CreateQueueRequest"
357    }
358}
359
360/// Request message for
361/// [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue].
362///
363/// [google.cloud.tasks.v2.CloudTasks.UpdateQueue]: crate::client::CloudTasks::update_queue
364#[derive(Clone, Default, PartialEq)]
365#[non_exhaustive]
366pub struct UpdateQueueRequest {
367    /// Required. The queue to create or update.
368    ///
369    /// The queue's [name][google.cloud.tasks.v2.Queue.name] must be specified.
370    ///
371    /// Output only fields cannot be modified using UpdateQueue.
372    /// Any value specified for an output only field will be ignored.
373    /// The queue's [name][google.cloud.tasks.v2.Queue.name] cannot be changed.
374    ///
375    /// [google.cloud.tasks.v2.Queue.name]: crate::model::Queue::name
376    pub queue: std::option::Option<crate::model::Queue>,
377
378    /// A mask used to specify which fields of the queue are being updated.
379    ///
380    /// If empty, then all fields will be updated.
381    pub update_mask: std::option::Option<wkt::FieldMask>,
382
383    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
384}
385
386impl UpdateQueueRequest {
387    pub fn new() -> Self {
388        std::default::Default::default()
389    }
390
391    /// Sets the value of [queue][crate::model::UpdateQueueRequest::queue].
392    ///
393    /// # Example
394    /// ```ignore,no_run
395    /// # use google_cloud_tasks_v2::model::UpdateQueueRequest;
396    /// use google_cloud_tasks_v2::model::Queue;
397    /// let x = UpdateQueueRequest::new().set_queue(Queue::default()/* use setters */);
398    /// ```
399    pub fn set_queue<T>(mut self, v: T) -> Self
400    where
401        T: std::convert::Into<crate::model::Queue>,
402    {
403        self.queue = std::option::Option::Some(v.into());
404        self
405    }
406
407    /// Sets or clears the value of [queue][crate::model::UpdateQueueRequest::queue].
408    ///
409    /// # Example
410    /// ```ignore,no_run
411    /// # use google_cloud_tasks_v2::model::UpdateQueueRequest;
412    /// use google_cloud_tasks_v2::model::Queue;
413    /// let x = UpdateQueueRequest::new().set_or_clear_queue(Some(Queue::default()/* use setters */));
414    /// let x = UpdateQueueRequest::new().set_or_clear_queue(None::<Queue>);
415    /// ```
416    pub fn set_or_clear_queue<T>(mut self, v: std::option::Option<T>) -> Self
417    where
418        T: std::convert::Into<crate::model::Queue>,
419    {
420        self.queue = v.map(|x| x.into());
421        self
422    }
423
424    /// Sets the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
425    ///
426    /// # Example
427    /// ```ignore,no_run
428    /// # use google_cloud_tasks_v2::model::UpdateQueueRequest;
429    /// use wkt::FieldMask;
430    /// let x = UpdateQueueRequest::new().set_update_mask(FieldMask::default()/* use setters */);
431    /// ```
432    pub fn set_update_mask<T>(mut self, v: T) -> Self
433    where
434        T: std::convert::Into<wkt::FieldMask>,
435    {
436        self.update_mask = std::option::Option::Some(v.into());
437        self
438    }
439
440    /// Sets or clears the value of [update_mask][crate::model::UpdateQueueRequest::update_mask].
441    ///
442    /// # Example
443    /// ```ignore,no_run
444    /// # use google_cloud_tasks_v2::model::UpdateQueueRequest;
445    /// use wkt::FieldMask;
446    /// let x = UpdateQueueRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
447    /// let x = UpdateQueueRequest::new().set_or_clear_update_mask(None::<FieldMask>);
448    /// ```
449    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
450    where
451        T: std::convert::Into<wkt::FieldMask>,
452    {
453        self.update_mask = v.map(|x| x.into());
454        self
455    }
456}
457
458impl wkt::message::Message for UpdateQueueRequest {
459    fn typename() -> &'static str {
460        "type.googleapis.com/google.cloud.tasks.v2.UpdateQueueRequest"
461    }
462}
463
464/// Request message for
465/// [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue].
466///
467/// [google.cloud.tasks.v2.CloudTasks.DeleteQueue]: crate::client::CloudTasks::delete_queue
468#[derive(Clone, Default, PartialEq)]
469#[non_exhaustive]
470pub struct DeleteQueueRequest {
471    /// Required. The queue name. For example:
472    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
473    pub name: std::string::String,
474
475    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
476}
477
478impl DeleteQueueRequest {
479    pub fn new() -> Self {
480        std::default::Default::default()
481    }
482
483    /// Sets the value of [name][crate::model::DeleteQueueRequest::name].
484    ///
485    /// # Example
486    /// ```ignore,no_run
487    /// # use google_cloud_tasks_v2::model::DeleteQueueRequest;
488    /// let x = DeleteQueueRequest::new().set_name("example");
489    /// ```
490    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
491        self.name = v.into();
492        self
493    }
494}
495
496impl wkt::message::Message for DeleteQueueRequest {
497    fn typename() -> &'static str {
498        "type.googleapis.com/google.cloud.tasks.v2.DeleteQueueRequest"
499    }
500}
501
502/// Request message for
503/// [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue].
504///
505/// [google.cloud.tasks.v2.CloudTasks.PurgeQueue]: crate::client::CloudTasks::purge_queue
506#[derive(Clone, Default, PartialEq)]
507#[non_exhaustive]
508pub struct PurgeQueueRequest {
509    /// Required. The queue name. For example:
510    /// `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
511    pub name: std::string::String,
512
513    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
514}
515
516impl PurgeQueueRequest {
517    pub fn new() -> Self {
518        std::default::Default::default()
519    }
520
521    /// Sets the value of [name][crate::model::PurgeQueueRequest::name].
522    ///
523    /// # Example
524    /// ```ignore,no_run
525    /// # use google_cloud_tasks_v2::model::PurgeQueueRequest;
526    /// let x = PurgeQueueRequest::new().set_name("example");
527    /// ```
528    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
529        self.name = v.into();
530        self
531    }
532}
533
534impl wkt::message::Message for PurgeQueueRequest {
535    fn typename() -> &'static str {
536        "type.googleapis.com/google.cloud.tasks.v2.PurgeQueueRequest"
537    }
538}
539
540/// Request message for
541/// [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue].
542///
543/// [google.cloud.tasks.v2.CloudTasks.PauseQueue]: crate::client::CloudTasks::pause_queue
544#[derive(Clone, Default, PartialEq)]
545#[non_exhaustive]
546pub struct PauseQueueRequest {
547    /// Required. The queue name. For example:
548    /// `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
549    pub name: std::string::String,
550
551    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
552}
553
554impl PauseQueueRequest {
555    pub fn new() -> Self {
556        std::default::Default::default()
557    }
558
559    /// Sets the value of [name][crate::model::PauseQueueRequest::name].
560    ///
561    /// # Example
562    /// ```ignore,no_run
563    /// # use google_cloud_tasks_v2::model::PauseQueueRequest;
564    /// let x = PauseQueueRequest::new().set_name("example");
565    /// ```
566    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
567        self.name = v.into();
568        self
569    }
570}
571
572impl wkt::message::Message for PauseQueueRequest {
573    fn typename() -> &'static str {
574        "type.googleapis.com/google.cloud.tasks.v2.PauseQueueRequest"
575    }
576}
577
578/// Request message for
579/// [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue].
580///
581/// [google.cloud.tasks.v2.CloudTasks.ResumeQueue]: crate::client::CloudTasks::resume_queue
582#[derive(Clone, Default, PartialEq)]
583#[non_exhaustive]
584pub struct ResumeQueueRequest {
585    /// Required. The queue name. For example:
586    /// `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`
587    pub name: std::string::String,
588
589    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
590}
591
592impl ResumeQueueRequest {
593    pub fn new() -> Self {
594        std::default::Default::default()
595    }
596
597    /// Sets the value of [name][crate::model::ResumeQueueRequest::name].
598    ///
599    /// # Example
600    /// ```ignore,no_run
601    /// # use google_cloud_tasks_v2::model::ResumeQueueRequest;
602    /// let x = ResumeQueueRequest::new().set_name("example");
603    /// ```
604    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
605        self.name = v.into();
606        self
607    }
608}
609
610impl wkt::message::Message for ResumeQueueRequest {
611    fn typename() -> &'static str {
612        "type.googleapis.com/google.cloud.tasks.v2.ResumeQueueRequest"
613    }
614}
615
616/// Request message for listing tasks using
617/// [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks].
618///
619/// [google.cloud.tasks.v2.CloudTasks.ListTasks]: crate::client::CloudTasks::list_tasks
620#[derive(Clone, Default, PartialEq)]
621#[non_exhaustive]
622pub struct ListTasksRequest {
623    /// Required. The queue name. For example:
624    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
625    pub parent: std::string::String,
626
627    /// The response_view specifies which subset of the
628    /// [Task][google.cloud.tasks.v2.Task] will be returned.
629    ///
630    /// By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC];
631    /// not all information is retrieved by default because some data, such as
632    /// payloads, might be desirable to return only when needed because
633    /// of its large size or because of the sensitivity of data that it
634    /// contains.
635    ///
636    /// Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
637    /// `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
638    /// permission on the [Task][google.cloud.tasks.v2.Task] resource.
639    ///
640    /// [google.cloud.tasks.v2.Task]: crate::model::Task
641    /// [google.cloud.tasks.v2.Task.View.BASIC]: crate::model::task::View::Basic
642    /// [google.cloud.tasks.v2.Task.View.FULL]: crate::model::task::View::Full
643    pub response_view: crate::model::task::View,
644
645    /// Maximum page size.
646    ///
647    /// Fewer tasks than requested might be returned, even if more tasks exist; use
648    /// [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token]
649    /// in the response to determine if more tasks exist.
650    ///
651    /// The maximum page size is 1000. If unspecified, the page size will be the
652    /// maximum.
653    ///
654    /// [google.cloud.tasks.v2.ListTasksResponse.next_page_token]: crate::model::ListTasksResponse::next_page_token
655    pub page_size: i32,
656
657    /// A token identifying the page of results to return.
658    ///
659    /// To request the first page results, page_token must be empty. To
660    /// request the next page of results, page_token must be the value of
661    /// [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token]
662    /// returned from the previous call to
663    /// [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] method.
664    ///
665    /// The page token is valid for only 2 hours.
666    ///
667    /// [google.cloud.tasks.v2.CloudTasks.ListTasks]: crate::client::CloudTasks::list_tasks
668    /// [google.cloud.tasks.v2.ListTasksResponse.next_page_token]: crate::model::ListTasksResponse::next_page_token
669    pub page_token: std::string::String,
670
671    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
672}
673
674impl ListTasksRequest {
675    pub fn new() -> Self {
676        std::default::Default::default()
677    }
678
679    /// Sets the value of [parent][crate::model::ListTasksRequest::parent].
680    ///
681    /// # Example
682    /// ```ignore,no_run
683    /// # use google_cloud_tasks_v2::model::ListTasksRequest;
684    /// let x = ListTasksRequest::new().set_parent("example");
685    /// ```
686    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
687        self.parent = v.into();
688        self
689    }
690
691    /// Sets the value of [response_view][crate::model::ListTasksRequest::response_view].
692    ///
693    /// # Example
694    /// ```ignore,no_run
695    /// # use google_cloud_tasks_v2::model::ListTasksRequest;
696    /// use google_cloud_tasks_v2::model::task::View;
697    /// let x0 = ListTasksRequest::new().set_response_view(View::Basic);
698    /// let x1 = ListTasksRequest::new().set_response_view(View::Full);
699    /// ```
700    pub fn set_response_view<T: std::convert::Into<crate::model::task::View>>(
701        mut self,
702        v: T,
703    ) -> Self {
704        self.response_view = v.into();
705        self
706    }
707
708    /// Sets the value of [page_size][crate::model::ListTasksRequest::page_size].
709    ///
710    /// # Example
711    /// ```ignore,no_run
712    /// # use google_cloud_tasks_v2::model::ListTasksRequest;
713    /// let x = ListTasksRequest::new().set_page_size(42);
714    /// ```
715    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
716        self.page_size = v.into();
717        self
718    }
719
720    /// Sets the value of [page_token][crate::model::ListTasksRequest::page_token].
721    ///
722    /// # Example
723    /// ```ignore,no_run
724    /// # use google_cloud_tasks_v2::model::ListTasksRequest;
725    /// let x = ListTasksRequest::new().set_page_token("example");
726    /// ```
727    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
728        self.page_token = v.into();
729        self
730    }
731}
732
733impl wkt::message::Message for ListTasksRequest {
734    fn typename() -> &'static str {
735        "type.googleapis.com/google.cloud.tasks.v2.ListTasksRequest"
736    }
737}
738
739/// Response message for listing tasks using
740/// [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks].
741///
742/// [google.cloud.tasks.v2.CloudTasks.ListTasks]: crate::client::CloudTasks::list_tasks
743#[derive(Clone, Default, PartialEq)]
744#[non_exhaustive]
745pub struct ListTasksResponse {
746    /// The list of tasks.
747    pub tasks: std::vec::Vec<crate::model::Task>,
748
749    /// A token to retrieve next page of results.
750    ///
751    /// To return the next page of results, call
752    /// [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] with this value as
753    /// the [page_token][google.cloud.tasks.v2.ListTasksRequest.page_token].
754    ///
755    /// If the next_page_token is empty, there are no more results.
756    ///
757    /// [google.cloud.tasks.v2.CloudTasks.ListTasks]: crate::client::CloudTasks::list_tasks
758    /// [google.cloud.tasks.v2.ListTasksRequest.page_token]: crate::model::ListTasksRequest::page_token
759    pub next_page_token: std::string::String,
760
761    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
762}
763
764impl ListTasksResponse {
765    pub fn new() -> Self {
766        std::default::Default::default()
767    }
768
769    /// Sets the value of [tasks][crate::model::ListTasksResponse::tasks].
770    ///
771    /// # Example
772    /// ```ignore,no_run
773    /// # use google_cloud_tasks_v2::model::ListTasksResponse;
774    /// use google_cloud_tasks_v2::model::Task;
775    /// let x = ListTasksResponse::new()
776    ///     .set_tasks([
777    ///         Task::default()/* use setters */,
778    ///         Task::default()/* use (different) setters */,
779    ///     ]);
780    /// ```
781    pub fn set_tasks<T, V>(mut self, v: T) -> Self
782    where
783        T: std::iter::IntoIterator<Item = V>,
784        V: std::convert::Into<crate::model::Task>,
785    {
786        use std::iter::Iterator;
787        self.tasks = v.into_iter().map(|i| i.into()).collect();
788        self
789    }
790
791    /// Sets the value of [next_page_token][crate::model::ListTasksResponse::next_page_token].
792    ///
793    /// # Example
794    /// ```ignore,no_run
795    /// # use google_cloud_tasks_v2::model::ListTasksResponse;
796    /// let x = ListTasksResponse::new().set_next_page_token("example");
797    /// ```
798    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
799        self.next_page_token = v.into();
800        self
801    }
802}
803
804impl wkt::message::Message for ListTasksResponse {
805    fn typename() -> &'static str {
806        "type.googleapis.com/google.cloud.tasks.v2.ListTasksResponse"
807    }
808}
809
810#[doc(hidden)]
811impl google_cloud_gax::paginator::internal::PageableResponse for ListTasksResponse {
812    type PageItem = crate::model::Task;
813
814    fn items(self) -> std::vec::Vec<Self::PageItem> {
815        self.tasks
816    }
817
818    fn next_page_token(&self) -> std::string::String {
819        use std::clone::Clone;
820        self.next_page_token.clone()
821    }
822}
823
824/// Request message for getting a task using
825/// [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask].
826///
827/// [google.cloud.tasks.v2.CloudTasks.GetTask]: crate::client::CloudTasks::get_task
828#[derive(Clone, Default, PartialEq)]
829#[non_exhaustive]
830pub struct GetTaskRequest {
831    /// Required. The task name. For example:
832    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
833    pub name: std::string::String,
834
835    /// The response_view specifies which subset of the
836    /// [Task][google.cloud.tasks.v2.Task] will be returned.
837    ///
838    /// By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC];
839    /// not all information is retrieved by default because some data, such as
840    /// payloads, might be desirable to return only when needed because
841    /// of its large size or because of the sensitivity of data that it
842    /// contains.
843    ///
844    /// Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
845    /// `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
846    /// permission on the [Task][google.cloud.tasks.v2.Task] resource.
847    ///
848    /// [google.cloud.tasks.v2.Task]: crate::model::Task
849    /// [google.cloud.tasks.v2.Task.View.BASIC]: crate::model::task::View::Basic
850    /// [google.cloud.tasks.v2.Task.View.FULL]: crate::model::task::View::Full
851    pub response_view: crate::model::task::View,
852
853    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
854}
855
856impl GetTaskRequest {
857    pub fn new() -> Self {
858        std::default::Default::default()
859    }
860
861    /// Sets the value of [name][crate::model::GetTaskRequest::name].
862    ///
863    /// # Example
864    /// ```ignore,no_run
865    /// # use google_cloud_tasks_v2::model::GetTaskRequest;
866    /// let x = GetTaskRequest::new().set_name("example");
867    /// ```
868    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
869        self.name = v.into();
870        self
871    }
872
873    /// Sets the value of [response_view][crate::model::GetTaskRequest::response_view].
874    ///
875    /// # Example
876    /// ```ignore,no_run
877    /// # use google_cloud_tasks_v2::model::GetTaskRequest;
878    /// use google_cloud_tasks_v2::model::task::View;
879    /// let x0 = GetTaskRequest::new().set_response_view(View::Basic);
880    /// let x1 = GetTaskRequest::new().set_response_view(View::Full);
881    /// ```
882    pub fn set_response_view<T: std::convert::Into<crate::model::task::View>>(
883        mut self,
884        v: T,
885    ) -> Self {
886        self.response_view = v.into();
887        self
888    }
889}
890
891impl wkt::message::Message for GetTaskRequest {
892    fn typename() -> &'static str {
893        "type.googleapis.com/google.cloud.tasks.v2.GetTaskRequest"
894    }
895}
896
897/// Request message for
898/// [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask].
899///
900/// [google.cloud.tasks.v2.CloudTasks.CreateTask]: crate::client::CloudTasks::create_task
901#[derive(Clone, Default, PartialEq)]
902#[non_exhaustive]
903pub struct CreateTaskRequest {
904    /// Required. The queue name. For example:
905    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
906    ///
907    /// The queue must already exist.
908    pub parent: std::string::String,
909
910    /// Required. The task to add.
911    ///
912    /// Task names have the following format:
913    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`.
914    /// The user can optionally specify a task
915    /// [name][google.cloud.tasks.v2.Task.name]. If a name is not specified then
916    /// the system will generate a random unique task id, which will be set in the
917    /// task returned in the [response][google.cloud.tasks.v2.Task.name].
918    ///
919    /// If [schedule_time][google.cloud.tasks.v2.Task.schedule_time] is not set or
920    /// is in the past then Cloud Tasks will set it to the current time.
921    ///
922    /// Task De-duplication:
923    ///
924    /// Explicitly specifying a task ID enables task de-duplication.  If
925    /// a task's ID is identical to that of an existing task or a task
926    /// that was deleted or executed recently then the call will fail
927    /// with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS].
928    /// If the task's queue was created using Cloud Tasks, then another task with
929    /// the same name can't be created for ~1hour after the original task was
930    /// deleted or executed. If the task's queue was created using queue.yaml or
931    /// queue.xml, then another task with the same name can't be created
932    /// for ~9days after the original task was deleted or executed.
933    ///
934    /// Because there is an extra lookup cost to identify duplicate task
935    /// names, these [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]
936    /// calls have significantly increased latency. Using hashed strings for the
937    /// task id or for the prefix of the task id is recommended. Choosing task ids
938    /// that are sequential or have sequential prefixes, for example using a
939    /// timestamp, causes an increase in latency and error rates in all
940    /// task commands. The infrastructure relies on an approximately
941    /// uniform distribution of task ids to store and serve tasks
942    /// efficiently.
943    ///
944    /// [google.cloud.tasks.v2.CloudTasks.CreateTask]: crate::client::CloudTasks::create_task
945    /// [google.cloud.tasks.v2.Task.name]: crate::model::Task::name
946    /// [google.cloud.tasks.v2.Task.schedule_time]: crate::model::Task::schedule_time
947    pub task: std::option::Option<crate::model::Task>,
948
949    /// The response_view specifies which subset of the
950    /// [Task][google.cloud.tasks.v2.Task] will be returned.
951    ///
952    /// By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC];
953    /// not all information is retrieved by default because some data, such as
954    /// payloads, might be desirable to return only when needed because
955    /// of its large size or because of the sensitivity of data that it
956    /// contains.
957    ///
958    /// Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
959    /// `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
960    /// permission on the [Task][google.cloud.tasks.v2.Task] resource.
961    ///
962    /// [google.cloud.tasks.v2.Task]: crate::model::Task
963    /// [google.cloud.tasks.v2.Task.View.BASIC]: crate::model::task::View::Basic
964    /// [google.cloud.tasks.v2.Task.View.FULL]: crate::model::task::View::Full
965    pub response_view: crate::model::task::View,
966
967    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
968}
969
970impl CreateTaskRequest {
971    pub fn new() -> Self {
972        std::default::Default::default()
973    }
974
975    /// Sets the value of [parent][crate::model::CreateTaskRequest::parent].
976    ///
977    /// # Example
978    /// ```ignore,no_run
979    /// # use google_cloud_tasks_v2::model::CreateTaskRequest;
980    /// let x = CreateTaskRequest::new().set_parent("example");
981    /// ```
982    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
983        self.parent = v.into();
984        self
985    }
986
987    /// Sets the value of [task][crate::model::CreateTaskRequest::task].
988    ///
989    /// # Example
990    /// ```ignore,no_run
991    /// # use google_cloud_tasks_v2::model::CreateTaskRequest;
992    /// use google_cloud_tasks_v2::model::Task;
993    /// let x = CreateTaskRequest::new().set_task(Task::default()/* use setters */);
994    /// ```
995    pub fn set_task<T>(mut self, v: T) -> Self
996    where
997        T: std::convert::Into<crate::model::Task>,
998    {
999        self.task = std::option::Option::Some(v.into());
1000        self
1001    }
1002
1003    /// Sets or clears the value of [task][crate::model::CreateTaskRequest::task].
1004    ///
1005    /// # Example
1006    /// ```ignore,no_run
1007    /// # use google_cloud_tasks_v2::model::CreateTaskRequest;
1008    /// use google_cloud_tasks_v2::model::Task;
1009    /// let x = CreateTaskRequest::new().set_or_clear_task(Some(Task::default()/* use setters */));
1010    /// let x = CreateTaskRequest::new().set_or_clear_task(None::<Task>);
1011    /// ```
1012    pub fn set_or_clear_task<T>(mut self, v: std::option::Option<T>) -> Self
1013    where
1014        T: std::convert::Into<crate::model::Task>,
1015    {
1016        self.task = v.map(|x| x.into());
1017        self
1018    }
1019
1020    /// Sets the value of [response_view][crate::model::CreateTaskRequest::response_view].
1021    ///
1022    /// # Example
1023    /// ```ignore,no_run
1024    /// # use google_cloud_tasks_v2::model::CreateTaskRequest;
1025    /// use google_cloud_tasks_v2::model::task::View;
1026    /// let x0 = CreateTaskRequest::new().set_response_view(View::Basic);
1027    /// let x1 = CreateTaskRequest::new().set_response_view(View::Full);
1028    /// ```
1029    pub fn set_response_view<T: std::convert::Into<crate::model::task::View>>(
1030        mut self,
1031        v: T,
1032    ) -> Self {
1033        self.response_view = v.into();
1034        self
1035    }
1036}
1037
1038impl wkt::message::Message for CreateTaskRequest {
1039    fn typename() -> &'static str {
1040        "type.googleapis.com/google.cloud.tasks.v2.CreateTaskRequest"
1041    }
1042}
1043
1044/// Request message for deleting a task using
1045/// [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask].
1046///
1047/// [google.cloud.tasks.v2.CloudTasks.DeleteTask]: crate::client::CloudTasks::delete_task
1048#[derive(Clone, Default, PartialEq)]
1049#[non_exhaustive]
1050pub struct DeleteTaskRequest {
1051    /// Required. The task name. For example:
1052    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1053    pub name: std::string::String,
1054
1055    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1056}
1057
1058impl DeleteTaskRequest {
1059    pub fn new() -> Self {
1060        std::default::Default::default()
1061    }
1062
1063    /// Sets the value of [name][crate::model::DeleteTaskRequest::name].
1064    ///
1065    /// # Example
1066    /// ```ignore,no_run
1067    /// # use google_cloud_tasks_v2::model::DeleteTaskRequest;
1068    /// let x = DeleteTaskRequest::new().set_name("example");
1069    /// ```
1070    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1071        self.name = v.into();
1072        self
1073    }
1074}
1075
1076impl wkt::message::Message for DeleteTaskRequest {
1077    fn typename() -> &'static str {
1078        "type.googleapis.com/google.cloud.tasks.v2.DeleteTaskRequest"
1079    }
1080}
1081
1082/// Request message for forcing a task to run now using
1083/// [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask].
1084///
1085/// [google.cloud.tasks.v2.CloudTasks.RunTask]: crate::client::CloudTasks::run_task
1086#[derive(Clone, Default, PartialEq)]
1087#[non_exhaustive]
1088pub struct RunTaskRequest {
1089    /// Required. The task name. For example:
1090    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
1091    pub name: std::string::String,
1092
1093    /// The response_view specifies which subset of the
1094    /// [Task][google.cloud.tasks.v2.Task] will be returned.
1095    ///
1096    /// By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC];
1097    /// not all information is retrieved by default because some data, such as
1098    /// payloads, might be desirable to return only when needed because
1099    /// of its large size or because of the sensitivity of data that it
1100    /// contains.
1101    ///
1102    /// Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
1103    /// `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
1104    /// permission on the [Task][google.cloud.tasks.v2.Task] resource.
1105    ///
1106    /// [google.cloud.tasks.v2.Task]: crate::model::Task
1107    /// [google.cloud.tasks.v2.Task.View.BASIC]: crate::model::task::View::Basic
1108    /// [google.cloud.tasks.v2.Task.View.FULL]: crate::model::task::View::Full
1109    pub response_view: crate::model::task::View,
1110
1111    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1112}
1113
1114impl RunTaskRequest {
1115    pub fn new() -> Self {
1116        std::default::Default::default()
1117    }
1118
1119    /// Sets the value of [name][crate::model::RunTaskRequest::name].
1120    ///
1121    /// # Example
1122    /// ```ignore,no_run
1123    /// # use google_cloud_tasks_v2::model::RunTaskRequest;
1124    /// let x = RunTaskRequest::new().set_name("example");
1125    /// ```
1126    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1127        self.name = v.into();
1128        self
1129    }
1130
1131    /// Sets the value of [response_view][crate::model::RunTaskRequest::response_view].
1132    ///
1133    /// # Example
1134    /// ```ignore,no_run
1135    /// # use google_cloud_tasks_v2::model::RunTaskRequest;
1136    /// use google_cloud_tasks_v2::model::task::View;
1137    /// let x0 = RunTaskRequest::new().set_response_view(View::Basic);
1138    /// let x1 = RunTaskRequest::new().set_response_view(View::Full);
1139    /// ```
1140    pub fn set_response_view<T: std::convert::Into<crate::model::task::View>>(
1141        mut self,
1142        v: T,
1143    ) -> Self {
1144        self.response_view = v.into();
1145        self
1146    }
1147}
1148
1149impl wkt::message::Message for RunTaskRequest {
1150    fn typename() -> &'static str {
1151        "type.googleapis.com/google.cloud.tasks.v2.RunTaskRequest"
1152    }
1153}
1154
1155/// A queue is a container of related tasks. Queues are configured to manage
1156/// how those tasks are dispatched. Configurable properties include rate limits,
1157/// retry options, queue types, and others.
1158#[derive(Clone, Default, PartialEq)]
1159#[non_exhaustive]
1160pub struct Queue {
1161    /// Caller-specified and required in
1162    /// [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue], after which it
1163    /// becomes output only.
1164    ///
1165    /// The queue name.
1166    ///
1167    /// The queue name must have the following format:
1168    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`
1169    ///
1170    /// * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
1171    ///   hyphens (-), colons (:), or periods (.).
1172    ///   For more information, see
1173    ///   [Identifying
1174    ///   projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
1175    /// * `LOCATION_ID` is the canonical ID for the queue's location.
1176    ///   The list of available locations can be obtained by calling
1177    ///   [ListLocations][google.cloud.location.Locations.ListLocations].
1178    ///   For more information, see <https://cloud.google.com/about/locations/>.
1179    /// * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
1180    ///   hyphens (-). The maximum length is 100 characters.
1181    ///
1182    /// [google.cloud.tasks.v2.CloudTasks.CreateQueue]: crate::client::CloudTasks::create_queue
1183    pub name: std::string::String,
1184
1185    /// Overrides for
1186    /// [task-level
1187    /// app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
1188    /// These settings apply only to
1189    /// [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in this
1190    /// queue. [Http tasks][google.cloud.tasks.v2.HttpRequest] are not affected.
1191    ///
1192    /// If set, `app_engine_routing_override` is used for all
1193    /// [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in the
1194    /// queue, no matter what the setting is for the [task-level
1195    /// app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
1196    ///
1197    /// [google.cloud.tasks.v2.AppEngineHttpRequest]: crate::model::AppEngineHttpRequest
1198    /// [google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]: crate::model::AppEngineHttpRequest::app_engine_routing
1199    /// [google.cloud.tasks.v2.HttpRequest]: crate::model::HttpRequest
1200    pub app_engine_routing_override: std::option::Option<crate::model::AppEngineRouting>,
1201
1202    /// Rate limits for task dispatches.
1203    ///
1204    /// [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] and
1205    /// [retry_config][google.cloud.tasks.v2.Queue.retry_config] are related
1206    /// because they both control task attempts. However they control task attempts
1207    /// in different ways:
1208    ///
1209    /// * [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] controls the total
1210    ///   rate of
1211    ///   dispatches from a queue (i.e. all traffic dispatched from the
1212    ///   queue, regardless of whether the dispatch is from a first
1213    ///   attempt or a retry).
1214    /// * [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls what
1215    ///   happens to
1216    ///   particular a task after its first attempt fails. That is,
1217    ///   [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls task
1218    ///   retries (the second attempt, third attempt, etc).
1219    ///
1220    /// The queue's actual dispatch rate is the result of:
1221    ///
1222    /// * Number of tasks in the queue
1223    /// * User-specified throttling:
1224    ///   [rate_limits][google.cloud.tasks.v2.Queue.rate_limits],
1225    ///   [retry_config][google.cloud.tasks.v2.Queue.retry_config], and the
1226    ///   [queue's state][google.cloud.tasks.v2.Queue.state].
1227    /// * System throttling due to `429` (Too Many Requests) or `503` (Service
1228    ///   Unavailable) responses from the worker, high error rates, or to smooth
1229    ///   sudden large traffic spikes.
1230    ///
1231    /// [google.cloud.tasks.v2.Queue.rate_limits]: crate::model::Queue::rate_limits
1232    /// [google.cloud.tasks.v2.Queue.retry_config]: crate::model::Queue::retry_config
1233    /// [google.cloud.tasks.v2.Queue.state]: crate::model::Queue::state
1234    pub rate_limits: std::option::Option<crate::model::RateLimits>,
1235
1236    /// Settings that determine the retry behavior.
1237    ///
1238    /// * For tasks created using Cloud Tasks: the queue-level retry settings
1239    ///   apply to all tasks in the queue that were created using Cloud Tasks.
1240    ///   Retry settings cannot be set on individual tasks.
1241    /// * For tasks created using the App Engine SDK: the queue-level retry
1242    ///   settings apply to all tasks in the queue which do not have retry settings
1243    ///   explicitly set on the task and were created by the App Engine SDK. See
1244    ///   [App Engine
1245    ///   documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks).
1246    pub retry_config: std::option::Option<crate::model::RetryConfig>,
1247
1248    /// Output only. The state of the queue.
1249    ///
1250    /// `state` can only be changed by calling
1251    /// [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue],
1252    /// [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue], or uploading
1253    /// [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref).
1254    /// [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] cannot be used
1255    /// to change `state`.
1256    ///
1257    /// [google.cloud.tasks.v2.CloudTasks.PauseQueue]: crate::client::CloudTasks::pause_queue
1258    /// [google.cloud.tasks.v2.CloudTasks.ResumeQueue]: crate::client::CloudTasks::resume_queue
1259    /// [google.cloud.tasks.v2.CloudTasks.UpdateQueue]: crate::client::CloudTasks::update_queue
1260    pub state: crate::model::queue::State,
1261
1262    /// Output only. The last time this queue was purged.
1263    ///
1264    /// All tasks that were [created][google.cloud.tasks.v2.Task.create_time]
1265    /// before this time were purged.
1266    ///
1267    /// A queue can be purged using
1268    /// [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue], the [App Engine
1269    /// Task Queue SDK, or the Cloud
1270    /// Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue).
1271    ///
1272    /// Purge time will be truncated to the nearest microsecond. Purge
1273    /// time will be unset if the queue has never been purged.
1274    ///
1275    /// [google.cloud.tasks.v2.CloudTasks.PurgeQueue]: crate::client::CloudTasks::purge_queue
1276    /// [google.cloud.tasks.v2.Task.create_time]: crate::model::Task::create_time
1277    pub purge_time: std::option::Option<wkt::Timestamp>,
1278
1279    /// Configuration options for writing logs to
1280    /// [Stackdriver Logging](https://cloud.google.com/logging/docs/). If this
1281    /// field is unset, then no logs are written.
1282    pub stackdriver_logging_config: std::option::Option<crate::model::StackdriverLoggingConfig>,
1283
1284    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1285}
1286
1287impl Queue {
1288    pub fn new() -> Self {
1289        std::default::Default::default()
1290    }
1291
1292    /// Sets the value of [name][crate::model::Queue::name].
1293    ///
1294    /// # Example
1295    /// ```ignore,no_run
1296    /// # use google_cloud_tasks_v2::model::Queue;
1297    /// let x = Queue::new().set_name("example");
1298    /// ```
1299    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1300        self.name = v.into();
1301        self
1302    }
1303
1304    /// Sets the value of [app_engine_routing_override][crate::model::Queue::app_engine_routing_override].
1305    ///
1306    /// # Example
1307    /// ```ignore,no_run
1308    /// # use google_cloud_tasks_v2::model::Queue;
1309    /// use google_cloud_tasks_v2::model::AppEngineRouting;
1310    /// let x = Queue::new().set_app_engine_routing_override(AppEngineRouting::default()/* use setters */);
1311    /// ```
1312    pub fn set_app_engine_routing_override<T>(mut self, v: T) -> Self
1313    where
1314        T: std::convert::Into<crate::model::AppEngineRouting>,
1315    {
1316        self.app_engine_routing_override = std::option::Option::Some(v.into());
1317        self
1318    }
1319
1320    /// Sets or clears the value of [app_engine_routing_override][crate::model::Queue::app_engine_routing_override].
1321    ///
1322    /// # Example
1323    /// ```ignore,no_run
1324    /// # use google_cloud_tasks_v2::model::Queue;
1325    /// use google_cloud_tasks_v2::model::AppEngineRouting;
1326    /// let x = Queue::new().set_or_clear_app_engine_routing_override(Some(AppEngineRouting::default()/* use setters */));
1327    /// let x = Queue::new().set_or_clear_app_engine_routing_override(None::<AppEngineRouting>);
1328    /// ```
1329    pub fn set_or_clear_app_engine_routing_override<T>(mut self, v: std::option::Option<T>) -> Self
1330    where
1331        T: std::convert::Into<crate::model::AppEngineRouting>,
1332    {
1333        self.app_engine_routing_override = v.map(|x| x.into());
1334        self
1335    }
1336
1337    /// Sets the value of [rate_limits][crate::model::Queue::rate_limits].
1338    ///
1339    /// # Example
1340    /// ```ignore,no_run
1341    /// # use google_cloud_tasks_v2::model::Queue;
1342    /// use google_cloud_tasks_v2::model::RateLimits;
1343    /// let x = Queue::new().set_rate_limits(RateLimits::default()/* use setters */);
1344    /// ```
1345    pub fn set_rate_limits<T>(mut self, v: T) -> Self
1346    where
1347        T: std::convert::Into<crate::model::RateLimits>,
1348    {
1349        self.rate_limits = std::option::Option::Some(v.into());
1350        self
1351    }
1352
1353    /// Sets or clears the value of [rate_limits][crate::model::Queue::rate_limits].
1354    ///
1355    /// # Example
1356    /// ```ignore,no_run
1357    /// # use google_cloud_tasks_v2::model::Queue;
1358    /// use google_cloud_tasks_v2::model::RateLimits;
1359    /// let x = Queue::new().set_or_clear_rate_limits(Some(RateLimits::default()/* use setters */));
1360    /// let x = Queue::new().set_or_clear_rate_limits(None::<RateLimits>);
1361    /// ```
1362    pub fn set_or_clear_rate_limits<T>(mut self, v: std::option::Option<T>) -> Self
1363    where
1364        T: std::convert::Into<crate::model::RateLimits>,
1365    {
1366        self.rate_limits = v.map(|x| x.into());
1367        self
1368    }
1369
1370    /// Sets the value of [retry_config][crate::model::Queue::retry_config].
1371    ///
1372    /// # Example
1373    /// ```ignore,no_run
1374    /// # use google_cloud_tasks_v2::model::Queue;
1375    /// use google_cloud_tasks_v2::model::RetryConfig;
1376    /// let x = Queue::new().set_retry_config(RetryConfig::default()/* use setters */);
1377    /// ```
1378    pub fn set_retry_config<T>(mut self, v: T) -> Self
1379    where
1380        T: std::convert::Into<crate::model::RetryConfig>,
1381    {
1382        self.retry_config = std::option::Option::Some(v.into());
1383        self
1384    }
1385
1386    /// Sets or clears the value of [retry_config][crate::model::Queue::retry_config].
1387    ///
1388    /// # Example
1389    /// ```ignore,no_run
1390    /// # use google_cloud_tasks_v2::model::Queue;
1391    /// use google_cloud_tasks_v2::model::RetryConfig;
1392    /// let x = Queue::new().set_or_clear_retry_config(Some(RetryConfig::default()/* use setters */));
1393    /// let x = Queue::new().set_or_clear_retry_config(None::<RetryConfig>);
1394    /// ```
1395    pub fn set_or_clear_retry_config<T>(mut self, v: std::option::Option<T>) -> Self
1396    where
1397        T: std::convert::Into<crate::model::RetryConfig>,
1398    {
1399        self.retry_config = v.map(|x| x.into());
1400        self
1401    }
1402
1403    /// Sets the value of [state][crate::model::Queue::state].
1404    ///
1405    /// # Example
1406    /// ```ignore,no_run
1407    /// # use google_cloud_tasks_v2::model::Queue;
1408    /// use google_cloud_tasks_v2::model::queue::State;
1409    /// let x0 = Queue::new().set_state(State::Running);
1410    /// let x1 = Queue::new().set_state(State::Paused);
1411    /// let x2 = Queue::new().set_state(State::Disabled);
1412    /// ```
1413    pub fn set_state<T: std::convert::Into<crate::model::queue::State>>(mut self, v: T) -> Self {
1414        self.state = v.into();
1415        self
1416    }
1417
1418    /// Sets the value of [purge_time][crate::model::Queue::purge_time].
1419    ///
1420    /// # Example
1421    /// ```ignore,no_run
1422    /// # use google_cloud_tasks_v2::model::Queue;
1423    /// use wkt::Timestamp;
1424    /// let x = Queue::new().set_purge_time(Timestamp::default()/* use setters */);
1425    /// ```
1426    pub fn set_purge_time<T>(mut self, v: T) -> Self
1427    where
1428        T: std::convert::Into<wkt::Timestamp>,
1429    {
1430        self.purge_time = std::option::Option::Some(v.into());
1431        self
1432    }
1433
1434    /// Sets or clears the value of [purge_time][crate::model::Queue::purge_time].
1435    ///
1436    /// # Example
1437    /// ```ignore,no_run
1438    /// # use google_cloud_tasks_v2::model::Queue;
1439    /// use wkt::Timestamp;
1440    /// let x = Queue::new().set_or_clear_purge_time(Some(Timestamp::default()/* use setters */));
1441    /// let x = Queue::new().set_or_clear_purge_time(None::<Timestamp>);
1442    /// ```
1443    pub fn set_or_clear_purge_time<T>(mut self, v: std::option::Option<T>) -> Self
1444    where
1445        T: std::convert::Into<wkt::Timestamp>,
1446    {
1447        self.purge_time = v.map(|x| x.into());
1448        self
1449    }
1450
1451    /// Sets the value of [stackdriver_logging_config][crate::model::Queue::stackdriver_logging_config].
1452    ///
1453    /// # Example
1454    /// ```ignore,no_run
1455    /// # use google_cloud_tasks_v2::model::Queue;
1456    /// use google_cloud_tasks_v2::model::StackdriverLoggingConfig;
1457    /// let x = Queue::new().set_stackdriver_logging_config(StackdriverLoggingConfig::default()/* use setters */);
1458    /// ```
1459    pub fn set_stackdriver_logging_config<T>(mut self, v: T) -> Self
1460    where
1461        T: std::convert::Into<crate::model::StackdriverLoggingConfig>,
1462    {
1463        self.stackdriver_logging_config = std::option::Option::Some(v.into());
1464        self
1465    }
1466
1467    /// Sets or clears the value of [stackdriver_logging_config][crate::model::Queue::stackdriver_logging_config].
1468    ///
1469    /// # Example
1470    /// ```ignore,no_run
1471    /// # use google_cloud_tasks_v2::model::Queue;
1472    /// use google_cloud_tasks_v2::model::StackdriverLoggingConfig;
1473    /// let x = Queue::new().set_or_clear_stackdriver_logging_config(Some(StackdriverLoggingConfig::default()/* use setters */));
1474    /// let x = Queue::new().set_or_clear_stackdriver_logging_config(None::<StackdriverLoggingConfig>);
1475    /// ```
1476    pub fn set_or_clear_stackdriver_logging_config<T>(mut self, v: std::option::Option<T>) -> Self
1477    where
1478        T: std::convert::Into<crate::model::StackdriverLoggingConfig>,
1479    {
1480        self.stackdriver_logging_config = v.map(|x| x.into());
1481        self
1482    }
1483}
1484
1485impl wkt::message::Message for Queue {
1486    fn typename() -> &'static str {
1487        "type.googleapis.com/google.cloud.tasks.v2.Queue"
1488    }
1489}
1490
1491/// Defines additional types related to [Queue].
1492pub mod queue {
1493    #[allow(unused_imports)]
1494    use super::*;
1495
1496    /// State of the queue.
1497    ///
1498    /// # Working with unknown values
1499    ///
1500    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1501    /// additional enum variants at any time. Adding new variants is not considered
1502    /// a breaking change. Applications should write their code in anticipation of:
1503    ///
1504    /// - New values appearing in future releases of the client library, **and**
1505    /// - New values received dynamically, without application changes.
1506    ///
1507    /// Please consult the [Working with enums] section in the user guide for some
1508    /// guidelines.
1509    ///
1510    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1511    #[derive(Clone, Debug, PartialEq)]
1512    #[non_exhaustive]
1513    pub enum State {
1514        /// Unspecified state.
1515        Unspecified,
1516        /// The queue is running. Tasks can be dispatched.
1517        ///
1518        /// If the queue was created using Cloud Tasks and the queue has
1519        /// had no activity (method calls or task dispatches) for 30 days,
1520        /// the queue may take a few minutes to re-activate. Some method
1521        /// calls may return [NOT_FOUND][google.rpc.Code.NOT_FOUND] and
1522        /// tasks may not be dispatched for a few minutes until the queue
1523        /// has been re-activated.
1524        Running,
1525        /// Tasks are paused by the user. If the queue is paused then Cloud
1526        /// Tasks will stop delivering tasks from it, but more tasks can
1527        /// still be added to it by the user.
1528        Paused,
1529        /// The queue is disabled.
1530        ///
1531        /// A queue becomes `DISABLED` when
1532        /// [queue.yaml](https://cloud.google.com/appengine/docs/python/config/queueref)
1533        /// or
1534        /// [queue.xml](https://cloud.google.com/appengine/docs/standard/java/config/queueref)
1535        /// is uploaded which does not contain the queue. You cannot directly disable
1536        /// a queue.
1537        ///
1538        /// When a queue is disabled, tasks can still be added to a queue
1539        /// but the tasks are not dispatched.
1540        ///
1541        /// To permanently delete this queue and all of its tasks, call
1542        /// [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue].
1543        ///
1544        /// [google.cloud.tasks.v2.CloudTasks.DeleteQueue]: crate::client::CloudTasks::delete_queue
1545        Disabled,
1546        /// If set, the enum was initialized with an unknown value.
1547        ///
1548        /// Applications can examine the value using [State::value] or
1549        /// [State::name].
1550        UnknownValue(state::UnknownValue),
1551    }
1552
1553    #[doc(hidden)]
1554    pub mod state {
1555        #[allow(unused_imports)]
1556        use super::*;
1557        #[derive(Clone, Debug, PartialEq)]
1558        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1559    }
1560
1561    impl State {
1562        /// Gets the enum value.
1563        ///
1564        /// Returns `None` if the enum contains an unknown value deserialized from
1565        /// the string representation of enums.
1566        pub fn value(&self) -> std::option::Option<i32> {
1567            match self {
1568                Self::Unspecified => std::option::Option::Some(0),
1569                Self::Running => std::option::Option::Some(1),
1570                Self::Paused => std::option::Option::Some(2),
1571                Self::Disabled => std::option::Option::Some(3),
1572                Self::UnknownValue(u) => u.0.value(),
1573            }
1574        }
1575
1576        /// Gets the enum value as a string.
1577        ///
1578        /// Returns `None` if the enum contains an unknown value deserialized from
1579        /// the integer representation of enums.
1580        pub fn name(&self) -> std::option::Option<&str> {
1581            match self {
1582                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1583                Self::Running => std::option::Option::Some("RUNNING"),
1584                Self::Paused => std::option::Option::Some("PAUSED"),
1585                Self::Disabled => std::option::Option::Some("DISABLED"),
1586                Self::UnknownValue(u) => u.0.name(),
1587            }
1588        }
1589    }
1590
1591    impl std::default::Default for State {
1592        fn default() -> Self {
1593            use std::convert::From;
1594            Self::from(0)
1595        }
1596    }
1597
1598    impl std::fmt::Display for State {
1599        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1600            wkt::internal::display_enum(f, self.name(), self.value())
1601        }
1602    }
1603
1604    impl std::convert::From<i32> for State {
1605        fn from(value: i32) -> Self {
1606            match value {
1607                0 => Self::Unspecified,
1608                1 => Self::Running,
1609                2 => Self::Paused,
1610                3 => Self::Disabled,
1611                _ => Self::UnknownValue(state::UnknownValue(
1612                    wkt::internal::UnknownEnumValue::Integer(value),
1613                )),
1614            }
1615        }
1616    }
1617
1618    impl std::convert::From<&str> for State {
1619        fn from(value: &str) -> Self {
1620            use std::string::ToString;
1621            match value {
1622                "STATE_UNSPECIFIED" => Self::Unspecified,
1623                "RUNNING" => Self::Running,
1624                "PAUSED" => Self::Paused,
1625                "DISABLED" => Self::Disabled,
1626                _ => Self::UnknownValue(state::UnknownValue(
1627                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1628                )),
1629            }
1630        }
1631    }
1632
1633    impl serde::ser::Serialize for State {
1634        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1635        where
1636            S: serde::Serializer,
1637        {
1638            match self {
1639                Self::Unspecified => serializer.serialize_i32(0),
1640                Self::Running => serializer.serialize_i32(1),
1641                Self::Paused => serializer.serialize_i32(2),
1642                Self::Disabled => serializer.serialize_i32(3),
1643                Self::UnknownValue(u) => u.0.serialize(serializer),
1644            }
1645        }
1646    }
1647
1648    impl<'de> serde::de::Deserialize<'de> for State {
1649        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1650        where
1651            D: serde::Deserializer<'de>,
1652        {
1653            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1654                ".google.cloud.tasks.v2.Queue.State",
1655            ))
1656        }
1657    }
1658}
1659
1660/// Rate limits.
1661///
1662/// This message determines the maximum rate that tasks can be dispatched by a
1663/// queue, regardless of whether the dispatch is a first task attempt or a retry.
1664///
1665/// Note: The debugging command,
1666/// [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask], will run a task even if
1667/// the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits].
1668///
1669/// [google.cloud.tasks.v2.CloudTasks.RunTask]: crate::client::CloudTasks::run_task
1670/// [google.cloud.tasks.v2.RateLimits]: crate::model::RateLimits
1671#[derive(Clone, Default, PartialEq)]
1672#[non_exhaustive]
1673pub struct RateLimits {
1674    /// The maximum rate at which tasks are dispatched from this queue.
1675    ///
1676    /// If unspecified when the queue is created, Cloud Tasks will pick the
1677    /// default.
1678    ///
1679    /// * The maximum allowed value is 500.
1680    ///
1681    /// This field has the same meaning as
1682    /// [rate in
1683    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate).
1684    pub max_dispatches_per_second: f64,
1685
1686    /// Output only. The max burst size.
1687    ///
1688    /// Max burst size limits how fast tasks in queue are processed when
1689    /// many tasks are in the queue and the rate is high. This field
1690    /// allows the queue to have a high rate so processing starts shortly
1691    /// after a task is enqueued, but still limits resource usage when
1692    /// many tasks are enqueued in a short period of time.
1693    ///
1694    /// The [token bucket](https://wikipedia.org/wiki/Token_Bucket)
1695    /// algorithm is used to control the rate of task dispatches. Each
1696    /// queue has a token bucket that holds tokens, up to the maximum
1697    /// specified by `max_burst_size`. Each time a task is dispatched, a
1698    /// token is removed from the bucket. Tasks will be dispatched until
1699    /// the queue's bucket runs out of tokens. The bucket will be
1700    /// continuously refilled with new tokens based on
1701    /// [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
1702    ///
1703    /// Cloud Tasks will pick the value of `max_burst_size` based on the
1704    /// value of
1705    /// [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second].
1706    ///
1707    /// For queues that were created or updated using
1708    /// `queue.yaml/xml`, `max_burst_size` is equal to
1709    /// [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size).
1710    /// Since `max_burst_size` is output only, if
1711    /// [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] is called on a
1712    /// queue created by `queue.yaml/xml`, `max_burst_size` will be reset based on
1713    /// the value of
1714    /// [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second],
1715    /// regardless of whether
1716    /// [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]
1717    /// is updated.
1718    ///
1719    /// [google.cloud.tasks.v2.CloudTasks.UpdateQueue]: crate::client::CloudTasks::update_queue
1720    /// [google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]: crate::model::RateLimits::max_dispatches_per_second
1721    pub max_burst_size: i32,
1722
1723    /// The maximum number of concurrent tasks that Cloud Tasks allows
1724    /// to be dispatched for this queue. After this threshold has been
1725    /// reached, Cloud Tasks stops dispatching tasks until the number of
1726    /// concurrent requests decreases.
1727    ///
1728    /// If unspecified when the queue is created, Cloud Tasks will pick the
1729    /// default.
1730    ///
1731    /// The maximum allowed value is 5,000.
1732    ///
1733    /// This field has the same meaning as
1734    /// [max_concurrent_requests in
1735    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests).
1736    pub max_concurrent_dispatches: i32,
1737
1738    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1739}
1740
1741impl RateLimits {
1742    pub fn new() -> Self {
1743        std::default::Default::default()
1744    }
1745
1746    /// Sets the value of [max_dispatches_per_second][crate::model::RateLimits::max_dispatches_per_second].
1747    ///
1748    /// # Example
1749    /// ```ignore,no_run
1750    /// # use google_cloud_tasks_v2::model::RateLimits;
1751    /// let x = RateLimits::new().set_max_dispatches_per_second(42.0);
1752    /// ```
1753    pub fn set_max_dispatches_per_second<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
1754        self.max_dispatches_per_second = v.into();
1755        self
1756    }
1757
1758    /// Sets the value of [max_burst_size][crate::model::RateLimits::max_burst_size].
1759    ///
1760    /// # Example
1761    /// ```ignore,no_run
1762    /// # use google_cloud_tasks_v2::model::RateLimits;
1763    /// let x = RateLimits::new().set_max_burst_size(42);
1764    /// ```
1765    pub fn set_max_burst_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1766        self.max_burst_size = v.into();
1767        self
1768    }
1769
1770    /// Sets the value of [max_concurrent_dispatches][crate::model::RateLimits::max_concurrent_dispatches].
1771    ///
1772    /// # Example
1773    /// ```ignore,no_run
1774    /// # use google_cloud_tasks_v2::model::RateLimits;
1775    /// let x = RateLimits::new().set_max_concurrent_dispatches(42);
1776    /// ```
1777    pub fn set_max_concurrent_dispatches<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1778        self.max_concurrent_dispatches = v.into();
1779        self
1780    }
1781}
1782
1783impl wkt::message::Message for RateLimits {
1784    fn typename() -> &'static str {
1785        "type.googleapis.com/google.cloud.tasks.v2.RateLimits"
1786    }
1787}
1788
1789/// Retry config.
1790///
1791/// These settings determine when a failed task attempt is retried.
1792#[derive(Clone, Default, PartialEq)]
1793#[non_exhaustive]
1794pub struct RetryConfig {
1795    /// Number of attempts per task.
1796    ///
1797    /// Cloud Tasks will attempt the task `max_attempts` times (that is, if the
1798    /// first attempt fails, then there will be `max_attempts - 1` retries). Must
1799    /// be >= -1.
1800    ///
1801    /// If unspecified when the queue is created, Cloud Tasks will pick the
1802    /// default.
1803    ///
1804    /// -1 indicates unlimited attempts.
1805    ///
1806    /// This field has the same meaning as
1807    /// [task_retry_limit in
1808    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1809    pub max_attempts: i32,
1810
1811    /// If positive, `max_retry_duration` specifies the time limit for
1812    /// retrying a failed task, measured from when the task was first
1813    /// attempted. Once `max_retry_duration` time has passed *and* the
1814    /// task has been attempted
1815    /// [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times, no
1816    /// further attempts will be made and the task will be deleted.
1817    ///
1818    /// If zero, then the task age is unlimited.
1819    ///
1820    /// If unspecified when the queue is created, Cloud Tasks will pick the
1821    /// default.
1822    ///
1823    /// `max_retry_duration` will be truncated to the nearest second.
1824    ///
1825    /// This field has the same meaning as
1826    /// [task_age_limit in
1827    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1828    ///
1829    /// [google.cloud.tasks.v2.RetryConfig.max_attempts]: crate::model::RetryConfig::max_attempts
1830    pub max_retry_duration: std::option::Option<wkt::Duration>,
1831
1832    /// A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for
1833    /// retry between [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff]
1834    /// and [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration
1835    /// after it fails, if the queue's
1836    /// [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task
1837    /// should be retried.
1838    ///
1839    /// If unspecified when the queue is created, Cloud Tasks will pick the
1840    /// default.
1841    ///
1842    /// `min_backoff` will be truncated to the nearest second.
1843    ///
1844    /// This field has the same meaning as
1845    /// [min_backoff_seconds in
1846    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1847    ///
1848    /// [google.cloud.tasks.v2.RetryConfig]: crate::model::RetryConfig
1849    /// [google.cloud.tasks.v2.RetryConfig.max_backoff]: crate::model::RetryConfig::max_backoff
1850    /// [google.cloud.tasks.v2.RetryConfig.min_backoff]: crate::model::RetryConfig::min_backoff
1851    /// [google.cloud.tasks.v2.Task.schedule_time]: crate::model::Task::schedule_time
1852    pub min_backoff: std::option::Option<wkt::Duration>,
1853
1854    /// A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for
1855    /// retry between [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff]
1856    /// and [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration
1857    /// after it fails, if the queue's
1858    /// [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task
1859    /// should be retried.
1860    ///
1861    /// If unspecified when the queue is created, Cloud Tasks will pick the
1862    /// default.
1863    ///
1864    /// `max_backoff` will be truncated to the nearest second.
1865    ///
1866    /// This field has the same meaning as
1867    /// [max_backoff_seconds in
1868    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1869    ///
1870    /// [google.cloud.tasks.v2.RetryConfig]: crate::model::RetryConfig
1871    /// [google.cloud.tasks.v2.RetryConfig.max_backoff]: crate::model::RetryConfig::max_backoff
1872    /// [google.cloud.tasks.v2.RetryConfig.min_backoff]: crate::model::RetryConfig::min_backoff
1873    /// [google.cloud.tasks.v2.Task.schedule_time]: crate::model::Task::schedule_time
1874    pub max_backoff: std::option::Option<wkt::Duration>,
1875
1876    /// The time between retries will double `max_doublings` times.
1877    ///
1878    /// A task's retry interval starts at
1879    /// [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff], then doubles
1880    /// `max_doublings` times, then increases linearly, and finally
1881    /// retries at intervals of
1882    /// [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] up to
1883    /// [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times.
1884    ///
1885    /// For example, if
1886    /// [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] is 10s,
1887    /// [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] is 300s, and
1888    /// `max_doublings` is 3, then the a task will first be retried in
1889    /// 10s. The retry interval will double three times, and then
1890    /// increase linearly by 2^3 * 10s.  Finally, the task will retry at
1891    /// intervals of [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff]
1892    /// until the task has been attempted
1893    /// [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times. Thus,
1894    /// the requests will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, ....
1895    ///
1896    /// If unspecified when the queue is created, Cloud Tasks will pick the
1897    /// default.
1898    ///
1899    /// This field has the same meaning as
1900    /// [max_doublings in
1901    /// queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters).
1902    ///
1903    /// [google.cloud.tasks.v2.RetryConfig.max_attempts]: crate::model::RetryConfig::max_attempts
1904    /// [google.cloud.tasks.v2.RetryConfig.max_backoff]: crate::model::RetryConfig::max_backoff
1905    /// [google.cloud.tasks.v2.RetryConfig.min_backoff]: crate::model::RetryConfig::min_backoff
1906    pub max_doublings: i32,
1907
1908    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1909}
1910
1911impl RetryConfig {
1912    pub fn new() -> Self {
1913        std::default::Default::default()
1914    }
1915
1916    /// Sets the value of [max_attempts][crate::model::RetryConfig::max_attempts].
1917    ///
1918    /// # Example
1919    /// ```ignore,no_run
1920    /// # use google_cloud_tasks_v2::model::RetryConfig;
1921    /// let x = RetryConfig::new().set_max_attempts(42);
1922    /// ```
1923    pub fn set_max_attempts<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
1924        self.max_attempts = v.into();
1925        self
1926    }
1927
1928    /// Sets the value of [max_retry_duration][crate::model::RetryConfig::max_retry_duration].
1929    ///
1930    /// # Example
1931    /// ```ignore,no_run
1932    /// # use google_cloud_tasks_v2::model::RetryConfig;
1933    /// use wkt::Duration;
1934    /// let x = RetryConfig::new().set_max_retry_duration(Duration::default()/* use setters */);
1935    /// ```
1936    pub fn set_max_retry_duration<T>(mut self, v: T) -> Self
1937    where
1938        T: std::convert::Into<wkt::Duration>,
1939    {
1940        self.max_retry_duration = std::option::Option::Some(v.into());
1941        self
1942    }
1943
1944    /// Sets or clears the value of [max_retry_duration][crate::model::RetryConfig::max_retry_duration].
1945    ///
1946    /// # Example
1947    /// ```ignore,no_run
1948    /// # use google_cloud_tasks_v2::model::RetryConfig;
1949    /// use wkt::Duration;
1950    /// let x = RetryConfig::new().set_or_clear_max_retry_duration(Some(Duration::default()/* use setters */));
1951    /// let x = RetryConfig::new().set_or_clear_max_retry_duration(None::<Duration>);
1952    /// ```
1953    pub fn set_or_clear_max_retry_duration<T>(mut self, v: std::option::Option<T>) -> Self
1954    where
1955        T: std::convert::Into<wkt::Duration>,
1956    {
1957        self.max_retry_duration = v.map(|x| x.into());
1958        self
1959    }
1960
1961    /// Sets the value of [min_backoff][crate::model::RetryConfig::min_backoff].
1962    ///
1963    /// # Example
1964    /// ```ignore,no_run
1965    /// # use google_cloud_tasks_v2::model::RetryConfig;
1966    /// use wkt::Duration;
1967    /// let x = RetryConfig::new().set_min_backoff(Duration::default()/* use setters */);
1968    /// ```
1969    pub fn set_min_backoff<T>(mut self, v: T) -> Self
1970    where
1971        T: std::convert::Into<wkt::Duration>,
1972    {
1973        self.min_backoff = std::option::Option::Some(v.into());
1974        self
1975    }
1976
1977    /// Sets or clears the value of [min_backoff][crate::model::RetryConfig::min_backoff].
1978    ///
1979    /// # Example
1980    /// ```ignore,no_run
1981    /// # use google_cloud_tasks_v2::model::RetryConfig;
1982    /// use wkt::Duration;
1983    /// let x = RetryConfig::new().set_or_clear_min_backoff(Some(Duration::default()/* use setters */));
1984    /// let x = RetryConfig::new().set_or_clear_min_backoff(None::<Duration>);
1985    /// ```
1986    pub fn set_or_clear_min_backoff<T>(mut self, v: std::option::Option<T>) -> Self
1987    where
1988        T: std::convert::Into<wkt::Duration>,
1989    {
1990        self.min_backoff = v.map(|x| x.into());
1991        self
1992    }
1993
1994    /// Sets the value of [max_backoff][crate::model::RetryConfig::max_backoff].
1995    ///
1996    /// # Example
1997    /// ```ignore,no_run
1998    /// # use google_cloud_tasks_v2::model::RetryConfig;
1999    /// use wkt::Duration;
2000    /// let x = RetryConfig::new().set_max_backoff(Duration::default()/* use setters */);
2001    /// ```
2002    pub fn set_max_backoff<T>(mut self, v: T) -> Self
2003    where
2004        T: std::convert::Into<wkt::Duration>,
2005    {
2006        self.max_backoff = std::option::Option::Some(v.into());
2007        self
2008    }
2009
2010    /// Sets or clears the value of [max_backoff][crate::model::RetryConfig::max_backoff].
2011    ///
2012    /// # Example
2013    /// ```ignore,no_run
2014    /// # use google_cloud_tasks_v2::model::RetryConfig;
2015    /// use wkt::Duration;
2016    /// let x = RetryConfig::new().set_or_clear_max_backoff(Some(Duration::default()/* use setters */));
2017    /// let x = RetryConfig::new().set_or_clear_max_backoff(None::<Duration>);
2018    /// ```
2019    pub fn set_or_clear_max_backoff<T>(mut self, v: std::option::Option<T>) -> Self
2020    where
2021        T: std::convert::Into<wkt::Duration>,
2022    {
2023        self.max_backoff = v.map(|x| x.into());
2024        self
2025    }
2026
2027    /// Sets the value of [max_doublings][crate::model::RetryConfig::max_doublings].
2028    ///
2029    /// # Example
2030    /// ```ignore,no_run
2031    /// # use google_cloud_tasks_v2::model::RetryConfig;
2032    /// let x = RetryConfig::new().set_max_doublings(42);
2033    /// ```
2034    pub fn set_max_doublings<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2035        self.max_doublings = v.into();
2036        self
2037    }
2038}
2039
2040impl wkt::message::Message for RetryConfig {
2041    fn typename() -> &'static str {
2042        "type.googleapis.com/google.cloud.tasks.v2.RetryConfig"
2043    }
2044}
2045
2046/// Configuration options for writing logs to
2047/// [Stackdriver Logging](https://cloud.google.com/logging/docs/).
2048#[derive(Clone, Default, PartialEq)]
2049#[non_exhaustive]
2050pub struct StackdriverLoggingConfig {
2051    /// Specifies the fraction of operations to write to
2052    /// [Stackdriver Logging](https://cloud.google.com/logging/docs/).
2053    /// This field may contain any value between 0.0 and 1.0, inclusive.
2054    /// 0.0 is the default and means that no operations are logged.
2055    pub sampling_ratio: f64,
2056
2057    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2058}
2059
2060impl StackdriverLoggingConfig {
2061    pub fn new() -> Self {
2062        std::default::Default::default()
2063    }
2064
2065    /// Sets the value of [sampling_ratio][crate::model::StackdriverLoggingConfig::sampling_ratio].
2066    ///
2067    /// # Example
2068    /// ```ignore,no_run
2069    /// # use google_cloud_tasks_v2::model::StackdriverLoggingConfig;
2070    /// let x = StackdriverLoggingConfig::new().set_sampling_ratio(42.0);
2071    /// ```
2072    pub fn set_sampling_ratio<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
2073        self.sampling_ratio = v.into();
2074        self
2075    }
2076}
2077
2078impl wkt::message::Message for StackdriverLoggingConfig {
2079    fn typename() -> &'static str {
2080        "type.googleapis.com/google.cloud.tasks.v2.StackdriverLoggingConfig"
2081    }
2082}
2083
2084/// HTTP request.
2085///
2086/// The task will be pushed to the worker as an HTTP request. If the worker
2087/// or the redirected worker acknowledges the task by returning a successful HTTP
2088/// response code ([`200` - `299`]), the task will be removed from the queue. If
2089/// any other HTTP response code is returned or no response is received, the
2090/// task will be retried according to the following:
2091///
2092/// * User-specified throttling: [retry
2093///   configuration][google.cloud.tasks.v2.Queue.retry_config],
2094///   [rate limits][google.cloud.tasks.v2.Queue.rate_limits], and the [queue's
2095///   state][google.cloud.tasks.v2.Queue.state].
2096///
2097/// * System throttling: To prevent the worker from overloading, Cloud Tasks may
2098///   temporarily reduce the queue's effective rate. User-specified settings
2099///   will not be changed.
2100///
2101///
2102/// System throttling happens because:
2103///
2104/// * Cloud Tasks backs off on all errors. Normally the backoff specified in
2105///   [rate limits][google.cloud.tasks.v2.Queue.rate_limits] will be used. But
2106///   if the worker returns `429` (Too Many Requests), `503` (Service
2107///   Unavailable), or the rate of errors is high, Cloud Tasks will use a
2108///   higher backoff rate. The retry specified in the `Retry-After` HTTP
2109///   response header is considered.
2110///
2111/// * To prevent traffic spikes and to smooth sudden increases in traffic,
2112///   dispatches ramp up slowly when the queue is newly created or idle and
2113///   if large numbers of tasks suddenly become available to dispatch (due to
2114///   spikes in create task rates, the queue being unpaused, or many tasks
2115///   that are scheduled at the same time).
2116///
2117///
2118/// [google.cloud.tasks.v2.Queue.rate_limits]: crate::model::Queue::rate_limits
2119/// [google.cloud.tasks.v2.Queue.retry_config]: crate::model::Queue::retry_config
2120/// [google.cloud.tasks.v2.Queue.state]: crate::model::Queue::state
2121#[derive(Clone, Default, PartialEq)]
2122#[non_exhaustive]
2123pub struct HttpRequest {
2124    /// Required. The full url path that the request will be sent to.
2125    ///
2126    /// This string must begin with either "http://" or "https://". Some examples
2127    /// are: `<http://acme.com>` and `<https://acme.com/sales:8080>`. Cloud Tasks will
2128    /// encode some characters for safety and compatibility. The maximum allowed
2129    /// URL length is 2083 characters after encoding.
2130    ///
2131    /// The `Location` header response from a redirect response [`300` - `399`]
2132    /// may be followed. The redirect is not counted as a separate attempt.
2133    pub url: std::string::String,
2134
2135    /// The HTTP method to use for the request. The default is POST.
2136    pub http_method: crate::model::HttpMethod,
2137
2138    /// HTTP request headers.
2139    ///
2140    /// This map contains the header field names and values.
2141    /// Headers can be set when the
2142    /// [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
2143    ///
2144    /// These headers represent a subset of the headers that will accompany the
2145    /// task's HTTP request. Some HTTP request headers will be ignored or replaced.
2146    ///
2147    /// A partial list of headers that will be ignored or replaced is:
2148    ///
2149    /// * Host: This will be computed by Cloud Tasks and derived from
2150    ///   [HttpRequest.url][google.cloud.tasks.v2.HttpRequest.url].
2151    /// * Content-Length: This will be computed by Cloud Tasks.
2152    /// * User-Agent: This will be set to `"Google-Cloud-Tasks"`.
2153    /// * `X-Google-*`: Google use only.
2154    /// * `X-AppEngine-*`: Google use only.
2155    ///
2156    /// `Content-Type` won't be set by Cloud Tasks. You can explicitly set
2157    /// `Content-Type` to a media type when the
2158    /// [task is created][google.cloud.tasks.v2beta3.CloudTasks.CreateTask].
2159    /// For example, `Content-Type` can be set to `"application/octet-stream"` or
2160    /// `"application/json"`.
2161    ///
2162    /// Headers which can have multiple values (according to RFC2616) can be
2163    /// specified using comma-separated values.
2164    ///
2165    /// The size of the headers must be less than 80KB.
2166    ///
2167    /// [google.cloud.tasks.v2.HttpRequest.url]: crate::model::HttpRequest::url
2168    pub headers: std::collections::HashMap<std::string::String, std::string::String>,
2169
2170    /// HTTP request body.
2171    ///
2172    /// A request body is allowed only if the
2173    /// [HTTP method][google.cloud.tasks.v2.HttpRequest.http_method] is POST, PUT,
2174    /// or PATCH. It is an error to set body on a task with an incompatible
2175    /// [HttpMethod][google.cloud.tasks.v2.HttpMethod].
2176    ///
2177    /// [google.cloud.tasks.v2.HttpMethod]: crate::model::HttpMethod
2178    /// [google.cloud.tasks.v2.HttpRequest.http_method]: crate::model::HttpRequest::http_method
2179    pub body: ::bytes::Bytes,
2180
2181    /// The mode for generating an `Authorization` header for HTTP requests.
2182    ///
2183    /// If specified, all `Authorization` headers in the
2184    /// [HttpRequest.headers][google.cloud.tasks.v2.HttpRequest.headers] field will
2185    /// be overridden.
2186    ///
2187    /// [google.cloud.tasks.v2.HttpRequest.headers]: crate::model::HttpRequest::headers
2188    pub authorization_header: std::option::Option<crate::model::http_request::AuthorizationHeader>,
2189
2190    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2191}
2192
2193impl HttpRequest {
2194    pub fn new() -> Self {
2195        std::default::Default::default()
2196    }
2197
2198    /// Sets the value of [url][crate::model::HttpRequest::url].
2199    ///
2200    /// # Example
2201    /// ```ignore,no_run
2202    /// # use google_cloud_tasks_v2::model::HttpRequest;
2203    /// let x = HttpRequest::new().set_url("example");
2204    /// ```
2205    pub fn set_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2206        self.url = v.into();
2207        self
2208    }
2209
2210    /// Sets the value of [http_method][crate::model::HttpRequest::http_method].
2211    ///
2212    /// # Example
2213    /// ```ignore,no_run
2214    /// # use google_cloud_tasks_v2::model::HttpRequest;
2215    /// use google_cloud_tasks_v2::model::HttpMethod;
2216    /// let x0 = HttpRequest::new().set_http_method(HttpMethod::Post);
2217    /// let x1 = HttpRequest::new().set_http_method(HttpMethod::Get);
2218    /// let x2 = HttpRequest::new().set_http_method(HttpMethod::Head);
2219    /// ```
2220    pub fn set_http_method<T: std::convert::Into<crate::model::HttpMethod>>(
2221        mut self,
2222        v: T,
2223    ) -> Self {
2224        self.http_method = v.into();
2225        self
2226    }
2227
2228    /// Sets the value of [headers][crate::model::HttpRequest::headers].
2229    ///
2230    /// # Example
2231    /// ```ignore,no_run
2232    /// # use google_cloud_tasks_v2::model::HttpRequest;
2233    /// let x = HttpRequest::new().set_headers([
2234    ///     ("key0", "abc"),
2235    ///     ("key1", "xyz"),
2236    /// ]);
2237    /// ```
2238    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
2239    where
2240        T: std::iter::IntoIterator<Item = (K, V)>,
2241        K: std::convert::Into<std::string::String>,
2242        V: std::convert::Into<std::string::String>,
2243    {
2244        use std::iter::Iterator;
2245        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2246        self
2247    }
2248
2249    /// Sets the value of [body][crate::model::HttpRequest::body].
2250    ///
2251    /// # Example
2252    /// ```ignore,no_run
2253    /// # use google_cloud_tasks_v2::model::HttpRequest;
2254    /// let x = HttpRequest::new().set_body(bytes::Bytes::from_static(b"example"));
2255    /// ```
2256    pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2257        self.body = v.into();
2258        self
2259    }
2260
2261    /// Sets the value of [authorization_header][crate::model::HttpRequest::authorization_header].
2262    ///
2263    /// Note that all the setters affecting `authorization_header` are mutually
2264    /// exclusive.
2265    ///
2266    /// # Example
2267    /// ```ignore,no_run
2268    /// # use google_cloud_tasks_v2::model::HttpRequest;
2269    /// use google_cloud_tasks_v2::model::OAuthToken;
2270    /// let x = HttpRequest::new().set_authorization_header(Some(
2271    ///     google_cloud_tasks_v2::model::http_request::AuthorizationHeader::OauthToken(OAuthToken::default().into())));
2272    /// ```
2273    pub fn set_authorization_header<
2274        T: std::convert::Into<std::option::Option<crate::model::http_request::AuthorizationHeader>>,
2275    >(
2276        mut self,
2277        v: T,
2278    ) -> Self {
2279        self.authorization_header = v.into();
2280        self
2281    }
2282
2283    /// The value of [authorization_header][crate::model::HttpRequest::authorization_header]
2284    /// if it holds a `OauthToken`, `None` if the field is not set or
2285    /// holds a different branch.
2286    pub fn oauth_token(&self) -> std::option::Option<&std::boxed::Box<crate::model::OAuthToken>> {
2287        #[allow(unreachable_patterns)]
2288        self.authorization_header.as_ref().and_then(|v| match v {
2289            crate::model::http_request::AuthorizationHeader::OauthToken(v) => {
2290                std::option::Option::Some(v)
2291            }
2292            _ => std::option::Option::None,
2293        })
2294    }
2295
2296    /// Sets the value of [authorization_header][crate::model::HttpRequest::authorization_header]
2297    /// to hold a `OauthToken`.
2298    ///
2299    /// Note that all the setters affecting `authorization_header` are
2300    /// mutually exclusive.
2301    ///
2302    /// # Example
2303    /// ```ignore,no_run
2304    /// # use google_cloud_tasks_v2::model::HttpRequest;
2305    /// use google_cloud_tasks_v2::model::OAuthToken;
2306    /// let x = HttpRequest::new().set_oauth_token(OAuthToken::default()/* use setters */);
2307    /// assert!(x.oauth_token().is_some());
2308    /// assert!(x.oidc_token().is_none());
2309    /// ```
2310    pub fn set_oauth_token<T: std::convert::Into<std::boxed::Box<crate::model::OAuthToken>>>(
2311        mut self,
2312        v: T,
2313    ) -> Self {
2314        self.authorization_header = std::option::Option::Some(
2315            crate::model::http_request::AuthorizationHeader::OauthToken(v.into()),
2316        );
2317        self
2318    }
2319
2320    /// The value of [authorization_header][crate::model::HttpRequest::authorization_header]
2321    /// if it holds a `OidcToken`, `None` if the field is not set or
2322    /// holds a different branch.
2323    pub fn oidc_token(&self) -> std::option::Option<&std::boxed::Box<crate::model::OidcToken>> {
2324        #[allow(unreachable_patterns)]
2325        self.authorization_header.as_ref().and_then(|v| match v {
2326            crate::model::http_request::AuthorizationHeader::OidcToken(v) => {
2327                std::option::Option::Some(v)
2328            }
2329            _ => std::option::Option::None,
2330        })
2331    }
2332
2333    /// Sets the value of [authorization_header][crate::model::HttpRequest::authorization_header]
2334    /// to hold a `OidcToken`.
2335    ///
2336    /// Note that all the setters affecting `authorization_header` are
2337    /// mutually exclusive.
2338    ///
2339    /// # Example
2340    /// ```ignore,no_run
2341    /// # use google_cloud_tasks_v2::model::HttpRequest;
2342    /// use google_cloud_tasks_v2::model::OidcToken;
2343    /// let x = HttpRequest::new().set_oidc_token(OidcToken::default()/* use setters */);
2344    /// assert!(x.oidc_token().is_some());
2345    /// assert!(x.oauth_token().is_none());
2346    /// ```
2347    pub fn set_oidc_token<T: std::convert::Into<std::boxed::Box<crate::model::OidcToken>>>(
2348        mut self,
2349        v: T,
2350    ) -> Self {
2351        self.authorization_header = std::option::Option::Some(
2352            crate::model::http_request::AuthorizationHeader::OidcToken(v.into()),
2353        );
2354        self
2355    }
2356}
2357
2358impl wkt::message::Message for HttpRequest {
2359    fn typename() -> &'static str {
2360        "type.googleapis.com/google.cloud.tasks.v2.HttpRequest"
2361    }
2362}
2363
2364/// Defines additional types related to [HttpRequest].
2365pub mod http_request {
2366    #[allow(unused_imports)]
2367    use super::*;
2368
2369    /// The mode for generating an `Authorization` header for HTTP requests.
2370    ///
2371    /// If specified, all `Authorization` headers in the
2372    /// [HttpRequest.headers][google.cloud.tasks.v2.HttpRequest.headers] field will
2373    /// be overridden.
2374    ///
2375    /// [google.cloud.tasks.v2.HttpRequest.headers]: crate::model::HttpRequest::headers
2376    #[derive(Clone, Debug, PartialEq)]
2377    #[non_exhaustive]
2378    pub enum AuthorizationHeader {
2379        /// If specified, an
2380        /// [OAuth token](https://developers.google.com/identity/protocols/OAuth2)
2381        /// will be generated and attached as an `Authorization` header in the HTTP
2382        /// request.
2383        ///
2384        /// This type of authorization should generally only be used when calling
2385        /// Google APIs hosted on *.googleapis.com.
2386        OauthToken(std::boxed::Box<crate::model::OAuthToken>),
2387        /// If specified, an
2388        /// [OIDC](https://developers.google.com/identity/protocols/OpenIDConnect)
2389        /// token will be generated and attached as an `Authorization` header in the
2390        /// HTTP request.
2391        ///
2392        /// This type of authorization can be used for many scenarios, including
2393        /// calling Cloud Run, or endpoints where you intend to validate the token
2394        /// yourself.
2395        OidcToken(std::boxed::Box<crate::model::OidcToken>),
2396    }
2397}
2398
2399/// App Engine HTTP request.
2400///
2401/// The message defines the HTTP request that is sent to an App Engine app when
2402/// the task is dispatched.
2403///
2404/// Using [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest]
2405/// requires
2406/// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control)
2407/// Google IAM permission for the project
2408/// and the following scope:
2409///
2410/// `<https://www.googleapis.com/auth/cloud-platform>`
2411///
2412/// The task will be delivered to the App Engine app which belongs to the same
2413/// project as the queue. For more information, see
2414/// [How Requests are
2415/// Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed)
2416/// and how routing is affected by
2417/// [dispatch
2418/// files](https://cloud.google.com/appengine/docs/python/config/dispatchref).
2419/// Traffic is encrypted during transport and never leaves Google datacenters.
2420/// Because this traffic is carried over a communication mechanism internal to
2421/// Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS).
2422/// The request to the handler, however, will appear to have used the HTTP
2423/// protocol.
2424///
2425/// The [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] used to
2426/// construct the URL that the task is delivered to can be set at the queue-level
2427/// or task-level:
2428///
2429/// * If [app_engine_routing_override is set on the
2430///   queue][google.cloud.tasks.v2.Queue.app_engine_routing_override], this value
2431///   is used for all tasks in the queue, no matter what the setting is for the
2432///   [task-level
2433///   app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
2434///
2435/// The `url` that the task will be sent to is:
2436///
2437/// * `url =` [host][google.cloud.tasks.v2.AppEngineRouting.host] `+`
2438///   [relative_uri][google.cloud.tasks.v2.AppEngineHttpRequest.relative_uri]
2439///
2440/// Tasks can be dispatched to secure app handlers, unsecure app handlers, and
2441/// URIs restricted with
2442/// [`login:
2443/// admin`](https://cloud.google.com/appengine/docs/standard/python/config/appref).
2444/// Because tasks are not run as any user, they cannot be dispatched to URIs
2445/// restricted with
2446/// [`login:
2447/// required`](https://cloud.google.com/appengine/docs/standard/python/config/appref)
2448/// Task dispatches also do not follow redirects.
2449///
2450/// The task attempt has succeeded if the app's request handler returns an HTTP
2451/// response code in the range [`200` - `299`]. The task attempt has failed if
2452/// the app's handler returns a non-2xx response code or Cloud Tasks does
2453/// not receive response before the
2454/// [deadline][google.cloud.tasks.v2.Task.dispatch_deadline]. Failed tasks will
2455/// be retried according to the [retry
2456/// configuration][google.cloud.tasks.v2.Queue.retry_config]. `503` (Service
2457/// Unavailable) is considered an App Engine system error instead of an
2458/// application error and will cause Cloud Tasks' traffic congestion control to
2459/// temporarily throttle the queue's dispatches. Unlike other types of task
2460/// targets, a `429` (Too Many Requests) response from an app handler does not
2461/// cause traffic congestion control to throttle the queue.
2462///
2463/// [google.cloud.tasks.v2.AppEngineHttpRequest]: crate::model::AppEngineHttpRequest
2464/// [google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]: crate::model::AppEngineHttpRequest::app_engine_routing
2465/// [google.cloud.tasks.v2.AppEngineHttpRequest.relative_uri]: crate::model::AppEngineHttpRequest::relative_uri
2466/// [google.cloud.tasks.v2.AppEngineRouting]: crate::model::AppEngineRouting
2467/// [google.cloud.tasks.v2.AppEngineRouting.host]: crate::model::AppEngineRouting::host
2468/// [google.cloud.tasks.v2.Queue.app_engine_routing_override]: crate::model::Queue::app_engine_routing_override
2469/// [google.cloud.tasks.v2.Queue.retry_config]: crate::model::Queue::retry_config
2470/// [google.cloud.tasks.v2.Task.dispatch_deadline]: crate::model::Task::dispatch_deadline
2471#[derive(Clone, Default, PartialEq)]
2472#[non_exhaustive]
2473pub struct AppEngineHttpRequest {
2474    /// The HTTP method to use for the request. The default is POST.
2475    ///
2476    /// The app's request handler for the task's target URL must be able to handle
2477    /// HTTP requests with this http_method, otherwise the task attempt fails with
2478    /// error code 405 (Method Not Allowed). See [Writing a push task request
2479    /// handler](https://cloud.google.com/appengine/docs/java/taskqueue/push/creating-handlers#writing_a_push_task_request_handler)
2480    /// and the App Engine documentation for your runtime on [How Requests are
2481    /// Handled](https://cloud.google.com/appengine/docs/standard/python3/how-requests-are-handled).
2482    pub http_method: crate::model::HttpMethod,
2483
2484    /// Task-level setting for App Engine routing.
2485    ///
2486    /// * If [app_engine_routing_override is set on the
2487    ///   queue][google.cloud.tasks.v2.Queue.app_engine_routing_override], this
2488    ///   value is used for all tasks in the queue, no matter what the setting is
2489    ///   for the [task-level
2490    ///   app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing].
2491    ///
2492    /// [google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]: crate::model::AppEngineHttpRequest::app_engine_routing
2493    /// [google.cloud.tasks.v2.Queue.app_engine_routing_override]: crate::model::Queue::app_engine_routing_override
2494    pub app_engine_routing: std::option::Option<crate::model::AppEngineRouting>,
2495
2496    /// The relative URI.
2497    ///
2498    /// The relative URI must begin with "/" and must be a valid HTTP relative URI.
2499    /// It can contain a path and query string arguments.
2500    /// If the relative URI is empty, then the root path "/" will be used.
2501    /// No spaces are allowed, and the maximum length allowed is 2083 characters.
2502    pub relative_uri: std::string::String,
2503
2504    /// HTTP request headers.
2505    ///
2506    /// This map contains the header field names and values.
2507    /// Headers can be set when the
2508    /// [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask].
2509    /// Repeated headers are not supported but a header value can contain commas.
2510    ///
2511    /// Cloud Tasks sets some headers to default values:
2512    ///
2513    /// * `User-Agent`: By default, this header is
2514    ///   `"AppEngine-Google; (+<http://code.google.com/appengine>)"`.
2515    ///   This header can be modified, but Cloud Tasks will append
2516    ///   `"AppEngine-Google; (+<http://code.google.com/appengine>)"` to the
2517    ///   modified `User-Agent`.
2518    ///
2519    /// If the task has a [body][google.cloud.tasks.v2.AppEngineHttpRequest.body],
2520    /// Cloud Tasks sets the following headers:
2521    ///
2522    /// * `Content-Type`: By default, the `Content-Type` header is set to
2523    ///   `"application/octet-stream"`. The default can be overridden by explicitly
2524    ///   setting `Content-Type` to a particular media type when the
2525    ///   [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask].
2526    ///   For example, `Content-Type` can be set to `"application/json"`.
2527    /// * `Content-Length`: This is computed by Cloud Tasks. This value is
2528    ///   output only.   It cannot be changed.
2529    ///
2530    /// The headers below cannot be set or overridden:
2531    ///
2532    /// * `Host`
2533    /// * `X-Google-*`
2534    /// * `X-AppEngine-*`
2535    ///
2536    /// In addition, Cloud Tasks sets some headers when the task is dispatched,
2537    /// such as headers containing information about the task; see
2538    /// [request
2539    /// headers](https://cloud.google.com/tasks/docs/creating-appengine-handlers#reading_request_headers).
2540    /// These headers are set only when the task is dispatched, so they are not
2541    /// visible when the task is returned in a Cloud Tasks response.
2542    ///
2543    /// Although there is no specific limit for the maximum number of headers or
2544    /// the size, there is a limit on the maximum size of the
2545    /// [Task][google.cloud.tasks.v2.Task]. For more information, see the
2546    /// [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] documentation.
2547    ///
2548    /// [google.cloud.tasks.v2.AppEngineHttpRequest.body]: crate::model::AppEngineHttpRequest::body
2549    /// [google.cloud.tasks.v2.CloudTasks.CreateTask]: crate::client::CloudTasks::create_task
2550    /// [google.cloud.tasks.v2.Task]: crate::model::Task
2551    pub headers: std::collections::HashMap<std::string::String, std::string::String>,
2552
2553    /// HTTP request body.
2554    ///
2555    /// A request body is allowed only if the HTTP method is POST or PUT. It is
2556    /// an error to set a body on a task with an incompatible
2557    /// [HttpMethod][google.cloud.tasks.v2.HttpMethod].
2558    ///
2559    /// [google.cloud.tasks.v2.HttpMethod]: crate::model::HttpMethod
2560    pub body: ::bytes::Bytes,
2561
2562    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2563}
2564
2565impl AppEngineHttpRequest {
2566    pub fn new() -> Self {
2567        std::default::Default::default()
2568    }
2569
2570    /// Sets the value of [http_method][crate::model::AppEngineHttpRequest::http_method].
2571    ///
2572    /// # Example
2573    /// ```ignore,no_run
2574    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2575    /// use google_cloud_tasks_v2::model::HttpMethod;
2576    /// let x0 = AppEngineHttpRequest::new().set_http_method(HttpMethod::Post);
2577    /// let x1 = AppEngineHttpRequest::new().set_http_method(HttpMethod::Get);
2578    /// let x2 = AppEngineHttpRequest::new().set_http_method(HttpMethod::Head);
2579    /// ```
2580    pub fn set_http_method<T: std::convert::Into<crate::model::HttpMethod>>(
2581        mut self,
2582        v: T,
2583    ) -> Self {
2584        self.http_method = v.into();
2585        self
2586    }
2587
2588    /// Sets the value of [app_engine_routing][crate::model::AppEngineHttpRequest::app_engine_routing].
2589    ///
2590    /// # Example
2591    /// ```ignore,no_run
2592    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2593    /// use google_cloud_tasks_v2::model::AppEngineRouting;
2594    /// let x = AppEngineHttpRequest::new().set_app_engine_routing(AppEngineRouting::default()/* use setters */);
2595    /// ```
2596    pub fn set_app_engine_routing<T>(mut self, v: T) -> Self
2597    where
2598        T: std::convert::Into<crate::model::AppEngineRouting>,
2599    {
2600        self.app_engine_routing = std::option::Option::Some(v.into());
2601        self
2602    }
2603
2604    /// Sets or clears the value of [app_engine_routing][crate::model::AppEngineHttpRequest::app_engine_routing].
2605    ///
2606    /// # Example
2607    /// ```ignore,no_run
2608    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2609    /// use google_cloud_tasks_v2::model::AppEngineRouting;
2610    /// let x = AppEngineHttpRequest::new().set_or_clear_app_engine_routing(Some(AppEngineRouting::default()/* use setters */));
2611    /// let x = AppEngineHttpRequest::new().set_or_clear_app_engine_routing(None::<AppEngineRouting>);
2612    /// ```
2613    pub fn set_or_clear_app_engine_routing<T>(mut self, v: std::option::Option<T>) -> Self
2614    where
2615        T: std::convert::Into<crate::model::AppEngineRouting>,
2616    {
2617        self.app_engine_routing = v.map(|x| x.into());
2618        self
2619    }
2620
2621    /// Sets the value of [relative_uri][crate::model::AppEngineHttpRequest::relative_uri].
2622    ///
2623    /// # Example
2624    /// ```ignore,no_run
2625    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2626    /// let x = AppEngineHttpRequest::new().set_relative_uri("example");
2627    /// ```
2628    pub fn set_relative_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2629        self.relative_uri = v.into();
2630        self
2631    }
2632
2633    /// Sets the value of [headers][crate::model::AppEngineHttpRequest::headers].
2634    ///
2635    /// # Example
2636    /// ```ignore,no_run
2637    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2638    /// let x = AppEngineHttpRequest::new().set_headers([
2639    ///     ("key0", "abc"),
2640    ///     ("key1", "xyz"),
2641    /// ]);
2642    /// ```
2643    pub fn set_headers<T, K, V>(mut self, v: T) -> Self
2644    where
2645        T: std::iter::IntoIterator<Item = (K, V)>,
2646        K: std::convert::Into<std::string::String>,
2647        V: std::convert::Into<std::string::String>,
2648    {
2649        use std::iter::Iterator;
2650        self.headers = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2651        self
2652    }
2653
2654    /// Sets the value of [body][crate::model::AppEngineHttpRequest::body].
2655    ///
2656    /// # Example
2657    /// ```ignore,no_run
2658    /// # use google_cloud_tasks_v2::model::AppEngineHttpRequest;
2659    /// let x = AppEngineHttpRequest::new().set_body(bytes::Bytes::from_static(b"example"));
2660    /// ```
2661    pub fn set_body<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
2662        self.body = v.into();
2663        self
2664    }
2665}
2666
2667impl wkt::message::Message for AppEngineHttpRequest {
2668    fn typename() -> &'static str {
2669        "type.googleapis.com/google.cloud.tasks.v2.AppEngineHttpRequest"
2670    }
2671}
2672
2673/// App Engine Routing.
2674///
2675/// Defines routing characteristics specific to App Engine - service, version,
2676/// and instance.
2677///
2678/// For more information about services, versions, and instances see
2679/// [An Overview of App
2680/// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine),
2681/// [Microservices Architecture on Google App
2682/// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine),
2683/// [App Engine Standard request
2684/// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed),
2685/// and [App Engine Flex request
2686/// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
2687///
2688/// Using [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] requires
2689/// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control)
2690/// Google IAM permission for the project
2691/// and the following scope:
2692///
2693/// `<https://www.googleapis.com/auth/cloud-platform>`
2694///
2695/// [google.cloud.tasks.v2.AppEngineRouting]: crate::model::AppEngineRouting
2696#[derive(Clone, Default, PartialEq)]
2697#[non_exhaustive]
2698pub struct AppEngineRouting {
2699    /// App service.
2700    ///
2701    /// By default, the task is sent to the service which is the default
2702    /// service when the task is attempted.
2703    ///
2704    /// For some queues or tasks which were created using the App Engine
2705    /// Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not
2706    /// parsable into [service][google.cloud.tasks.v2.AppEngineRouting.service],
2707    /// [version][google.cloud.tasks.v2.AppEngineRouting.version], and
2708    /// [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example,
2709    /// some tasks which were created using the App Engine SDK use a custom domain
2710    /// name; custom domains are not parsed by Cloud Tasks. If
2711    /// [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then
2712    /// [service][google.cloud.tasks.v2.AppEngineRouting.service],
2713    /// [version][google.cloud.tasks.v2.AppEngineRouting.version], and
2714    /// [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty
2715    /// string.
2716    ///
2717    /// [google.cloud.tasks.v2.AppEngineRouting.host]: crate::model::AppEngineRouting::host
2718    /// [google.cloud.tasks.v2.AppEngineRouting.instance]: crate::model::AppEngineRouting::instance
2719    /// [google.cloud.tasks.v2.AppEngineRouting.service]: crate::model::AppEngineRouting::service
2720    /// [google.cloud.tasks.v2.AppEngineRouting.version]: crate::model::AppEngineRouting::version
2721    pub service: std::string::String,
2722
2723    /// App version.
2724    ///
2725    /// By default, the task is sent to the version which is the default
2726    /// version when the task is attempted.
2727    ///
2728    /// For some queues or tasks which were created using the App Engine
2729    /// Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not
2730    /// parsable into [service][google.cloud.tasks.v2.AppEngineRouting.service],
2731    /// [version][google.cloud.tasks.v2.AppEngineRouting.version], and
2732    /// [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example,
2733    /// some tasks which were created using the App Engine SDK use a custom domain
2734    /// name; custom domains are not parsed by Cloud Tasks. If
2735    /// [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then
2736    /// [service][google.cloud.tasks.v2.AppEngineRouting.service],
2737    /// [version][google.cloud.tasks.v2.AppEngineRouting.version], and
2738    /// [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty
2739    /// string.
2740    ///
2741    /// [google.cloud.tasks.v2.AppEngineRouting.host]: crate::model::AppEngineRouting::host
2742    /// [google.cloud.tasks.v2.AppEngineRouting.instance]: crate::model::AppEngineRouting::instance
2743    /// [google.cloud.tasks.v2.AppEngineRouting.service]: crate::model::AppEngineRouting::service
2744    /// [google.cloud.tasks.v2.AppEngineRouting.version]: crate::model::AppEngineRouting::version
2745    pub version: std::string::String,
2746
2747    /// App instance.
2748    ///
2749    /// By default, the task is sent to an instance which is available when
2750    /// the task is attempted.
2751    ///
2752    /// Requests can only be sent to a specific instance if
2753    /// [manual scaling is used in App Engine
2754    /// Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes).
2755    /// App Engine Flex does not support instances. For more information, see
2756    /// [App Engine Standard request
2757    /// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed)
2758    /// and [App Engine Flex request
2759    /// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed).
2760    pub instance: std::string::String,
2761
2762    /// Output only. The host that the task is sent to.
2763    ///
2764    /// The host is constructed from the domain name of the app associated with
2765    /// the queue's project ID (for example \<app-id\>.appspot.com), and the
2766    /// [service][google.cloud.tasks.v2.AppEngineRouting.service],
2767    /// [version][google.cloud.tasks.v2.AppEngineRouting.version], and
2768    /// [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. Tasks which
2769    /// were created using the App Engine SDK might have a custom domain name.
2770    ///
2771    /// For more information, see
2772    /// [How Requests are
2773    /// Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed).
2774    ///
2775    /// [google.cloud.tasks.v2.AppEngineRouting.instance]: crate::model::AppEngineRouting::instance
2776    /// [google.cloud.tasks.v2.AppEngineRouting.service]: crate::model::AppEngineRouting::service
2777    /// [google.cloud.tasks.v2.AppEngineRouting.version]: crate::model::AppEngineRouting::version
2778    pub host: std::string::String,
2779
2780    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2781}
2782
2783impl AppEngineRouting {
2784    pub fn new() -> Self {
2785        std::default::Default::default()
2786    }
2787
2788    /// Sets the value of [service][crate::model::AppEngineRouting::service].
2789    ///
2790    /// # Example
2791    /// ```ignore,no_run
2792    /// # use google_cloud_tasks_v2::model::AppEngineRouting;
2793    /// let x = AppEngineRouting::new().set_service("example");
2794    /// ```
2795    pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2796        self.service = v.into();
2797        self
2798    }
2799
2800    /// Sets the value of [version][crate::model::AppEngineRouting::version].
2801    ///
2802    /// # Example
2803    /// ```ignore,no_run
2804    /// # use google_cloud_tasks_v2::model::AppEngineRouting;
2805    /// let x = AppEngineRouting::new().set_version("example");
2806    /// ```
2807    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2808        self.version = v.into();
2809        self
2810    }
2811
2812    /// Sets the value of [instance][crate::model::AppEngineRouting::instance].
2813    ///
2814    /// # Example
2815    /// ```ignore,no_run
2816    /// # use google_cloud_tasks_v2::model::AppEngineRouting;
2817    /// let x = AppEngineRouting::new().set_instance("example");
2818    /// ```
2819    pub fn set_instance<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2820        self.instance = v.into();
2821        self
2822    }
2823
2824    /// Sets the value of [host][crate::model::AppEngineRouting::host].
2825    ///
2826    /// # Example
2827    /// ```ignore,no_run
2828    /// # use google_cloud_tasks_v2::model::AppEngineRouting;
2829    /// let x = AppEngineRouting::new().set_host("example");
2830    /// ```
2831    pub fn set_host<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2832        self.host = v.into();
2833        self
2834    }
2835}
2836
2837impl wkt::message::Message for AppEngineRouting {
2838    fn typename() -> &'static str {
2839        "type.googleapis.com/google.cloud.tasks.v2.AppEngineRouting"
2840    }
2841}
2842
2843/// Contains information needed for generating an
2844/// [OAuth token](https://developers.google.com/identity/protocols/OAuth2).
2845/// This type of authorization should generally only be used when calling Google
2846/// APIs hosted on *.googleapis.com.
2847#[derive(Clone, Default, PartialEq)]
2848#[non_exhaustive]
2849pub struct OAuthToken {
2850    /// [Service account email](https://cloud.google.com/iam/docs/service-accounts)
2851    /// to be used for generating OAuth token.
2852    /// The service account must be within the same project as the queue. The
2853    /// caller must have iam.serviceAccounts.actAs permission for the service
2854    /// account.
2855    pub service_account_email: std::string::String,
2856
2857    /// OAuth scope to be used for generating OAuth access token.
2858    /// If not specified, `https://www.googleapis.com/auth/cloud-platform`
2859    /// will be used.
2860    pub scope: std::string::String,
2861
2862    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2863}
2864
2865impl OAuthToken {
2866    pub fn new() -> Self {
2867        std::default::Default::default()
2868    }
2869
2870    /// Sets the value of [service_account_email][crate::model::OAuthToken::service_account_email].
2871    ///
2872    /// # Example
2873    /// ```ignore,no_run
2874    /// # use google_cloud_tasks_v2::model::OAuthToken;
2875    /// let x = OAuthToken::new().set_service_account_email("example");
2876    /// ```
2877    pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
2878        mut self,
2879        v: T,
2880    ) -> Self {
2881        self.service_account_email = v.into();
2882        self
2883    }
2884
2885    /// Sets the value of [scope][crate::model::OAuthToken::scope].
2886    ///
2887    /// # Example
2888    /// ```ignore,no_run
2889    /// # use google_cloud_tasks_v2::model::OAuthToken;
2890    /// let x = OAuthToken::new().set_scope("example");
2891    /// ```
2892    pub fn set_scope<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2893        self.scope = v.into();
2894        self
2895    }
2896}
2897
2898impl wkt::message::Message for OAuthToken {
2899    fn typename() -> &'static str {
2900        "type.googleapis.com/google.cloud.tasks.v2.OAuthToken"
2901    }
2902}
2903
2904/// Contains information needed for generating an
2905/// [OpenID Connect
2906/// token](https://developers.google.com/identity/protocols/OpenIDConnect).
2907/// This type of authorization can be used for many scenarios, including
2908/// calling Cloud Run, or endpoints where you intend to validate the token
2909/// yourself.
2910#[derive(Clone, Default, PartialEq)]
2911#[non_exhaustive]
2912pub struct OidcToken {
2913    /// [Service account email](https://cloud.google.com/iam/docs/service-accounts)
2914    /// to be used for generating OIDC token.
2915    /// The service account must be within the same project as the queue. The
2916    /// caller must have iam.serviceAccounts.actAs permission for the service
2917    /// account.
2918    pub service_account_email: std::string::String,
2919
2920    /// Audience to be used when generating OIDC token. If not specified, the URI
2921    /// specified in target will be used.
2922    pub audience: std::string::String,
2923
2924    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2925}
2926
2927impl OidcToken {
2928    pub fn new() -> Self {
2929        std::default::Default::default()
2930    }
2931
2932    /// Sets the value of [service_account_email][crate::model::OidcToken::service_account_email].
2933    ///
2934    /// # Example
2935    /// ```ignore,no_run
2936    /// # use google_cloud_tasks_v2::model::OidcToken;
2937    /// let x = OidcToken::new().set_service_account_email("example");
2938    /// ```
2939    pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
2940        mut self,
2941        v: T,
2942    ) -> Self {
2943        self.service_account_email = v.into();
2944        self
2945    }
2946
2947    /// Sets the value of [audience][crate::model::OidcToken::audience].
2948    ///
2949    /// # Example
2950    /// ```ignore,no_run
2951    /// # use google_cloud_tasks_v2::model::OidcToken;
2952    /// let x = OidcToken::new().set_audience("example");
2953    /// ```
2954    pub fn set_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2955        self.audience = v.into();
2956        self
2957    }
2958}
2959
2960impl wkt::message::Message for OidcToken {
2961    fn typename() -> &'static str {
2962        "type.googleapis.com/google.cloud.tasks.v2.OidcToken"
2963    }
2964}
2965
2966/// A unit of scheduled work.
2967#[derive(Clone, Default, PartialEq)]
2968#[non_exhaustive]
2969pub struct Task {
2970    /// Optionally caller-specified in
2971    /// [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask].
2972    ///
2973    /// The task name.
2974    ///
2975    /// The task name must have the following format:
2976    /// `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`
2977    ///
2978    /// * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]),
2979    ///   hyphens (-), colons (:), or periods (.).
2980    ///   For more information, see
2981    ///   [Identifying
2982    ///   projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects)
2983    /// * `LOCATION_ID` is the canonical ID for the task's location.
2984    ///   The list of available locations can be obtained by calling
2985    ///   [ListLocations][google.cloud.location.Locations.ListLocations].
2986    ///   For more information, see <https://cloud.google.com/about/locations/>.
2987    /// * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or
2988    ///   hyphens (-). The maximum length is 100 characters.
2989    /// * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]),
2990    ///   hyphens (-), or underscores (_). The maximum length is 500 characters.
2991    ///
2992    /// [google.cloud.tasks.v2.CloudTasks.CreateTask]: crate::client::CloudTasks::create_task
2993    pub name: std::string::String,
2994
2995    /// The time when the task is scheduled to be attempted or retried.
2996    ///
2997    /// `schedule_time` will be truncated to the nearest microsecond.
2998    pub schedule_time: std::option::Option<wkt::Timestamp>,
2999
3000    /// Output only. The time that the task was created.
3001    ///
3002    /// `create_time` will be truncated to the nearest second.
3003    pub create_time: std::option::Option<wkt::Timestamp>,
3004
3005    /// The deadline for requests sent to the worker. If the worker does not
3006    /// respond by this deadline then the request is cancelled and the attempt
3007    /// is marked as a `DEADLINE_EXCEEDED` failure. Cloud Tasks will retry the
3008    /// task according to the [RetryConfig][google.cloud.tasks.v2.RetryConfig].
3009    ///
3010    /// Note that when the request is cancelled, Cloud Tasks will stop listening
3011    /// for the response, but whether the worker stops processing depends on the
3012    /// worker. For example, if the worker is stuck, it may not react to cancelled
3013    /// requests.
3014    ///
3015    /// The default and maximum values depend on the type of request:
3016    ///
3017    /// * For [HTTP tasks][google.cloud.tasks.v2.HttpRequest], the default is 10
3018    ///   minutes. The deadline
3019    ///   must be in the interval [15 seconds, 30 minutes].
3020    ///
3021    /// * For [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest], 0
3022    ///   indicates that the
3023    ///   request has the default deadline. The default deadline depends on the
3024    ///   [scaling
3025    ///   type](https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_scaling)
3026    ///   of the service: 10 minutes for standard apps with automatic scaling, 24
3027    ///   hours for standard apps with manual and basic scaling, and 60 minutes for
3028    ///   flex apps. If the request deadline is set, it must be in the interval [15
3029    ///   seconds, 24 hours 15 seconds]. Regardless of the task's
3030    ///   `dispatch_deadline`, the app handler will not run for longer than than
3031    ///   the service's timeout. We recommend setting the `dispatch_deadline` to
3032    ///   at most a few seconds more than the app handler's timeout. For more
3033    ///   information see
3034    ///   [Timeouts](https://cloud.google.com/tasks/docs/creating-appengine-handlers#timeouts).
3035    ///
3036    ///
3037    /// `dispatch_deadline` will be truncated to the nearest millisecond. The
3038    /// deadline is an approximate deadline.
3039    ///
3040    /// [google.cloud.tasks.v2.AppEngineHttpRequest]: crate::model::AppEngineHttpRequest
3041    /// [google.cloud.tasks.v2.HttpRequest]: crate::model::HttpRequest
3042    /// [google.cloud.tasks.v2.RetryConfig]: crate::model::RetryConfig
3043    pub dispatch_deadline: std::option::Option<wkt::Duration>,
3044
3045    /// Output only. The number of attempts dispatched.
3046    ///
3047    /// This count includes attempts which have been dispatched but haven't
3048    /// received a response.
3049    pub dispatch_count: i32,
3050
3051    /// Output only. The number of attempts which have received a response.
3052    pub response_count: i32,
3053
3054    /// Output only. The status of the task's first attempt.
3055    ///
3056    /// Only [dispatch_time][google.cloud.tasks.v2.Attempt.dispatch_time] will be
3057    /// set. The other [Attempt][google.cloud.tasks.v2.Attempt] information is not
3058    /// retained by Cloud Tasks.
3059    ///
3060    /// [google.cloud.tasks.v2.Attempt]: crate::model::Attempt
3061    /// [google.cloud.tasks.v2.Attempt.dispatch_time]: crate::model::Attempt::dispatch_time
3062    pub first_attempt: std::option::Option<crate::model::Attempt>,
3063
3064    /// Output only. The status of the task's last attempt.
3065    pub last_attempt: std::option::Option<crate::model::Attempt>,
3066
3067    /// Output only. The view specifies which subset of the
3068    /// [Task][google.cloud.tasks.v2.Task] has been returned.
3069    ///
3070    /// [google.cloud.tasks.v2.Task]: crate::model::Task
3071    pub view: crate::model::task::View,
3072
3073    /// Required. The message to send to the worker.
3074    pub message_type: std::option::Option<crate::model::task::MessageType>,
3075
3076    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3077}
3078
3079impl Task {
3080    pub fn new() -> Self {
3081        std::default::Default::default()
3082    }
3083
3084    /// Sets the value of [name][crate::model::Task::name].
3085    ///
3086    /// # Example
3087    /// ```ignore,no_run
3088    /// # use google_cloud_tasks_v2::model::Task;
3089    /// let x = Task::new().set_name("example");
3090    /// ```
3091    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3092        self.name = v.into();
3093        self
3094    }
3095
3096    /// Sets the value of [schedule_time][crate::model::Task::schedule_time].
3097    ///
3098    /// # Example
3099    /// ```ignore,no_run
3100    /// # use google_cloud_tasks_v2::model::Task;
3101    /// use wkt::Timestamp;
3102    /// let x = Task::new().set_schedule_time(Timestamp::default()/* use setters */);
3103    /// ```
3104    pub fn set_schedule_time<T>(mut self, v: T) -> Self
3105    where
3106        T: std::convert::Into<wkt::Timestamp>,
3107    {
3108        self.schedule_time = std::option::Option::Some(v.into());
3109        self
3110    }
3111
3112    /// Sets or clears the value of [schedule_time][crate::model::Task::schedule_time].
3113    ///
3114    /// # Example
3115    /// ```ignore,no_run
3116    /// # use google_cloud_tasks_v2::model::Task;
3117    /// use wkt::Timestamp;
3118    /// let x = Task::new().set_or_clear_schedule_time(Some(Timestamp::default()/* use setters */));
3119    /// let x = Task::new().set_or_clear_schedule_time(None::<Timestamp>);
3120    /// ```
3121    pub fn set_or_clear_schedule_time<T>(mut self, v: std::option::Option<T>) -> Self
3122    where
3123        T: std::convert::Into<wkt::Timestamp>,
3124    {
3125        self.schedule_time = v.map(|x| x.into());
3126        self
3127    }
3128
3129    /// Sets the value of [create_time][crate::model::Task::create_time].
3130    ///
3131    /// # Example
3132    /// ```ignore,no_run
3133    /// # use google_cloud_tasks_v2::model::Task;
3134    /// use wkt::Timestamp;
3135    /// let x = Task::new().set_create_time(Timestamp::default()/* use setters */);
3136    /// ```
3137    pub fn set_create_time<T>(mut self, v: T) -> Self
3138    where
3139        T: std::convert::Into<wkt::Timestamp>,
3140    {
3141        self.create_time = std::option::Option::Some(v.into());
3142        self
3143    }
3144
3145    /// Sets or clears the value of [create_time][crate::model::Task::create_time].
3146    ///
3147    /// # Example
3148    /// ```ignore,no_run
3149    /// # use google_cloud_tasks_v2::model::Task;
3150    /// use wkt::Timestamp;
3151    /// let x = Task::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
3152    /// let x = Task::new().set_or_clear_create_time(None::<Timestamp>);
3153    /// ```
3154    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
3155    where
3156        T: std::convert::Into<wkt::Timestamp>,
3157    {
3158        self.create_time = v.map(|x| x.into());
3159        self
3160    }
3161
3162    /// Sets the value of [dispatch_deadline][crate::model::Task::dispatch_deadline].
3163    ///
3164    /// # Example
3165    /// ```ignore,no_run
3166    /// # use google_cloud_tasks_v2::model::Task;
3167    /// use wkt::Duration;
3168    /// let x = Task::new().set_dispatch_deadline(Duration::default()/* use setters */);
3169    /// ```
3170    pub fn set_dispatch_deadline<T>(mut self, v: T) -> Self
3171    where
3172        T: std::convert::Into<wkt::Duration>,
3173    {
3174        self.dispatch_deadline = std::option::Option::Some(v.into());
3175        self
3176    }
3177
3178    /// Sets or clears the value of [dispatch_deadline][crate::model::Task::dispatch_deadline].
3179    ///
3180    /// # Example
3181    /// ```ignore,no_run
3182    /// # use google_cloud_tasks_v2::model::Task;
3183    /// use wkt::Duration;
3184    /// let x = Task::new().set_or_clear_dispatch_deadline(Some(Duration::default()/* use setters */));
3185    /// let x = Task::new().set_or_clear_dispatch_deadline(None::<Duration>);
3186    /// ```
3187    pub fn set_or_clear_dispatch_deadline<T>(mut self, v: std::option::Option<T>) -> Self
3188    where
3189        T: std::convert::Into<wkt::Duration>,
3190    {
3191        self.dispatch_deadline = v.map(|x| x.into());
3192        self
3193    }
3194
3195    /// Sets the value of [dispatch_count][crate::model::Task::dispatch_count].
3196    ///
3197    /// # Example
3198    /// ```ignore,no_run
3199    /// # use google_cloud_tasks_v2::model::Task;
3200    /// let x = Task::new().set_dispatch_count(42);
3201    /// ```
3202    pub fn set_dispatch_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3203        self.dispatch_count = v.into();
3204        self
3205    }
3206
3207    /// Sets the value of [response_count][crate::model::Task::response_count].
3208    ///
3209    /// # Example
3210    /// ```ignore,no_run
3211    /// # use google_cloud_tasks_v2::model::Task;
3212    /// let x = Task::new().set_response_count(42);
3213    /// ```
3214    pub fn set_response_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3215        self.response_count = v.into();
3216        self
3217    }
3218
3219    /// Sets the value of [first_attempt][crate::model::Task::first_attempt].
3220    ///
3221    /// # Example
3222    /// ```ignore,no_run
3223    /// # use google_cloud_tasks_v2::model::Task;
3224    /// use google_cloud_tasks_v2::model::Attempt;
3225    /// let x = Task::new().set_first_attempt(Attempt::default()/* use setters */);
3226    /// ```
3227    pub fn set_first_attempt<T>(mut self, v: T) -> Self
3228    where
3229        T: std::convert::Into<crate::model::Attempt>,
3230    {
3231        self.first_attempt = std::option::Option::Some(v.into());
3232        self
3233    }
3234
3235    /// Sets or clears the value of [first_attempt][crate::model::Task::first_attempt].
3236    ///
3237    /// # Example
3238    /// ```ignore,no_run
3239    /// # use google_cloud_tasks_v2::model::Task;
3240    /// use google_cloud_tasks_v2::model::Attempt;
3241    /// let x = Task::new().set_or_clear_first_attempt(Some(Attempt::default()/* use setters */));
3242    /// let x = Task::new().set_or_clear_first_attempt(None::<Attempt>);
3243    /// ```
3244    pub fn set_or_clear_first_attempt<T>(mut self, v: std::option::Option<T>) -> Self
3245    where
3246        T: std::convert::Into<crate::model::Attempt>,
3247    {
3248        self.first_attempt = v.map(|x| x.into());
3249        self
3250    }
3251
3252    /// Sets the value of [last_attempt][crate::model::Task::last_attempt].
3253    ///
3254    /// # Example
3255    /// ```ignore,no_run
3256    /// # use google_cloud_tasks_v2::model::Task;
3257    /// use google_cloud_tasks_v2::model::Attempt;
3258    /// let x = Task::new().set_last_attempt(Attempt::default()/* use setters */);
3259    /// ```
3260    pub fn set_last_attempt<T>(mut self, v: T) -> Self
3261    where
3262        T: std::convert::Into<crate::model::Attempt>,
3263    {
3264        self.last_attempt = std::option::Option::Some(v.into());
3265        self
3266    }
3267
3268    /// Sets or clears the value of [last_attempt][crate::model::Task::last_attempt].
3269    ///
3270    /// # Example
3271    /// ```ignore,no_run
3272    /// # use google_cloud_tasks_v2::model::Task;
3273    /// use google_cloud_tasks_v2::model::Attempt;
3274    /// let x = Task::new().set_or_clear_last_attempt(Some(Attempt::default()/* use setters */));
3275    /// let x = Task::new().set_or_clear_last_attempt(None::<Attempt>);
3276    /// ```
3277    pub fn set_or_clear_last_attempt<T>(mut self, v: std::option::Option<T>) -> Self
3278    where
3279        T: std::convert::Into<crate::model::Attempt>,
3280    {
3281        self.last_attempt = v.map(|x| x.into());
3282        self
3283    }
3284
3285    /// Sets the value of [view][crate::model::Task::view].
3286    ///
3287    /// # Example
3288    /// ```ignore,no_run
3289    /// # use google_cloud_tasks_v2::model::Task;
3290    /// use google_cloud_tasks_v2::model::task::View;
3291    /// let x0 = Task::new().set_view(View::Basic);
3292    /// let x1 = Task::new().set_view(View::Full);
3293    /// ```
3294    pub fn set_view<T: std::convert::Into<crate::model::task::View>>(mut self, v: T) -> Self {
3295        self.view = v.into();
3296        self
3297    }
3298
3299    /// Sets the value of [message_type][crate::model::Task::message_type].
3300    ///
3301    /// Note that all the setters affecting `message_type` are mutually
3302    /// exclusive.
3303    ///
3304    /// # Example
3305    /// ```ignore,no_run
3306    /// # use google_cloud_tasks_v2::model::Task;
3307    /// use google_cloud_tasks_v2::model::AppEngineHttpRequest;
3308    /// let x = Task::new().set_message_type(Some(
3309    ///     google_cloud_tasks_v2::model::task::MessageType::AppEngineHttpRequest(AppEngineHttpRequest::default().into())));
3310    /// ```
3311    pub fn set_message_type<
3312        T: std::convert::Into<std::option::Option<crate::model::task::MessageType>>,
3313    >(
3314        mut self,
3315        v: T,
3316    ) -> Self {
3317        self.message_type = v.into();
3318        self
3319    }
3320
3321    /// The value of [message_type][crate::model::Task::message_type]
3322    /// if it holds a `AppEngineHttpRequest`, `None` if the field is not set or
3323    /// holds a different branch.
3324    pub fn app_engine_http_request(
3325        &self,
3326    ) -> std::option::Option<&std::boxed::Box<crate::model::AppEngineHttpRequest>> {
3327        #[allow(unreachable_patterns)]
3328        self.message_type.as_ref().and_then(|v| match v {
3329            crate::model::task::MessageType::AppEngineHttpRequest(v) => {
3330                std::option::Option::Some(v)
3331            }
3332            _ => std::option::Option::None,
3333        })
3334    }
3335
3336    /// Sets the value of [message_type][crate::model::Task::message_type]
3337    /// to hold a `AppEngineHttpRequest`.
3338    ///
3339    /// Note that all the setters affecting `message_type` are
3340    /// mutually exclusive.
3341    ///
3342    /// # Example
3343    /// ```ignore,no_run
3344    /// # use google_cloud_tasks_v2::model::Task;
3345    /// use google_cloud_tasks_v2::model::AppEngineHttpRequest;
3346    /// let x = Task::new().set_app_engine_http_request(AppEngineHttpRequest::default()/* use setters */);
3347    /// assert!(x.app_engine_http_request().is_some());
3348    /// assert!(x.http_request().is_none());
3349    /// ```
3350    pub fn set_app_engine_http_request<
3351        T: std::convert::Into<std::boxed::Box<crate::model::AppEngineHttpRequest>>,
3352    >(
3353        mut self,
3354        v: T,
3355    ) -> Self {
3356        self.message_type = std::option::Option::Some(
3357            crate::model::task::MessageType::AppEngineHttpRequest(v.into()),
3358        );
3359        self
3360    }
3361
3362    /// The value of [message_type][crate::model::Task::message_type]
3363    /// if it holds a `HttpRequest`, `None` if the field is not set or
3364    /// holds a different branch.
3365    pub fn http_request(&self) -> std::option::Option<&std::boxed::Box<crate::model::HttpRequest>> {
3366        #[allow(unreachable_patterns)]
3367        self.message_type.as_ref().and_then(|v| match v {
3368            crate::model::task::MessageType::HttpRequest(v) => std::option::Option::Some(v),
3369            _ => std::option::Option::None,
3370        })
3371    }
3372
3373    /// Sets the value of [message_type][crate::model::Task::message_type]
3374    /// to hold a `HttpRequest`.
3375    ///
3376    /// Note that all the setters affecting `message_type` are
3377    /// mutually exclusive.
3378    ///
3379    /// # Example
3380    /// ```ignore,no_run
3381    /// # use google_cloud_tasks_v2::model::Task;
3382    /// use google_cloud_tasks_v2::model::HttpRequest;
3383    /// let x = Task::new().set_http_request(HttpRequest::default()/* use setters */);
3384    /// assert!(x.http_request().is_some());
3385    /// assert!(x.app_engine_http_request().is_none());
3386    /// ```
3387    pub fn set_http_request<T: std::convert::Into<std::boxed::Box<crate::model::HttpRequest>>>(
3388        mut self,
3389        v: T,
3390    ) -> Self {
3391        self.message_type =
3392            std::option::Option::Some(crate::model::task::MessageType::HttpRequest(v.into()));
3393        self
3394    }
3395}
3396
3397impl wkt::message::Message for Task {
3398    fn typename() -> &'static str {
3399        "type.googleapis.com/google.cloud.tasks.v2.Task"
3400    }
3401}
3402
3403/// Defines additional types related to [Task].
3404pub mod task {
3405    #[allow(unused_imports)]
3406    use super::*;
3407
3408    /// The view specifies a subset of [Task][google.cloud.tasks.v2.Task] data.
3409    ///
3410    /// When a task is returned in a response, not all
3411    /// information is retrieved by default because some data, such as
3412    /// payloads, might be desirable to return only when needed because
3413    /// of its large size or because of the sensitivity of data that it
3414    /// contains.
3415    ///
3416    /// [google.cloud.tasks.v2.Task]: crate::model::Task
3417    ///
3418    /// # Working with unknown values
3419    ///
3420    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3421    /// additional enum variants at any time. Adding new variants is not considered
3422    /// a breaking change. Applications should write their code in anticipation of:
3423    ///
3424    /// - New values appearing in future releases of the client library, **and**
3425    /// - New values received dynamically, without application changes.
3426    ///
3427    /// Please consult the [Working with enums] section in the user guide for some
3428    /// guidelines.
3429    ///
3430    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3431    #[derive(Clone, Debug, PartialEq)]
3432    #[non_exhaustive]
3433    pub enum View {
3434        /// Unspecified. Defaults to BASIC.
3435        Unspecified,
3436        /// The basic view omits fields which can be large or can contain
3437        /// sensitive data.
3438        ///
3439        /// This view does not include the
3440        /// [body in
3441        /// AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest.body].
3442        /// Bodies are desirable to return only when needed, because they
3443        /// can be large and because of the sensitivity of the data that you
3444        /// choose to store in it.
3445        ///
3446        /// [google.cloud.tasks.v2.AppEngineHttpRequest.body]: crate::model::AppEngineHttpRequest::body
3447        Basic,
3448        /// All information is returned.
3449        ///
3450        /// Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires
3451        /// `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/)
3452        /// permission on the [Queue][google.cloud.tasks.v2.Queue] resource.
3453        ///
3454        /// [google.cloud.tasks.v2.Queue]: crate::model::Queue
3455        /// [google.cloud.tasks.v2.Task.View.FULL]: crate::model::task::View::Full
3456        Full,
3457        /// If set, the enum was initialized with an unknown value.
3458        ///
3459        /// Applications can examine the value using [View::value] or
3460        /// [View::name].
3461        UnknownValue(view::UnknownValue),
3462    }
3463
3464    #[doc(hidden)]
3465    pub mod view {
3466        #[allow(unused_imports)]
3467        use super::*;
3468        #[derive(Clone, Debug, PartialEq)]
3469        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3470    }
3471
3472    impl View {
3473        /// Gets the enum value.
3474        ///
3475        /// Returns `None` if the enum contains an unknown value deserialized from
3476        /// the string representation of enums.
3477        pub fn value(&self) -> std::option::Option<i32> {
3478            match self {
3479                Self::Unspecified => std::option::Option::Some(0),
3480                Self::Basic => std::option::Option::Some(1),
3481                Self::Full => std::option::Option::Some(2),
3482                Self::UnknownValue(u) => u.0.value(),
3483            }
3484        }
3485
3486        /// Gets the enum value as a string.
3487        ///
3488        /// Returns `None` if the enum contains an unknown value deserialized from
3489        /// the integer representation of enums.
3490        pub fn name(&self) -> std::option::Option<&str> {
3491            match self {
3492                Self::Unspecified => std::option::Option::Some("VIEW_UNSPECIFIED"),
3493                Self::Basic => std::option::Option::Some("BASIC"),
3494                Self::Full => std::option::Option::Some("FULL"),
3495                Self::UnknownValue(u) => u.0.name(),
3496            }
3497        }
3498    }
3499
3500    impl std::default::Default for View {
3501        fn default() -> Self {
3502            use std::convert::From;
3503            Self::from(0)
3504        }
3505    }
3506
3507    impl std::fmt::Display for View {
3508        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3509            wkt::internal::display_enum(f, self.name(), self.value())
3510        }
3511    }
3512
3513    impl std::convert::From<i32> for View {
3514        fn from(value: i32) -> Self {
3515            match value {
3516                0 => Self::Unspecified,
3517                1 => Self::Basic,
3518                2 => Self::Full,
3519                _ => Self::UnknownValue(view::UnknownValue(
3520                    wkt::internal::UnknownEnumValue::Integer(value),
3521                )),
3522            }
3523        }
3524    }
3525
3526    impl std::convert::From<&str> for View {
3527        fn from(value: &str) -> Self {
3528            use std::string::ToString;
3529            match value {
3530                "VIEW_UNSPECIFIED" => Self::Unspecified,
3531                "BASIC" => Self::Basic,
3532                "FULL" => Self::Full,
3533                _ => Self::UnknownValue(view::UnknownValue(
3534                    wkt::internal::UnknownEnumValue::String(value.to_string()),
3535                )),
3536            }
3537        }
3538    }
3539
3540    impl serde::ser::Serialize for View {
3541        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3542        where
3543            S: serde::Serializer,
3544        {
3545            match self {
3546                Self::Unspecified => serializer.serialize_i32(0),
3547                Self::Basic => serializer.serialize_i32(1),
3548                Self::Full => serializer.serialize_i32(2),
3549                Self::UnknownValue(u) => u.0.serialize(serializer),
3550            }
3551        }
3552    }
3553
3554    impl<'de> serde::de::Deserialize<'de> for View {
3555        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3556        where
3557            D: serde::Deserializer<'de>,
3558        {
3559            deserializer.deserialize_any(wkt::internal::EnumVisitor::<View>::new(
3560                ".google.cloud.tasks.v2.Task.View",
3561            ))
3562        }
3563    }
3564
3565    /// Required. The message to send to the worker.
3566    #[derive(Clone, Debug, PartialEq)]
3567    #[non_exhaustive]
3568    pub enum MessageType {
3569        /// HTTP request that is sent to the App Engine app handler.
3570        ///
3571        /// An App Engine task is a task that has
3572        /// [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] set.
3573        ///
3574        /// [google.cloud.tasks.v2.AppEngineHttpRequest]: crate::model::AppEngineHttpRequest
3575        AppEngineHttpRequest(std::boxed::Box<crate::model::AppEngineHttpRequest>),
3576        /// HTTP request that is sent to the worker.
3577        ///
3578        /// An HTTP task is a task that has
3579        /// [HttpRequest][google.cloud.tasks.v2.HttpRequest] set.
3580        ///
3581        /// [google.cloud.tasks.v2.HttpRequest]: crate::model::HttpRequest
3582        HttpRequest(std::boxed::Box<crate::model::HttpRequest>),
3583    }
3584}
3585
3586/// The status of a task attempt.
3587#[derive(Clone, Default, PartialEq)]
3588#[non_exhaustive]
3589pub struct Attempt {
3590    /// Output only. The time that this attempt was scheduled.
3591    ///
3592    /// `schedule_time` will be truncated to the nearest microsecond.
3593    pub schedule_time: std::option::Option<wkt::Timestamp>,
3594
3595    /// Output only. The time that this attempt was dispatched.
3596    ///
3597    /// `dispatch_time` will be truncated to the nearest microsecond.
3598    pub dispatch_time: std::option::Option<wkt::Timestamp>,
3599
3600    /// Output only. The time that this attempt response was received.
3601    ///
3602    /// `response_time` will be truncated to the nearest microsecond.
3603    pub response_time: std::option::Option<wkt::Timestamp>,
3604
3605    /// Output only. The response from the worker for this attempt.
3606    ///
3607    /// If `response_time` is unset, then the task has not been attempted or is
3608    /// currently running and the `response_status` field is meaningless.
3609    pub response_status: std::option::Option<google_cloud_rpc::model::Status>,
3610
3611    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3612}
3613
3614impl Attempt {
3615    pub fn new() -> Self {
3616        std::default::Default::default()
3617    }
3618
3619    /// Sets the value of [schedule_time][crate::model::Attempt::schedule_time].
3620    ///
3621    /// # Example
3622    /// ```ignore,no_run
3623    /// # use google_cloud_tasks_v2::model::Attempt;
3624    /// use wkt::Timestamp;
3625    /// let x = Attempt::new().set_schedule_time(Timestamp::default()/* use setters */);
3626    /// ```
3627    pub fn set_schedule_time<T>(mut self, v: T) -> Self
3628    where
3629        T: std::convert::Into<wkt::Timestamp>,
3630    {
3631        self.schedule_time = std::option::Option::Some(v.into());
3632        self
3633    }
3634
3635    /// Sets or clears the value of [schedule_time][crate::model::Attempt::schedule_time].
3636    ///
3637    /// # Example
3638    /// ```ignore,no_run
3639    /// # use google_cloud_tasks_v2::model::Attempt;
3640    /// use wkt::Timestamp;
3641    /// let x = Attempt::new().set_or_clear_schedule_time(Some(Timestamp::default()/* use setters */));
3642    /// let x = Attempt::new().set_or_clear_schedule_time(None::<Timestamp>);
3643    /// ```
3644    pub fn set_or_clear_schedule_time<T>(mut self, v: std::option::Option<T>) -> Self
3645    where
3646        T: std::convert::Into<wkt::Timestamp>,
3647    {
3648        self.schedule_time = v.map(|x| x.into());
3649        self
3650    }
3651
3652    /// Sets the value of [dispatch_time][crate::model::Attempt::dispatch_time].
3653    ///
3654    /// # Example
3655    /// ```ignore,no_run
3656    /// # use google_cloud_tasks_v2::model::Attempt;
3657    /// use wkt::Timestamp;
3658    /// let x = Attempt::new().set_dispatch_time(Timestamp::default()/* use setters */);
3659    /// ```
3660    pub fn set_dispatch_time<T>(mut self, v: T) -> Self
3661    where
3662        T: std::convert::Into<wkt::Timestamp>,
3663    {
3664        self.dispatch_time = std::option::Option::Some(v.into());
3665        self
3666    }
3667
3668    /// Sets or clears the value of [dispatch_time][crate::model::Attempt::dispatch_time].
3669    ///
3670    /// # Example
3671    /// ```ignore,no_run
3672    /// # use google_cloud_tasks_v2::model::Attempt;
3673    /// use wkt::Timestamp;
3674    /// let x = Attempt::new().set_or_clear_dispatch_time(Some(Timestamp::default()/* use setters */));
3675    /// let x = Attempt::new().set_or_clear_dispatch_time(None::<Timestamp>);
3676    /// ```
3677    pub fn set_or_clear_dispatch_time<T>(mut self, v: std::option::Option<T>) -> Self
3678    where
3679        T: std::convert::Into<wkt::Timestamp>,
3680    {
3681        self.dispatch_time = v.map(|x| x.into());
3682        self
3683    }
3684
3685    /// Sets the value of [response_time][crate::model::Attempt::response_time].
3686    ///
3687    /// # Example
3688    /// ```ignore,no_run
3689    /// # use google_cloud_tasks_v2::model::Attempt;
3690    /// use wkt::Timestamp;
3691    /// let x = Attempt::new().set_response_time(Timestamp::default()/* use setters */);
3692    /// ```
3693    pub fn set_response_time<T>(mut self, v: T) -> Self
3694    where
3695        T: std::convert::Into<wkt::Timestamp>,
3696    {
3697        self.response_time = std::option::Option::Some(v.into());
3698        self
3699    }
3700
3701    /// Sets or clears the value of [response_time][crate::model::Attempt::response_time].
3702    ///
3703    /// # Example
3704    /// ```ignore,no_run
3705    /// # use google_cloud_tasks_v2::model::Attempt;
3706    /// use wkt::Timestamp;
3707    /// let x = Attempt::new().set_or_clear_response_time(Some(Timestamp::default()/* use setters */));
3708    /// let x = Attempt::new().set_or_clear_response_time(None::<Timestamp>);
3709    /// ```
3710    pub fn set_or_clear_response_time<T>(mut self, v: std::option::Option<T>) -> Self
3711    where
3712        T: std::convert::Into<wkt::Timestamp>,
3713    {
3714        self.response_time = v.map(|x| x.into());
3715        self
3716    }
3717
3718    /// Sets the value of [response_status][crate::model::Attempt::response_status].
3719    ///
3720    /// # Example
3721    /// ```ignore,no_run
3722    /// # use google_cloud_tasks_v2::model::Attempt;
3723    /// use google_cloud_rpc::model::Status;
3724    /// let x = Attempt::new().set_response_status(Status::default()/* use setters */);
3725    /// ```
3726    pub fn set_response_status<T>(mut self, v: T) -> Self
3727    where
3728        T: std::convert::Into<google_cloud_rpc::model::Status>,
3729    {
3730        self.response_status = std::option::Option::Some(v.into());
3731        self
3732    }
3733
3734    /// Sets or clears the value of [response_status][crate::model::Attempt::response_status].
3735    ///
3736    /// # Example
3737    /// ```ignore,no_run
3738    /// # use google_cloud_tasks_v2::model::Attempt;
3739    /// use google_cloud_rpc::model::Status;
3740    /// let x = Attempt::new().set_or_clear_response_status(Some(Status::default()/* use setters */));
3741    /// let x = Attempt::new().set_or_clear_response_status(None::<Status>);
3742    /// ```
3743    pub fn set_or_clear_response_status<T>(mut self, v: std::option::Option<T>) -> Self
3744    where
3745        T: std::convert::Into<google_cloud_rpc::model::Status>,
3746    {
3747        self.response_status = v.map(|x| x.into());
3748        self
3749    }
3750}
3751
3752impl wkt::message::Message for Attempt {
3753    fn typename() -> &'static str {
3754        "type.googleapis.com/google.cloud.tasks.v2.Attempt"
3755    }
3756}
3757
3758/// The HTTP method used to deliver the task.
3759///
3760/// # Working with unknown values
3761///
3762/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3763/// additional enum variants at any time. Adding new variants is not considered
3764/// a breaking change. Applications should write their code in anticipation of:
3765///
3766/// - New values appearing in future releases of the client library, **and**
3767/// - New values received dynamically, without application changes.
3768///
3769/// Please consult the [Working with enums] section in the user guide for some
3770/// guidelines.
3771///
3772/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3773#[derive(Clone, Debug, PartialEq)]
3774#[non_exhaustive]
3775pub enum HttpMethod {
3776    /// HTTP method unspecified
3777    Unspecified,
3778    /// HTTP POST
3779    Post,
3780    /// HTTP GET
3781    Get,
3782    /// HTTP HEAD
3783    Head,
3784    /// HTTP PUT
3785    Put,
3786    /// HTTP DELETE
3787    Delete,
3788    /// HTTP PATCH
3789    Patch,
3790    /// HTTP OPTIONS
3791    Options,
3792    /// If set, the enum was initialized with an unknown value.
3793    ///
3794    /// Applications can examine the value using [HttpMethod::value] or
3795    /// [HttpMethod::name].
3796    UnknownValue(http_method::UnknownValue),
3797}
3798
3799#[doc(hidden)]
3800pub mod http_method {
3801    #[allow(unused_imports)]
3802    use super::*;
3803    #[derive(Clone, Debug, PartialEq)]
3804    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3805}
3806
3807impl HttpMethod {
3808    /// Gets the enum value.
3809    ///
3810    /// Returns `None` if the enum contains an unknown value deserialized from
3811    /// the string representation of enums.
3812    pub fn value(&self) -> std::option::Option<i32> {
3813        match self {
3814            Self::Unspecified => std::option::Option::Some(0),
3815            Self::Post => std::option::Option::Some(1),
3816            Self::Get => std::option::Option::Some(2),
3817            Self::Head => std::option::Option::Some(3),
3818            Self::Put => std::option::Option::Some(4),
3819            Self::Delete => std::option::Option::Some(5),
3820            Self::Patch => std::option::Option::Some(6),
3821            Self::Options => std::option::Option::Some(7),
3822            Self::UnknownValue(u) => u.0.value(),
3823        }
3824    }
3825
3826    /// Gets the enum value as a string.
3827    ///
3828    /// Returns `None` if the enum contains an unknown value deserialized from
3829    /// the integer representation of enums.
3830    pub fn name(&self) -> std::option::Option<&str> {
3831        match self {
3832            Self::Unspecified => std::option::Option::Some("HTTP_METHOD_UNSPECIFIED"),
3833            Self::Post => std::option::Option::Some("POST"),
3834            Self::Get => std::option::Option::Some("GET"),
3835            Self::Head => std::option::Option::Some("HEAD"),
3836            Self::Put => std::option::Option::Some("PUT"),
3837            Self::Delete => std::option::Option::Some("DELETE"),
3838            Self::Patch => std::option::Option::Some("PATCH"),
3839            Self::Options => std::option::Option::Some("OPTIONS"),
3840            Self::UnknownValue(u) => u.0.name(),
3841        }
3842    }
3843}
3844
3845impl std::default::Default for HttpMethod {
3846    fn default() -> Self {
3847        use std::convert::From;
3848        Self::from(0)
3849    }
3850}
3851
3852impl std::fmt::Display for HttpMethod {
3853    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3854        wkt::internal::display_enum(f, self.name(), self.value())
3855    }
3856}
3857
3858impl std::convert::From<i32> for HttpMethod {
3859    fn from(value: i32) -> Self {
3860        match value {
3861            0 => Self::Unspecified,
3862            1 => Self::Post,
3863            2 => Self::Get,
3864            3 => Self::Head,
3865            4 => Self::Put,
3866            5 => Self::Delete,
3867            6 => Self::Patch,
3868            7 => Self::Options,
3869            _ => Self::UnknownValue(http_method::UnknownValue(
3870                wkt::internal::UnknownEnumValue::Integer(value),
3871            )),
3872        }
3873    }
3874}
3875
3876impl std::convert::From<&str> for HttpMethod {
3877    fn from(value: &str) -> Self {
3878        use std::string::ToString;
3879        match value {
3880            "HTTP_METHOD_UNSPECIFIED" => Self::Unspecified,
3881            "POST" => Self::Post,
3882            "GET" => Self::Get,
3883            "HEAD" => Self::Head,
3884            "PUT" => Self::Put,
3885            "DELETE" => Self::Delete,
3886            "PATCH" => Self::Patch,
3887            "OPTIONS" => Self::Options,
3888            _ => Self::UnknownValue(http_method::UnknownValue(
3889                wkt::internal::UnknownEnumValue::String(value.to_string()),
3890            )),
3891        }
3892    }
3893}
3894
3895impl serde::ser::Serialize for HttpMethod {
3896    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3897    where
3898        S: serde::Serializer,
3899    {
3900        match self {
3901            Self::Unspecified => serializer.serialize_i32(0),
3902            Self::Post => serializer.serialize_i32(1),
3903            Self::Get => serializer.serialize_i32(2),
3904            Self::Head => serializer.serialize_i32(3),
3905            Self::Put => serializer.serialize_i32(4),
3906            Self::Delete => serializer.serialize_i32(5),
3907            Self::Patch => serializer.serialize_i32(6),
3908            Self::Options => serializer.serialize_i32(7),
3909            Self::UnknownValue(u) => u.0.serialize(serializer),
3910        }
3911    }
3912}
3913
3914impl<'de> serde::de::Deserialize<'de> for HttpMethod {
3915    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3916    where
3917        D: serde::Deserializer<'de>,
3918    {
3919        deserializer.deserialize_any(wkt::internal::EnumVisitor::<HttpMethod>::new(
3920            ".google.cloud.tasks.v2.HttpMethod",
3921        ))
3922    }
3923}