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