Skip to main content

google_cloud_tasks_v2/
model.rs

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