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