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