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