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