google_taskqueue1_beta2/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// Manage your Tasks and Taskqueues
17 Full,
18
19 /// Consume Tasks from your Taskqueues
20 Consumer,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Full => "https://www.googleapis.com/auth/taskqueue",
27 Scope::Consumer => "https://www.googleapis.com/auth/taskqueue.consumer",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Full
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Taskqueue related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
53/// use taskqueue1_beta2::{Result, Error};
54/// # async fn dox() {
55/// use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = Taskqueue::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.tasks().lease("project", "taskqueue", -75, -4)
97/// .tag("ea")
98/// .group_by_tag(true)
99/// .doit().await;
100///
101/// match result {
102/// Err(e) => match e {
103/// // The Error enum provides details about what exactly happened.
104/// // You can also just use its `Debug`, `Display` or `Error` traits
105/// Error::HttpError(_)
106/// |Error::Io(_)
107/// |Error::MissingAPIKey
108/// |Error::MissingToken(_)
109/// |Error::Cancelled
110/// |Error::UploadSizeLimitExceeded(_, _)
111/// |Error::Failure(_)
112/// |Error::BadRequest(_)
113/// |Error::FieldClash(_)
114/// |Error::JsonDecodeError(_, _) => println!("{}", e),
115/// },
116/// Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct Taskqueue<C> {
122 pub client: common::Client<C>,
123 pub auth: Box<dyn common::GetToken>,
124 _user_agent: String,
125 _base_url: String,
126 _root_url: String,
127}
128
129impl<C> common::Hub for Taskqueue<C> {}
130
131impl<'a, C> Taskqueue<C> {
132 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Taskqueue<C> {
133 Taskqueue {
134 client,
135 auth: Box::new(auth),
136 _user_agent: "google-api-rust-client/7.0.0".to_string(),
137 _base_url: "https://www.googleapis.com/taskqueue/v1beta2/projects/".to_string(),
138 _root_url: "https://www.googleapis.com/".to_string(),
139 }
140 }
141
142 pub fn taskqueues(&'a self) -> TaskqueueMethods<'a, C> {
143 TaskqueueMethods { hub: self }
144 }
145 pub fn tasks(&'a self) -> TaskMethods<'a, C> {
146 TaskMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/7.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://www.googleapis.com/taskqueue/v1beta2/projects/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://www.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// There is no detailed description.
178///
179/// # Activities
180///
181/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
182/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
183///
184/// * [delete tasks](TaskDeleteCall) (none)
185/// * [get tasks](TaskGetCall) (response)
186/// * [insert tasks](TaskInsertCall) (request|response)
187/// * [lease tasks](TaskLeaseCall) (none)
188/// * [list tasks](TaskListCall) (none)
189/// * [patch tasks](TaskPatchCall) (request|response)
190/// * [update tasks](TaskUpdateCall) (request|response)
191#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
192#[serde_with::serde_as]
193#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
194pub struct Task {
195 /// Time (in seconds since the epoch) at which the task was enqueued.
196 #[serde(rename = "enqueueTimestamp")]
197 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
198 pub enqueue_timestamp: Option<i64>,
199 /// Name of the task.
200 pub id: Option<String>,
201 /// The kind of object returned, in this case set to task.
202 pub kind: Option<String>,
203 /// Time (in seconds since the epoch) at which the task lease will expire. This value is 0 if the task isnt currently leased out to a worker.
204 #[serde(rename = "leaseTimestamp")]
205 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
206 pub lease_timestamp: Option<i64>,
207 /// A bag of bytes which is the task payload. The payload on the JSON side is always Base64 encoded.
208 #[serde(rename = "payloadBase64")]
209 pub payload_base64: Option<String>,
210 /// Name of the queue that the task is in.
211 #[serde(rename = "queueName")]
212 pub queue_name: Option<String>,
213 /// The number of leases applied to this task.
214 pub retry_count: Option<i32>,
215 /// Tag for the task, could be used later to lease tasks grouped by a specific tag.
216 pub tag: Option<String>,
217}
218
219impl common::RequestValue for Task {}
220impl common::Resource for Task {}
221impl common::ResponseResult for Task {}
222
223/// There is no detailed description.
224///
225/// # Activities
226///
227/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
228/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
229///
230/// * [get taskqueues](TaskqueueGetCall) (response)
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct TaskQueue {
235 /// ACLs that are applicable to this TaskQueue object.
236 pub acl: Option<TaskQueueAcl>,
237 /// Name of the taskqueue.
238 pub id: Option<String>,
239 /// The kind of REST object returned, in this case taskqueue.
240 pub kind: Option<String>,
241 /// The number of times we should lease out tasks before giving up on them. If unset we lease them out forever until a worker deletes the task.
242 #[serde(rename = "maxLeases")]
243 pub max_leases: Option<i32>,
244 /// Statistics for the TaskQueue object in question.
245 pub stats: Option<TaskQueueStats>,
246}
247
248impl common::Resource for TaskQueue {}
249impl common::ResponseResult for TaskQueue {}
250
251/// There is no detailed description.
252///
253/// # Activities
254///
255/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
256/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
257///
258/// * [lease tasks](TaskLeaseCall) (response)
259#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
260#[serde_with::serde_as]
261#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
262pub struct Tasks {
263 /// The actual list of tasks returned as a result of the lease operation.
264 pub items: Option<Vec<Task>>,
265 /// The kind of object returned, a list of tasks.
266 pub kind: Option<String>,
267}
268
269impl common::ResponseResult for Tasks {}
270
271/// There is no detailed description.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [list tasks](TaskListCall) (response)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct Tasks2 {
283 /// The actual list of tasks currently active in the TaskQueue.
284 pub items: Option<Vec<Task>>,
285 /// The kind of object returned, a list of tasks.
286 pub kind: Option<String>,
287}
288
289impl common::ResponseResult for Tasks2 {}
290
291/// ACLs that are applicable to this TaskQueue object.
292///
293/// This type is not used in any activity, and only used as *part* of another schema.
294///
295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
296#[serde_with::serde_as]
297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
298pub struct TaskQueueAcl {
299 /// Email addresses of users who are "admins" of the TaskQueue. This means they can control the queue, eg set ACLs for the queue.
300 #[serde(rename = "adminEmails")]
301 pub admin_emails: Option<Vec<String>>,
302 /// Email addresses of users who can "consume" tasks from the TaskQueue. This means they can Dequeue and Delete tasks from the queue.
303 #[serde(rename = "consumerEmails")]
304 pub consumer_emails: Option<Vec<String>>,
305 /// Email addresses of users who can "produce" tasks into the TaskQueue. This means they can Insert tasks into the queue.
306 #[serde(rename = "producerEmails")]
307 pub producer_emails: Option<Vec<String>>,
308}
309
310impl common::NestedType for TaskQueueAcl {}
311impl common::Part for TaskQueueAcl {}
312
313/// Statistics for the TaskQueue object in question.
314///
315/// This type is not used in any activity, and only used as *part* of another schema.
316///
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct TaskQueueStats {
321 /// Number of tasks leased in the last hour.
322 #[serde(rename = "leasedLastHour")]
323 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
324 pub leased_last_hour: Option<i64>,
325 /// Number of tasks leased in the last minute.
326 #[serde(rename = "leasedLastMinute")]
327 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
328 pub leased_last_minute: Option<i64>,
329 /// The timestamp (in seconds since the epoch) of the oldest unfinished task.
330 #[serde(rename = "oldestTask")]
331 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
332 pub oldest_task: Option<i64>,
333 /// Number of tasks in the queue.
334 #[serde(rename = "totalTasks")]
335 pub total_tasks: Option<i32>,
336}
337
338impl common::NestedType for TaskQueueStats {}
339impl common::Part for TaskQueueStats {}
340
341// ###################
342// MethodBuilders ###
343// #################
344
345/// A builder providing access to all methods supported on *taskqueue* resources.
346/// It is not used directly, but through the [`Taskqueue`] hub.
347///
348/// # Example
349///
350/// Instantiate a resource builder
351///
352/// ```test_harness,no_run
353/// extern crate hyper;
354/// extern crate hyper_rustls;
355/// extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
356///
357/// # async fn dox() {
358/// use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
359///
360/// let secret: yup_oauth2::ApplicationSecret = Default::default();
361/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
362/// .with_native_roots()
363/// .unwrap()
364/// .https_only()
365/// .enable_http2()
366/// .build();
367///
368/// let executor = hyper_util::rt::TokioExecutor::new();
369/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
370/// secret,
371/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
372/// yup_oauth2::client::CustomHyperClientBuilder::from(
373/// hyper_util::client::legacy::Client::builder(executor).build(connector),
374/// ),
375/// ).build().await.unwrap();
376///
377/// let client = hyper_util::client::legacy::Client::builder(
378/// hyper_util::rt::TokioExecutor::new()
379/// )
380/// .build(
381/// hyper_rustls::HttpsConnectorBuilder::new()
382/// .with_native_roots()
383/// .unwrap()
384/// .https_or_http()
385/// .enable_http2()
386/// .build()
387/// );
388/// let mut hub = Taskqueue::new(client, auth);
389/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
390/// // like `get(...)`
391/// // to build up your call.
392/// let rb = hub.taskqueues();
393/// # }
394/// ```
395pub struct TaskqueueMethods<'a, C>
396where
397 C: 'a,
398{
399 hub: &'a Taskqueue<C>,
400}
401
402impl<'a, C> common::MethodsBuilder for TaskqueueMethods<'a, C> {}
403
404impl<'a, C> TaskqueueMethods<'a, C> {
405 /// Create a builder to help you perform the following task:
406 ///
407 /// Get detailed information about a TaskQueue.
408 ///
409 /// # Arguments
410 ///
411 /// * `project` - The project under which the queue lies.
412 /// * `taskqueue` - The id of the taskqueue to get the properties of.
413 pub fn get(&self, project: &str, taskqueue: &str) -> TaskqueueGetCall<'a, C> {
414 TaskqueueGetCall {
415 hub: self.hub,
416 _project: project.to_string(),
417 _taskqueue: taskqueue.to_string(),
418 _get_stats: Default::default(),
419 _delegate: Default::default(),
420 _additional_params: Default::default(),
421 _scopes: Default::default(),
422 }
423 }
424}
425
426/// A builder providing access to all methods supported on *task* resources.
427/// It is not used directly, but through the [`Taskqueue`] hub.
428///
429/// # Example
430///
431/// Instantiate a resource builder
432///
433/// ```test_harness,no_run
434/// extern crate hyper;
435/// extern crate hyper_rustls;
436/// extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
437///
438/// # async fn dox() {
439/// use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
440///
441/// let secret: yup_oauth2::ApplicationSecret = Default::default();
442/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
443/// .with_native_roots()
444/// .unwrap()
445/// .https_only()
446/// .enable_http2()
447/// .build();
448///
449/// let executor = hyper_util::rt::TokioExecutor::new();
450/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
451/// secret,
452/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
453/// yup_oauth2::client::CustomHyperClientBuilder::from(
454/// hyper_util::client::legacy::Client::builder(executor).build(connector),
455/// ),
456/// ).build().await.unwrap();
457///
458/// let client = hyper_util::client::legacy::Client::builder(
459/// hyper_util::rt::TokioExecutor::new()
460/// )
461/// .build(
462/// hyper_rustls::HttpsConnectorBuilder::new()
463/// .with_native_roots()
464/// .unwrap()
465/// .https_or_http()
466/// .enable_http2()
467/// .build()
468/// );
469/// let mut hub = Taskqueue::new(client, auth);
470/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
471/// // like `delete(...)`, `get(...)`, `insert(...)`, `lease(...)`, `list(...)`, `patch(...)` and `update(...)`
472/// // to build up your call.
473/// let rb = hub.tasks();
474/// # }
475/// ```
476pub struct TaskMethods<'a, C>
477where
478 C: 'a,
479{
480 hub: &'a Taskqueue<C>,
481}
482
483impl<'a, C> common::MethodsBuilder for TaskMethods<'a, C> {}
484
485impl<'a, C> TaskMethods<'a, C> {
486 /// Create a builder to help you perform the following task:
487 ///
488 /// Delete a task from a TaskQueue.
489 ///
490 /// # Arguments
491 ///
492 /// * `project` - The project under which the queue lies.
493 /// * `taskqueue` - The taskqueue to delete a task from.
494 /// * `task` - The id of the task to delete.
495 pub fn delete(&self, project: &str, taskqueue: &str, task: &str) -> TaskDeleteCall<'a, C> {
496 TaskDeleteCall {
497 hub: self.hub,
498 _project: project.to_string(),
499 _taskqueue: taskqueue.to_string(),
500 _task: task.to_string(),
501 _delegate: Default::default(),
502 _additional_params: Default::default(),
503 _scopes: Default::default(),
504 }
505 }
506
507 /// Create a builder to help you perform the following task:
508 ///
509 /// Get a particular task from a TaskQueue.
510 ///
511 /// # Arguments
512 ///
513 /// * `project` - The project under which the queue lies.
514 /// * `taskqueue` - The taskqueue in which the task belongs.
515 /// * `task` - The task to get properties of.
516 pub fn get(&self, project: &str, taskqueue: &str, task: &str) -> TaskGetCall<'a, C> {
517 TaskGetCall {
518 hub: self.hub,
519 _project: project.to_string(),
520 _taskqueue: taskqueue.to_string(),
521 _task: task.to_string(),
522 _delegate: Default::default(),
523 _additional_params: Default::default(),
524 _scopes: Default::default(),
525 }
526 }
527
528 /// Create a builder to help you perform the following task:
529 ///
530 /// Insert a new task in a TaskQueue
531 ///
532 /// # Arguments
533 ///
534 /// * `request` - No description provided.
535 /// * `project` - The project under which the queue lies
536 /// * `taskqueue` - The taskqueue to insert the task into
537 pub fn insert(&self, request: Task, project: &str, taskqueue: &str) -> TaskInsertCall<'a, C> {
538 TaskInsertCall {
539 hub: self.hub,
540 _request: request,
541 _project: project.to_string(),
542 _taskqueue: taskqueue.to_string(),
543 _delegate: Default::default(),
544 _additional_params: Default::default(),
545 _scopes: Default::default(),
546 }
547 }
548
549 /// Create a builder to help you perform the following task:
550 ///
551 /// Lease 1 or more tasks from a TaskQueue.
552 ///
553 /// # Arguments
554 ///
555 /// * `project` - The project under which the queue lies.
556 /// * `taskqueue` - The taskqueue to lease a task from.
557 /// * `numTasks` - The number of tasks to lease.
558 /// * `leaseSecs` - The lease in seconds.
559 pub fn lease(
560 &self,
561 project: &str,
562 taskqueue: &str,
563 num_tasks: i32,
564 lease_secs: i32,
565 ) -> TaskLeaseCall<'a, C> {
566 TaskLeaseCall {
567 hub: self.hub,
568 _project: project.to_string(),
569 _taskqueue: taskqueue.to_string(),
570 _num_tasks: num_tasks,
571 _lease_secs: lease_secs,
572 _tag: Default::default(),
573 _group_by_tag: Default::default(),
574 _delegate: Default::default(),
575 _additional_params: Default::default(),
576 _scopes: Default::default(),
577 }
578 }
579
580 /// Create a builder to help you perform the following task:
581 ///
582 /// List Tasks in a TaskQueue
583 ///
584 /// # Arguments
585 ///
586 /// * `project` - The project under which the queue lies.
587 /// * `taskqueue` - The id of the taskqueue to list tasks from.
588 pub fn list(&self, project: &str, taskqueue: &str) -> TaskListCall<'a, C> {
589 TaskListCall {
590 hub: self.hub,
591 _project: project.to_string(),
592 _taskqueue: taskqueue.to_string(),
593 _delegate: Default::default(),
594 _additional_params: Default::default(),
595 _scopes: Default::default(),
596 }
597 }
598
599 /// Create a builder to help you perform the following task:
600 ///
601 /// Update tasks that are leased out of a TaskQueue. This method supports patch semantics.
602 ///
603 /// # Arguments
604 ///
605 /// * `request` - No description provided.
606 /// * `project` - The project under which the queue lies.
607 /// * `taskqueue` - No description provided.
608 /// * `task` - No description provided.
609 /// * `newLeaseSeconds` - The new lease in seconds.
610 pub fn patch(
611 &self,
612 request: Task,
613 project: &str,
614 taskqueue: &str,
615 task: &str,
616 new_lease_seconds: i32,
617 ) -> TaskPatchCall<'a, C> {
618 TaskPatchCall {
619 hub: self.hub,
620 _request: request,
621 _project: project.to_string(),
622 _taskqueue: taskqueue.to_string(),
623 _task: task.to_string(),
624 _new_lease_seconds: new_lease_seconds,
625 _delegate: Default::default(),
626 _additional_params: Default::default(),
627 _scopes: Default::default(),
628 }
629 }
630
631 /// Create a builder to help you perform the following task:
632 ///
633 /// Update tasks that are leased out of a TaskQueue.
634 ///
635 /// # Arguments
636 ///
637 /// * `request` - No description provided.
638 /// * `project` - The project under which the queue lies.
639 /// * `taskqueue` - No description provided.
640 /// * `task` - No description provided.
641 /// * `newLeaseSeconds` - The new lease in seconds.
642 pub fn update(
643 &self,
644 request: Task,
645 project: &str,
646 taskqueue: &str,
647 task: &str,
648 new_lease_seconds: i32,
649 ) -> TaskUpdateCall<'a, C> {
650 TaskUpdateCall {
651 hub: self.hub,
652 _request: request,
653 _project: project.to_string(),
654 _taskqueue: taskqueue.to_string(),
655 _task: task.to_string(),
656 _new_lease_seconds: new_lease_seconds,
657 _delegate: Default::default(),
658 _additional_params: Default::default(),
659 _scopes: Default::default(),
660 }
661 }
662}
663
664// ###################
665// CallBuilders ###
666// #################
667
668/// Get detailed information about a TaskQueue.
669///
670/// A builder for the *get* method supported by a *taskqueue* resource.
671/// It is not used directly, but through a [`TaskqueueMethods`] instance.
672///
673/// # Example
674///
675/// Instantiate a resource method builder
676///
677/// ```test_harness,no_run
678/// # extern crate hyper;
679/// # extern crate hyper_rustls;
680/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
681/// # async fn dox() {
682/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
683///
684/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
685/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
686/// # .with_native_roots()
687/// # .unwrap()
688/// # .https_only()
689/// # .enable_http2()
690/// # .build();
691///
692/// # let executor = hyper_util::rt::TokioExecutor::new();
693/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
694/// # secret,
695/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
696/// # yup_oauth2::client::CustomHyperClientBuilder::from(
697/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
698/// # ),
699/// # ).build().await.unwrap();
700///
701/// # let client = hyper_util::client::legacy::Client::builder(
702/// # hyper_util::rt::TokioExecutor::new()
703/// # )
704/// # .build(
705/// # hyper_rustls::HttpsConnectorBuilder::new()
706/// # .with_native_roots()
707/// # .unwrap()
708/// # .https_or_http()
709/// # .enable_http2()
710/// # .build()
711/// # );
712/// # let mut hub = Taskqueue::new(client, auth);
713/// // You can configure optional parameters by calling the respective setters at will, and
714/// // execute the final call using `doit()`.
715/// // Values shown here are possibly random and not representative !
716/// let result = hub.taskqueues().get("project", "taskqueue")
717/// .get_stats(true)
718/// .doit().await;
719/// # }
720/// ```
721pub struct TaskqueueGetCall<'a, C>
722where
723 C: 'a,
724{
725 hub: &'a Taskqueue<C>,
726 _project: String,
727 _taskqueue: String,
728 _get_stats: Option<bool>,
729 _delegate: Option<&'a mut dyn common::Delegate>,
730 _additional_params: HashMap<String, String>,
731 _scopes: BTreeSet<String>,
732}
733
734impl<'a, C> common::CallBuilder for TaskqueueGetCall<'a, C> {}
735
736impl<'a, C> TaskqueueGetCall<'a, C>
737where
738 C: common::Connector,
739{
740 /// Perform the operation you have build so far.
741 pub async fn doit(mut self) -> common::Result<(common::Response, TaskQueue)> {
742 use std::borrow::Cow;
743 use std::io::{Read, Seek};
744
745 use common::{url::Params, ToParts};
746 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
747
748 let mut dd = common::DefaultDelegate;
749 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
750 dlg.begin(common::MethodInfo {
751 id: "taskqueue.taskqueues.get",
752 http_method: hyper::Method::GET,
753 });
754
755 for &field in ["alt", "project", "taskqueue", "getStats"].iter() {
756 if self._additional_params.contains_key(field) {
757 dlg.finished(false);
758 return Err(common::Error::FieldClash(field));
759 }
760 }
761
762 let mut params = Params::with_capacity(5 + self._additional_params.len());
763 params.push("project", self._project);
764 params.push("taskqueue", self._taskqueue);
765 if let Some(value) = self._get_stats.as_ref() {
766 params.push("getStats", value.to_string());
767 }
768
769 params.extend(self._additional_params.iter());
770
771 params.push("alt", "json");
772 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}";
773 if self._scopes.is_empty() {
774 self._scopes.insert(Scope::Full.as_ref().to_string());
775 }
776
777 #[allow(clippy::single_element_loop)]
778 for &(find_this, param_name) in
779 [("{project}", "project"), ("{taskqueue}", "taskqueue")].iter()
780 {
781 url = params.uri_replacement(url, param_name, find_this, false);
782 }
783 {
784 let to_remove = ["taskqueue", "project"];
785 params.remove_params(&to_remove);
786 }
787
788 let url = params.parse_with_url(&url);
789
790 loop {
791 let token = match self
792 .hub
793 .auth
794 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
795 .await
796 {
797 Ok(token) => token,
798 Err(e) => match dlg.token(e) {
799 Ok(token) => token,
800 Err(e) => {
801 dlg.finished(false);
802 return Err(common::Error::MissingToken(e));
803 }
804 },
805 };
806 let mut req_result = {
807 let client = &self.hub.client;
808 dlg.pre_request();
809 let mut req_builder = hyper::Request::builder()
810 .method(hyper::Method::GET)
811 .uri(url.as_str())
812 .header(USER_AGENT, self.hub._user_agent.clone());
813
814 if let Some(token) = token.as_ref() {
815 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
816 }
817
818 let request = req_builder
819 .header(CONTENT_LENGTH, 0_u64)
820 .body(common::to_body::<String>(None));
821
822 client.request(request.unwrap()).await
823 };
824
825 match req_result {
826 Err(err) => {
827 if let common::Retry::After(d) = dlg.http_error(&err) {
828 sleep(d).await;
829 continue;
830 }
831 dlg.finished(false);
832 return Err(common::Error::HttpError(err));
833 }
834 Ok(res) => {
835 let (mut parts, body) = res.into_parts();
836 let mut body = common::Body::new(body);
837 if !parts.status.is_success() {
838 let bytes = common::to_bytes(body).await.unwrap_or_default();
839 let error = serde_json::from_str(&common::to_string(&bytes));
840 let response = common::to_response(parts, bytes.into());
841
842 if let common::Retry::After(d) =
843 dlg.http_failure(&response, error.as_ref().ok())
844 {
845 sleep(d).await;
846 continue;
847 }
848
849 dlg.finished(false);
850
851 return Err(match error {
852 Ok(value) => common::Error::BadRequest(value),
853 _ => common::Error::Failure(response),
854 });
855 }
856 let response = {
857 let bytes = common::to_bytes(body).await.unwrap_or_default();
858 let encoded = common::to_string(&bytes);
859 match serde_json::from_str(&encoded) {
860 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
861 Err(error) => {
862 dlg.response_json_decode_error(&encoded, &error);
863 return Err(common::Error::JsonDecodeError(
864 encoded.to_string(),
865 error,
866 ));
867 }
868 }
869 };
870
871 dlg.finished(true);
872 return Ok(response);
873 }
874 }
875 }
876 }
877
878 /// The project under which the queue lies.
879 ///
880 /// Sets the *project* path property to the given value.
881 ///
882 /// Even though the property as already been set when instantiating this call,
883 /// we provide this method for API completeness.
884 pub fn project(mut self, new_value: &str) -> TaskqueueGetCall<'a, C> {
885 self._project = new_value.to_string();
886 self
887 }
888 /// The id of the taskqueue to get the properties of.
889 ///
890 /// Sets the *taskqueue* path property to the given value.
891 ///
892 /// Even though the property as already been set when instantiating this call,
893 /// we provide this method for API completeness.
894 pub fn taskqueue(mut self, new_value: &str) -> TaskqueueGetCall<'a, C> {
895 self._taskqueue = new_value.to_string();
896 self
897 }
898 /// Whether to get stats. Optional.
899 ///
900 /// Sets the *get stats* query property to the given value.
901 pub fn get_stats(mut self, new_value: bool) -> TaskqueueGetCall<'a, C> {
902 self._get_stats = Some(new_value);
903 self
904 }
905 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
906 /// while executing the actual API request.
907 ///
908 /// ````text
909 /// It should be used to handle progress information, and to implement a certain level of resilience.
910 /// ````
911 ///
912 /// Sets the *delegate* property to the given value.
913 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskqueueGetCall<'a, C> {
914 self._delegate = Some(new_value);
915 self
916 }
917
918 /// Set any additional parameter of the query string used in the request.
919 /// It should be used to set parameters which are not yet available through their own
920 /// setters.
921 ///
922 /// Please note that this method must not be used to set any of the known parameters
923 /// which have their own setter method. If done anyway, the request will fail.
924 ///
925 /// # Additional Parameters
926 ///
927 /// * *alt* (query-string) - Data format for the response.
928 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
929 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
930 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
931 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
932 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
933 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
934 pub fn param<T>(mut self, name: T, value: T) -> TaskqueueGetCall<'a, C>
935 where
936 T: AsRef<str>,
937 {
938 self._additional_params
939 .insert(name.as_ref().to_string(), value.as_ref().to_string());
940 self
941 }
942
943 /// Identifies the authorization scope for the method you are building.
944 ///
945 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
946 /// [`Scope::Full`].
947 ///
948 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
949 /// tokens for more than one scope.
950 ///
951 /// Usually there is more than one suitable scope to authorize an operation, some of which may
952 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
953 /// sufficient, a read-write scope will do as well.
954 pub fn add_scope<St>(mut self, scope: St) -> TaskqueueGetCall<'a, C>
955 where
956 St: AsRef<str>,
957 {
958 self._scopes.insert(String::from(scope.as_ref()));
959 self
960 }
961 /// Identifies the authorization scope(s) for the method you are building.
962 ///
963 /// See [`Self::add_scope()`] for details.
964 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskqueueGetCall<'a, C>
965 where
966 I: IntoIterator<Item = St>,
967 St: AsRef<str>,
968 {
969 self._scopes
970 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
971 self
972 }
973
974 /// Removes all scopes, and no default scope will be used either.
975 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
976 /// for details).
977 pub fn clear_scopes(mut self) -> TaskqueueGetCall<'a, C> {
978 self._scopes.clear();
979 self
980 }
981}
982
983/// Delete a task from a TaskQueue.
984///
985/// A builder for the *delete* method supported by a *task* resource.
986/// It is not used directly, but through a [`TaskMethods`] instance.
987///
988/// # Example
989///
990/// Instantiate a resource method builder
991///
992/// ```test_harness,no_run
993/// # extern crate hyper;
994/// # extern crate hyper_rustls;
995/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
996/// # async fn dox() {
997/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
998///
999/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1000/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1001/// # .with_native_roots()
1002/// # .unwrap()
1003/// # .https_only()
1004/// # .enable_http2()
1005/// # .build();
1006///
1007/// # let executor = hyper_util::rt::TokioExecutor::new();
1008/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1009/// # secret,
1010/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1011/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1012/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1013/// # ),
1014/// # ).build().await.unwrap();
1015///
1016/// # let client = hyper_util::client::legacy::Client::builder(
1017/// # hyper_util::rt::TokioExecutor::new()
1018/// # )
1019/// # .build(
1020/// # hyper_rustls::HttpsConnectorBuilder::new()
1021/// # .with_native_roots()
1022/// # .unwrap()
1023/// # .https_or_http()
1024/// # .enable_http2()
1025/// # .build()
1026/// # );
1027/// # let mut hub = Taskqueue::new(client, auth);
1028/// // You can configure optional parameters by calling the respective setters at will, and
1029/// // execute the final call using `doit()`.
1030/// // Values shown here are possibly random and not representative !
1031/// let result = hub.tasks().delete("project", "taskqueue", "task")
1032/// .doit().await;
1033/// # }
1034/// ```
1035pub struct TaskDeleteCall<'a, C>
1036where
1037 C: 'a,
1038{
1039 hub: &'a Taskqueue<C>,
1040 _project: String,
1041 _taskqueue: String,
1042 _task: String,
1043 _delegate: Option<&'a mut dyn common::Delegate>,
1044 _additional_params: HashMap<String, String>,
1045 _scopes: BTreeSet<String>,
1046}
1047
1048impl<'a, C> common::CallBuilder for TaskDeleteCall<'a, C> {}
1049
1050impl<'a, C> TaskDeleteCall<'a, C>
1051where
1052 C: common::Connector,
1053{
1054 /// Perform the operation you have build so far.
1055 pub async fn doit(mut self) -> common::Result<common::Response> {
1056 use std::borrow::Cow;
1057 use std::io::{Read, Seek};
1058
1059 use common::{url::Params, ToParts};
1060 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1061
1062 let mut dd = common::DefaultDelegate;
1063 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1064 dlg.begin(common::MethodInfo {
1065 id: "taskqueue.tasks.delete",
1066 http_method: hyper::Method::DELETE,
1067 });
1068
1069 for &field in ["project", "taskqueue", "task"].iter() {
1070 if self._additional_params.contains_key(field) {
1071 dlg.finished(false);
1072 return Err(common::Error::FieldClash(field));
1073 }
1074 }
1075
1076 let mut params = Params::with_capacity(4 + self._additional_params.len());
1077 params.push("project", self._project);
1078 params.push("taskqueue", self._taskqueue);
1079 params.push("task", self._task);
1080
1081 params.extend(self._additional_params.iter());
1082
1083 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
1084 if self._scopes.is_empty() {
1085 self._scopes.insert(Scope::Full.as_ref().to_string());
1086 }
1087
1088 #[allow(clippy::single_element_loop)]
1089 for &(find_this, param_name) in [
1090 ("{project}", "project"),
1091 ("{taskqueue}", "taskqueue"),
1092 ("{task}", "task"),
1093 ]
1094 .iter()
1095 {
1096 url = params.uri_replacement(url, param_name, find_this, false);
1097 }
1098 {
1099 let to_remove = ["task", "taskqueue", "project"];
1100 params.remove_params(&to_remove);
1101 }
1102
1103 let url = params.parse_with_url(&url);
1104
1105 loop {
1106 let token = match self
1107 .hub
1108 .auth
1109 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1110 .await
1111 {
1112 Ok(token) => token,
1113 Err(e) => match dlg.token(e) {
1114 Ok(token) => token,
1115 Err(e) => {
1116 dlg.finished(false);
1117 return Err(common::Error::MissingToken(e));
1118 }
1119 },
1120 };
1121 let mut req_result = {
1122 let client = &self.hub.client;
1123 dlg.pre_request();
1124 let mut req_builder = hyper::Request::builder()
1125 .method(hyper::Method::DELETE)
1126 .uri(url.as_str())
1127 .header(USER_AGENT, self.hub._user_agent.clone());
1128
1129 if let Some(token) = token.as_ref() {
1130 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1131 }
1132
1133 let request = req_builder
1134 .header(CONTENT_LENGTH, 0_u64)
1135 .body(common::to_body::<String>(None));
1136
1137 client.request(request.unwrap()).await
1138 };
1139
1140 match req_result {
1141 Err(err) => {
1142 if let common::Retry::After(d) = dlg.http_error(&err) {
1143 sleep(d).await;
1144 continue;
1145 }
1146 dlg.finished(false);
1147 return Err(common::Error::HttpError(err));
1148 }
1149 Ok(res) => {
1150 let (mut parts, body) = res.into_parts();
1151 let mut body = common::Body::new(body);
1152 if !parts.status.is_success() {
1153 let bytes = common::to_bytes(body).await.unwrap_or_default();
1154 let error = serde_json::from_str(&common::to_string(&bytes));
1155 let response = common::to_response(parts, bytes.into());
1156
1157 if let common::Retry::After(d) =
1158 dlg.http_failure(&response, error.as_ref().ok())
1159 {
1160 sleep(d).await;
1161 continue;
1162 }
1163
1164 dlg.finished(false);
1165
1166 return Err(match error {
1167 Ok(value) => common::Error::BadRequest(value),
1168 _ => common::Error::Failure(response),
1169 });
1170 }
1171 let response = common::Response::from_parts(parts, body);
1172
1173 dlg.finished(true);
1174 return Ok(response);
1175 }
1176 }
1177 }
1178 }
1179
1180 /// The project under which the queue lies.
1181 ///
1182 /// Sets the *project* path property to the given value.
1183 ///
1184 /// Even though the property as already been set when instantiating this call,
1185 /// we provide this method for API completeness.
1186 pub fn project(mut self, new_value: &str) -> TaskDeleteCall<'a, C> {
1187 self._project = new_value.to_string();
1188 self
1189 }
1190 /// The taskqueue to delete a task from.
1191 ///
1192 /// Sets the *taskqueue* path property to the given value.
1193 ///
1194 /// Even though the property as already been set when instantiating this call,
1195 /// we provide this method for API completeness.
1196 pub fn taskqueue(mut self, new_value: &str) -> TaskDeleteCall<'a, C> {
1197 self._taskqueue = new_value.to_string();
1198 self
1199 }
1200 /// The id of the task to delete.
1201 ///
1202 /// Sets the *task* path property to the given value.
1203 ///
1204 /// Even though the property as already been set when instantiating this call,
1205 /// we provide this method for API completeness.
1206 pub fn task(mut self, new_value: &str) -> TaskDeleteCall<'a, C> {
1207 self._task = new_value.to_string();
1208 self
1209 }
1210 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1211 /// while executing the actual API request.
1212 ///
1213 /// ````text
1214 /// It should be used to handle progress information, and to implement a certain level of resilience.
1215 /// ````
1216 ///
1217 /// Sets the *delegate* property to the given value.
1218 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskDeleteCall<'a, C> {
1219 self._delegate = Some(new_value);
1220 self
1221 }
1222
1223 /// Set any additional parameter of the query string used in the request.
1224 /// It should be used to set parameters which are not yet available through their own
1225 /// setters.
1226 ///
1227 /// Please note that this method must not be used to set any of the known parameters
1228 /// which have their own setter method. If done anyway, the request will fail.
1229 ///
1230 /// # Additional Parameters
1231 ///
1232 /// * *alt* (query-string) - Data format for the response.
1233 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1234 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1235 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1236 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1237 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1238 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1239 pub fn param<T>(mut self, name: T, value: T) -> TaskDeleteCall<'a, C>
1240 where
1241 T: AsRef<str>,
1242 {
1243 self._additional_params
1244 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1245 self
1246 }
1247
1248 /// Identifies the authorization scope for the method you are building.
1249 ///
1250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1251 /// [`Scope::Full`].
1252 ///
1253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1254 /// tokens for more than one scope.
1255 ///
1256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1258 /// sufficient, a read-write scope will do as well.
1259 pub fn add_scope<St>(mut self, scope: St) -> TaskDeleteCall<'a, C>
1260 where
1261 St: AsRef<str>,
1262 {
1263 self._scopes.insert(String::from(scope.as_ref()));
1264 self
1265 }
1266 /// Identifies the authorization scope(s) for the method you are building.
1267 ///
1268 /// See [`Self::add_scope()`] for details.
1269 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskDeleteCall<'a, C>
1270 where
1271 I: IntoIterator<Item = St>,
1272 St: AsRef<str>,
1273 {
1274 self._scopes
1275 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1276 self
1277 }
1278
1279 /// Removes all scopes, and no default scope will be used either.
1280 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1281 /// for details).
1282 pub fn clear_scopes(mut self) -> TaskDeleteCall<'a, C> {
1283 self._scopes.clear();
1284 self
1285 }
1286}
1287
1288/// Get a particular task from a TaskQueue.
1289///
1290/// A builder for the *get* method supported by a *task* resource.
1291/// It is not used directly, but through a [`TaskMethods`] instance.
1292///
1293/// # Example
1294///
1295/// Instantiate a resource method builder
1296///
1297/// ```test_harness,no_run
1298/// # extern crate hyper;
1299/// # extern crate hyper_rustls;
1300/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
1301/// # async fn dox() {
1302/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1303///
1304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1306/// # .with_native_roots()
1307/// # .unwrap()
1308/// # .https_only()
1309/// # .enable_http2()
1310/// # .build();
1311///
1312/// # let executor = hyper_util::rt::TokioExecutor::new();
1313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1314/// # secret,
1315/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1316/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1317/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1318/// # ),
1319/// # ).build().await.unwrap();
1320///
1321/// # let client = hyper_util::client::legacy::Client::builder(
1322/// # hyper_util::rt::TokioExecutor::new()
1323/// # )
1324/// # .build(
1325/// # hyper_rustls::HttpsConnectorBuilder::new()
1326/// # .with_native_roots()
1327/// # .unwrap()
1328/// # .https_or_http()
1329/// # .enable_http2()
1330/// # .build()
1331/// # );
1332/// # let mut hub = Taskqueue::new(client, auth);
1333/// // You can configure optional parameters by calling the respective setters at will, and
1334/// // execute the final call using `doit()`.
1335/// // Values shown here are possibly random and not representative !
1336/// let result = hub.tasks().get("project", "taskqueue", "task")
1337/// .doit().await;
1338/// # }
1339/// ```
1340pub struct TaskGetCall<'a, C>
1341where
1342 C: 'a,
1343{
1344 hub: &'a Taskqueue<C>,
1345 _project: String,
1346 _taskqueue: String,
1347 _task: String,
1348 _delegate: Option<&'a mut dyn common::Delegate>,
1349 _additional_params: HashMap<String, String>,
1350 _scopes: BTreeSet<String>,
1351}
1352
1353impl<'a, C> common::CallBuilder for TaskGetCall<'a, C> {}
1354
1355impl<'a, C> TaskGetCall<'a, C>
1356where
1357 C: common::Connector,
1358{
1359 /// Perform the operation you have build so far.
1360 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
1361 use std::borrow::Cow;
1362 use std::io::{Read, Seek};
1363
1364 use common::{url::Params, ToParts};
1365 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1366
1367 let mut dd = common::DefaultDelegate;
1368 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1369 dlg.begin(common::MethodInfo {
1370 id: "taskqueue.tasks.get",
1371 http_method: hyper::Method::GET,
1372 });
1373
1374 for &field in ["alt", "project", "taskqueue", "task"].iter() {
1375 if self._additional_params.contains_key(field) {
1376 dlg.finished(false);
1377 return Err(common::Error::FieldClash(field));
1378 }
1379 }
1380
1381 let mut params = Params::with_capacity(5 + self._additional_params.len());
1382 params.push("project", self._project);
1383 params.push("taskqueue", self._taskqueue);
1384 params.push("task", self._task);
1385
1386 params.extend(self._additional_params.iter());
1387
1388 params.push("alt", "json");
1389 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
1390 if self._scopes.is_empty() {
1391 self._scopes.insert(Scope::Full.as_ref().to_string());
1392 }
1393
1394 #[allow(clippy::single_element_loop)]
1395 for &(find_this, param_name) in [
1396 ("{project}", "project"),
1397 ("{taskqueue}", "taskqueue"),
1398 ("{task}", "task"),
1399 ]
1400 .iter()
1401 {
1402 url = params.uri_replacement(url, param_name, find_this, false);
1403 }
1404 {
1405 let to_remove = ["task", "taskqueue", "project"];
1406 params.remove_params(&to_remove);
1407 }
1408
1409 let url = params.parse_with_url(&url);
1410
1411 loop {
1412 let token = match self
1413 .hub
1414 .auth
1415 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1416 .await
1417 {
1418 Ok(token) => token,
1419 Err(e) => match dlg.token(e) {
1420 Ok(token) => token,
1421 Err(e) => {
1422 dlg.finished(false);
1423 return Err(common::Error::MissingToken(e));
1424 }
1425 },
1426 };
1427 let mut req_result = {
1428 let client = &self.hub.client;
1429 dlg.pre_request();
1430 let mut req_builder = hyper::Request::builder()
1431 .method(hyper::Method::GET)
1432 .uri(url.as_str())
1433 .header(USER_AGENT, self.hub._user_agent.clone());
1434
1435 if let Some(token) = token.as_ref() {
1436 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1437 }
1438
1439 let request = req_builder
1440 .header(CONTENT_LENGTH, 0_u64)
1441 .body(common::to_body::<String>(None));
1442
1443 client.request(request.unwrap()).await
1444 };
1445
1446 match req_result {
1447 Err(err) => {
1448 if let common::Retry::After(d) = dlg.http_error(&err) {
1449 sleep(d).await;
1450 continue;
1451 }
1452 dlg.finished(false);
1453 return Err(common::Error::HttpError(err));
1454 }
1455 Ok(res) => {
1456 let (mut parts, body) = res.into_parts();
1457 let mut body = common::Body::new(body);
1458 if !parts.status.is_success() {
1459 let bytes = common::to_bytes(body).await.unwrap_or_default();
1460 let error = serde_json::from_str(&common::to_string(&bytes));
1461 let response = common::to_response(parts, bytes.into());
1462
1463 if let common::Retry::After(d) =
1464 dlg.http_failure(&response, error.as_ref().ok())
1465 {
1466 sleep(d).await;
1467 continue;
1468 }
1469
1470 dlg.finished(false);
1471
1472 return Err(match error {
1473 Ok(value) => common::Error::BadRequest(value),
1474 _ => common::Error::Failure(response),
1475 });
1476 }
1477 let response = {
1478 let bytes = common::to_bytes(body).await.unwrap_or_default();
1479 let encoded = common::to_string(&bytes);
1480 match serde_json::from_str(&encoded) {
1481 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1482 Err(error) => {
1483 dlg.response_json_decode_error(&encoded, &error);
1484 return Err(common::Error::JsonDecodeError(
1485 encoded.to_string(),
1486 error,
1487 ));
1488 }
1489 }
1490 };
1491
1492 dlg.finished(true);
1493 return Ok(response);
1494 }
1495 }
1496 }
1497 }
1498
1499 /// The project under which the queue lies.
1500 ///
1501 /// Sets the *project* path property to the given value.
1502 ///
1503 /// Even though the property as already been set when instantiating this call,
1504 /// we provide this method for API completeness.
1505 pub fn project(mut self, new_value: &str) -> TaskGetCall<'a, C> {
1506 self._project = new_value.to_string();
1507 self
1508 }
1509 /// The taskqueue in which the task belongs.
1510 ///
1511 /// Sets the *taskqueue* path property to the given value.
1512 ///
1513 /// Even though the property as already been set when instantiating this call,
1514 /// we provide this method for API completeness.
1515 pub fn taskqueue(mut self, new_value: &str) -> TaskGetCall<'a, C> {
1516 self._taskqueue = new_value.to_string();
1517 self
1518 }
1519 /// The task to get properties of.
1520 ///
1521 /// Sets the *task* path property to the given value.
1522 ///
1523 /// Even though the property as already been set when instantiating this call,
1524 /// we provide this method for API completeness.
1525 pub fn task(mut self, new_value: &str) -> TaskGetCall<'a, C> {
1526 self._task = new_value.to_string();
1527 self
1528 }
1529 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1530 /// while executing the actual API request.
1531 ///
1532 /// ````text
1533 /// It should be used to handle progress information, and to implement a certain level of resilience.
1534 /// ````
1535 ///
1536 /// Sets the *delegate* property to the given value.
1537 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskGetCall<'a, C> {
1538 self._delegate = Some(new_value);
1539 self
1540 }
1541
1542 /// Set any additional parameter of the query string used in the request.
1543 /// It should be used to set parameters which are not yet available through their own
1544 /// setters.
1545 ///
1546 /// Please note that this method must not be used to set any of the known parameters
1547 /// which have their own setter method. If done anyway, the request will fail.
1548 ///
1549 /// # Additional Parameters
1550 ///
1551 /// * *alt* (query-string) - Data format for the response.
1552 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1553 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1554 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1555 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1556 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1557 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1558 pub fn param<T>(mut self, name: T, value: T) -> TaskGetCall<'a, C>
1559 where
1560 T: AsRef<str>,
1561 {
1562 self._additional_params
1563 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1564 self
1565 }
1566
1567 /// Identifies the authorization scope for the method you are building.
1568 ///
1569 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1570 /// [`Scope::Full`].
1571 ///
1572 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1573 /// tokens for more than one scope.
1574 ///
1575 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1576 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1577 /// sufficient, a read-write scope will do as well.
1578 pub fn add_scope<St>(mut self, scope: St) -> TaskGetCall<'a, C>
1579 where
1580 St: AsRef<str>,
1581 {
1582 self._scopes.insert(String::from(scope.as_ref()));
1583 self
1584 }
1585 /// Identifies the authorization scope(s) for the method you are building.
1586 ///
1587 /// See [`Self::add_scope()`] for details.
1588 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskGetCall<'a, C>
1589 where
1590 I: IntoIterator<Item = St>,
1591 St: AsRef<str>,
1592 {
1593 self._scopes
1594 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1595 self
1596 }
1597
1598 /// Removes all scopes, and no default scope will be used either.
1599 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1600 /// for details).
1601 pub fn clear_scopes(mut self) -> TaskGetCall<'a, C> {
1602 self._scopes.clear();
1603 self
1604 }
1605}
1606
1607/// Insert a new task in a TaskQueue
1608///
1609/// A builder for the *insert* method supported by a *task* resource.
1610/// It is not used directly, but through a [`TaskMethods`] instance.
1611///
1612/// # Example
1613///
1614/// Instantiate a resource method builder
1615///
1616/// ```test_harness,no_run
1617/// # extern crate hyper;
1618/// # extern crate hyper_rustls;
1619/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
1620/// use taskqueue1_beta2::api::Task;
1621/// # async fn dox() {
1622/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1623///
1624/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1625/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1626/// # .with_native_roots()
1627/// # .unwrap()
1628/// # .https_only()
1629/// # .enable_http2()
1630/// # .build();
1631///
1632/// # let executor = hyper_util::rt::TokioExecutor::new();
1633/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1634/// # secret,
1635/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1636/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1637/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1638/// # ),
1639/// # ).build().await.unwrap();
1640///
1641/// # let client = hyper_util::client::legacy::Client::builder(
1642/// # hyper_util::rt::TokioExecutor::new()
1643/// # )
1644/// # .build(
1645/// # hyper_rustls::HttpsConnectorBuilder::new()
1646/// # .with_native_roots()
1647/// # .unwrap()
1648/// # .https_or_http()
1649/// # .enable_http2()
1650/// # .build()
1651/// # );
1652/// # let mut hub = Taskqueue::new(client, auth);
1653/// // As the method needs a request, you would usually fill it with the desired information
1654/// // into the respective structure. Some of the parts shown here might not be applicable !
1655/// // Values shown here are possibly random and not representative !
1656/// let mut req = Task::default();
1657///
1658/// // You can configure optional parameters by calling the respective setters at will, and
1659/// // execute the final call using `doit()`.
1660/// // Values shown here are possibly random and not representative !
1661/// let result = hub.tasks().insert(req, "project", "taskqueue")
1662/// .doit().await;
1663/// # }
1664/// ```
1665pub struct TaskInsertCall<'a, C>
1666where
1667 C: 'a,
1668{
1669 hub: &'a Taskqueue<C>,
1670 _request: Task,
1671 _project: String,
1672 _taskqueue: String,
1673 _delegate: Option<&'a mut dyn common::Delegate>,
1674 _additional_params: HashMap<String, String>,
1675 _scopes: BTreeSet<String>,
1676}
1677
1678impl<'a, C> common::CallBuilder for TaskInsertCall<'a, C> {}
1679
1680impl<'a, C> TaskInsertCall<'a, C>
1681where
1682 C: common::Connector,
1683{
1684 /// Perform the operation you have build so far.
1685 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
1686 use std::borrow::Cow;
1687 use std::io::{Read, Seek};
1688
1689 use common::{url::Params, ToParts};
1690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1691
1692 let mut dd = common::DefaultDelegate;
1693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1694 dlg.begin(common::MethodInfo {
1695 id: "taskqueue.tasks.insert",
1696 http_method: hyper::Method::POST,
1697 });
1698
1699 for &field in ["alt", "project", "taskqueue"].iter() {
1700 if self._additional_params.contains_key(field) {
1701 dlg.finished(false);
1702 return Err(common::Error::FieldClash(field));
1703 }
1704 }
1705
1706 let mut params = Params::with_capacity(5 + self._additional_params.len());
1707 params.push("project", self._project);
1708 params.push("taskqueue", self._taskqueue);
1709
1710 params.extend(self._additional_params.iter());
1711
1712 params.push("alt", "json");
1713 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks";
1714 if self._scopes.is_empty() {
1715 self._scopes.insert(Scope::Full.as_ref().to_string());
1716 }
1717
1718 #[allow(clippy::single_element_loop)]
1719 for &(find_this, param_name) in
1720 [("{project}", "project"), ("{taskqueue}", "taskqueue")].iter()
1721 {
1722 url = params.uri_replacement(url, param_name, find_this, false);
1723 }
1724 {
1725 let to_remove = ["taskqueue", "project"];
1726 params.remove_params(&to_remove);
1727 }
1728
1729 let url = params.parse_with_url(&url);
1730
1731 let mut json_mime_type = mime::APPLICATION_JSON;
1732 let mut request_value_reader = {
1733 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1734 common::remove_json_null_values(&mut value);
1735 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1736 serde_json::to_writer(&mut dst, &value).unwrap();
1737 dst
1738 };
1739 let request_size = request_value_reader
1740 .seek(std::io::SeekFrom::End(0))
1741 .unwrap();
1742 request_value_reader
1743 .seek(std::io::SeekFrom::Start(0))
1744 .unwrap();
1745
1746 loop {
1747 let token = match self
1748 .hub
1749 .auth
1750 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1751 .await
1752 {
1753 Ok(token) => token,
1754 Err(e) => match dlg.token(e) {
1755 Ok(token) => token,
1756 Err(e) => {
1757 dlg.finished(false);
1758 return Err(common::Error::MissingToken(e));
1759 }
1760 },
1761 };
1762 request_value_reader
1763 .seek(std::io::SeekFrom::Start(0))
1764 .unwrap();
1765 let mut req_result = {
1766 let client = &self.hub.client;
1767 dlg.pre_request();
1768 let mut req_builder = hyper::Request::builder()
1769 .method(hyper::Method::POST)
1770 .uri(url.as_str())
1771 .header(USER_AGENT, self.hub._user_agent.clone());
1772
1773 if let Some(token) = token.as_ref() {
1774 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1775 }
1776
1777 let request = req_builder
1778 .header(CONTENT_TYPE, json_mime_type.to_string())
1779 .header(CONTENT_LENGTH, request_size as u64)
1780 .body(common::to_body(
1781 request_value_reader.get_ref().clone().into(),
1782 ));
1783
1784 client.request(request.unwrap()).await
1785 };
1786
1787 match req_result {
1788 Err(err) => {
1789 if let common::Retry::After(d) = dlg.http_error(&err) {
1790 sleep(d).await;
1791 continue;
1792 }
1793 dlg.finished(false);
1794 return Err(common::Error::HttpError(err));
1795 }
1796 Ok(res) => {
1797 let (mut parts, body) = res.into_parts();
1798 let mut body = common::Body::new(body);
1799 if !parts.status.is_success() {
1800 let bytes = common::to_bytes(body).await.unwrap_or_default();
1801 let error = serde_json::from_str(&common::to_string(&bytes));
1802 let response = common::to_response(parts, bytes.into());
1803
1804 if let common::Retry::After(d) =
1805 dlg.http_failure(&response, error.as_ref().ok())
1806 {
1807 sleep(d).await;
1808 continue;
1809 }
1810
1811 dlg.finished(false);
1812
1813 return Err(match error {
1814 Ok(value) => common::Error::BadRequest(value),
1815 _ => common::Error::Failure(response),
1816 });
1817 }
1818 let response = {
1819 let bytes = common::to_bytes(body).await.unwrap_or_default();
1820 let encoded = common::to_string(&bytes);
1821 match serde_json::from_str(&encoded) {
1822 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1823 Err(error) => {
1824 dlg.response_json_decode_error(&encoded, &error);
1825 return Err(common::Error::JsonDecodeError(
1826 encoded.to_string(),
1827 error,
1828 ));
1829 }
1830 }
1831 };
1832
1833 dlg.finished(true);
1834 return Ok(response);
1835 }
1836 }
1837 }
1838 }
1839
1840 ///
1841 /// Sets the *request* property to the given value.
1842 ///
1843 /// Even though the property as already been set when instantiating this call,
1844 /// we provide this method for API completeness.
1845 pub fn request(mut self, new_value: Task) -> TaskInsertCall<'a, C> {
1846 self._request = new_value;
1847 self
1848 }
1849 /// The project under which the queue lies
1850 ///
1851 /// Sets the *project* path property to the given value.
1852 ///
1853 /// Even though the property as already been set when instantiating this call,
1854 /// we provide this method for API completeness.
1855 pub fn project(mut self, new_value: &str) -> TaskInsertCall<'a, C> {
1856 self._project = new_value.to_string();
1857 self
1858 }
1859 /// The taskqueue to insert the task into
1860 ///
1861 /// Sets the *taskqueue* path property to the given value.
1862 ///
1863 /// Even though the property as already been set when instantiating this call,
1864 /// we provide this method for API completeness.
1865 pub fn taskqueue(mut self, new_value: &str) -> TaskInsertCall<'a, C> {
1866 self._taskqueue = new_value.to_string();
1867 self
1868 }
1869 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1870 /// while executing the actual API request.
1871 ///
1872 /// ````text
1873 /// It should be used to handle progress information, and to implement a certain level of resilience.
1874 /// ````
1875 ///
1876 /// Sets the *delegate* property to the given value.
1877 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskInsertCall<'a, C> {
1878 self._delegate = Some(new_value);
1879 self
1880 }
1881
1882 /// Set any additional parameter of the query string used in the request.
1883 /// It should be used to set parameters which are not yet available through their own
1884 /// setters.
1885 ///
1886 /// Please note that this method must not be used to set any of the known parameters
1887 /// which have their own setter method. If done anyway, the request will fail.
1888 ///
1889 /// # Additional Parameters
1890 ///
1891 /// * *alt* (query-string) - Data format for the response.
1892 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1893 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1894 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1895 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1896 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
1897 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
1898 pub fn param<T>(mut self, name: T, value: T) -> TaskInsertCall<'a, C>
1899 where
1900 T: AsRef<str>,
1901 {
1902 self._additional_params
1903 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1904 self
1905 }
1906
1907 /// Identifies the authorization scope for the method you are building.
1908 ///
1909 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1910 /// [`Scope::Full`].
1911 ///
1912 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1913 /// tokens for more than one scope.
1914 ///
1915 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1916 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1917 /// sufficient, a read-write scope will do as well.
1918 pub fn add_scope<St>(mut self, scope: St) -> TaskInsertCall<'a, C>
1919 where
1920 St: AsRef<str>,
1921 {
1922 self._scopes.insert(String::from(scope.as_ref()));
1923 self
1924 }
1925 /// Identifies the authorization scope(s) for the method you are building.
1926 ///
1927 /// See [`Self::add_scope()`] for details.
1928 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskInsertCall<'a, C>
1929 where
1930 I: IntoIterator<Item = St>,
1931 St: AsRef<str>,
1932 {
1933 self._scopes
1934 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1935 self
1936 }
1937
1938 /// Removes all scopes, and no default scope will be used either.
1939 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1940 /// for details).
1941 pub fn clear_scopes(mut self) -> TaskInsertCall<'a, C> {
1942 self._scopes.clear();
1943 self
1944 }
1945}
1946
1947/// Lease 1 or more tasks from a TaskQueue.
1948///
1949/// A builder for the *lease* method supported by a *task* resource.
1950/// It is not used directly, but through a [`TaskMethods`] instance.
1951///
1952/// # Example
1953///
1954/// Instantiate a resource method builder
1955///
1956/// ```test_harness,no_run
1957/// # extern crate hyper;
1958/// # extern crate hyper_rustls;
1959/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
1960/// # async fn dox() {
1961/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1962///
1963/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1964/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1965/// # .with_native_roots()
1966/// # .unwrap()
1967/// # .https_only()
1968/// # .enable_http2()
1969/// # .build();
1970///
1971/// # let executor = hyper_util::rt::TokioExecutor::new();
1972/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1973/// # secret,
1974/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1975/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1976/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1977/// # ),
1978/// # ).build().await.unwrap();
1979///
1980/// # let client = hyper_util::client::legacy::Client::builder(
1981/// # hyper_util::rt::TokioExecutor::new()
1982/// # )
1983/// # .build(
1984/// # hyper_rustls::HttpsConnectorBuilder::new()
1985/// # .with_native_roots()
1986/// # .unwrap()
1987/// # .https_or_http()
1988/// # .enable_http2()
1989/// # .build()
1990/// # );
1991/// # let mut hub = Taskqueue::new(client, auth);
1992/// // You can configure optional parameters by calling the respective setters at will, and
1993/// // execute the final call using `doit()`.
1994/// // Values shown here are possibly random and not representative !
1995/// let result = hub.tasks().lease("project", "taskqueue", -99, -56)
1996/// .tag("eos")
1997/// .group_by_tag(false)
1998/// .doit().await;
1999/// # }
2000/// ```
2001pub struct TaskLeaseCall<'a, C>
2002where
2003 C: 'a,
2004{
2005 hub: &'a Taskqueue<C>,
2006 _project: String,
2007 _taskqueue: String,
2008 _num_tasks: i32,
2009 _lease_secs: i32,
2010 _tag: Option<String>,
2011 _group_by_tag: Option<bool>,
2012 _delegate: Option<&'a mut dyn common::Delegate>,
2013 _additional_params: HashMap<String, String>,
2014 _scopes: BTreeSet<String>,
2015}
2016
2017impl<'a, C> common::CallBuilder for TaskLeaseCall<'a, C> {}
2018
2019impl<'a, C> TaskLeaseCall<'a, C>
2020where
2021 C: common::Connector,
2022{
2023 /// Perform the operation you have build so far.
2024 pub async fn doit(mut self) -> common::Result<(common::Response, Tasks)> {
2025 use std::borrow::Cow;
2026 use std::io::{Read, Seek};
2027
2028 use common::{url::Params, ToParts};
2029 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2030
2031 let mut dd = common::DefaultDelegate;
2032 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2033 dlg.begin(common::MethodInfo {
2034 id: "taskqueue.tasks.lease",
2035 http_method: hyper::Method::POST,
2036 });
2037
2038 for &field in [
2039 "alt",
2040 "project",
2041 "taskqueue",
2042 "numTasks",
2043 "leaseSecs",
2044 "tag",
2045 "groupByTag",
2046 ]
2047 .iter()
2048 {
2049 if self._additional_params.contains_key(field) {
2050 dlg.finished(false);
2051 return Err(common::Error::FieldClash(field));
2052 }
2053 }
2054
2055 let mut params = Params::with_capacity(8 + self._additional_params.len());
2056 params.push("project", self._project);
2057 params.push("taskqueue", self._taskqueue);
2058 params.push("numTasks", self._num_tasks.to_string());
2059 params.push("leaseSecs", self._lease_secs.to_string());
2060 if let Some(value) = self._tag.as_ref() {
2061 params.push("tag", value);
2062 }
2063 if let Some(value) = self._group_by_tag.as_ref() {
2064 params.push("groupByTag", value.to_string());
2065 }
2066
2067 params.extend(self._additional_params.iter());
2068
2069 params.push("alt", "json");
2070 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/lease";
2071 if self._scopes.is_empty() {
2072 self._scopes.insert(Scope::Full.as_ref().to_string());
2073 }
2074
2075 #[allow(clippy::single_element_loop)]
2076 for &(find_this, param_name) in
2077 [("{project}", "project"), ("{taskqueue}", "taskqueue")].iter()
2078 {
2079 url = params.uri_replacement(url, param_name, find_this, false);
2080 }
2081 {
2082 let to_remove = ["taskqueue", "project"];
2083 params.remove_params(&to_remove);
2084 }
2085
2086 let url = params.parse_with_url(&url);
2087
2088 loop {
2089 let token = match self
2090 .hub
2091 .auth
2092 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2093 .await
2094 {
2095 Ok(token) => token,
2096 Err(e) => match dlg.token(e) {
2097 Ok(token) => token,
2098 Err(e) => {
2099 dlg.finished(false);
2100 return Err(common::Error::MissingToken(e));
2101 }
2102 },
2103 };
2104 let mut req_result = {
2105 let client = &self.hub.client;
2106 dlg.pre_request();
2107 let mut req_builder = hyper::Request::builder()
2108 .method(hyper::Method::POST)
2109 .uri(url.as_str())
2110 .header(USER_AGENT, self.hub._user_agent.clone());
2111
2112 if let Some(token) = token.as_ref() {
2113 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2114 }
2115
2116 let request = req_builder
2117 .header(CONTENT_LENGTH, 0_u64)
2118 .body(common::to_body::<String>(None));
2119
2120 client.request(request.unwrap()).await
2121 };
2122
2123 match req_result {
2124 Err(err) => {
2125 if let common::Retry::After(d) = dlg.http_error(&err) {
2126 sleep(d).await;
2127 continue;
2128 }
2129 dlg.finished(false);
2130 return Err(common::Error::HttpError(err));
2131 }
2132 Ok(res) => {
2133 let (mut parts, body) = res.into_parts();
2134 let mut body = common::Body::new(body);
2135 if !parts.status.is_success() {
2136 let bytes = common::to_bytes(body).await.unwrap_or_default();
2137 let error = serde_json::from_str(&common::to_string(&bytes));
2138 let response = common::to_response(parts, bytes.into());
2139
2140 if let common::Retry::After(d) =
2141 dlg.http_failure(&response, error.as_ref().ok())
2142 {
2143 sleep(d).await;
2144 continue;
2145 }
2146
2147 dlg.finished(false);
2148
2149 return Err(match error {
2150 Ok(value) => common::Error::BadRequest(value),
2151 _ => common::Error::Failure(response),
2152 });
2153 }
2154 let response = {
2155 let bytes = common::to_bytes(body).await.unwrap_or_default();
2156 let encoded = common::to_string(&bytes);
2157 match serde_json::from_str(&encoded) {
2158 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2159 Err(error) => {
2160 dlg.response_json_decode_error(&encoded, &error);
2161 return Err(common::Error::JsonDecodeError(
2162 encoded.to_string(),
2163 error,
2164 ));
2165 }
2166 }
2167 };
2168
2169 dlg.finished(true);
2170 return Ok(response);
2171 }
2172 }
2173 }
2174 }
2175
2176 /// The project under which the queue lies.
2177 ///
2178 /// Sets the *project* path property to the given value.
2179 ///
2180 /// Even though the property as already been set when instantiating this call,
2181 /// we provide this method for API completeness.
2182 pub fn project(mut self, new_value: &str) -> TaskLeaseCall<'a, C> {
2183 self._project = new_value.to_string();
2184 self
2185 }
2186 /// The taskqueue to lease a task from.
2187 ///
2188 /// Sets the *taskqueue* path property to the given value.
2189 ///
2190 /// Even though the property as already been set when instantiating this call,
2191 /// we provide this method for API completeness.
2192 pub fn taskqueue(mut self, new_value: &str) -> TaskLeaseCall<'a, C> {
2193 self._taskqueue = new_value.to_string();
2194 self
2195 }
2196 /// The number of tasks to lease.
2197 ///
2198 /// Sets the *num tasks* query property to the given value.
2199 ///
2200 /// Even though the property as already been set when instantiating this call,
2201 /// we provide this method for API completeness.
2202 pub fn num_tasks(mut self, new_value: i32) -> TaskLeaseCall<'a, C> {
2203 self._num_tasks = new_value;
2204 self
2205 }
2206 /// The lease in seconds.
2207 ///
2208 /// Sets the *lease secs* query property to the given value.
2209 ///
2210 /// Even though the property as already been set when instantiating this call,
2211 /// we provide this method for API completeness.
2212 pub fn lease_secs(mut self, new_value: i32) -> TaskLeaseCall<'a, C> {
2213 self._lease_secs = new_value;
2214 self
2215 }
2216 /// The tag allowed for tasks in the response. Must only be specified if group_by_tag is true. If group_by_tag is true and tag is not specified the tag will be that of the oldest task by eta, i.e. the first available tag
2217 ///
2218 /// Sets the *tag* query property to the given value.
2219 pub fn tag(mut self, new_value: &str) -> TaskLeaseCall<'a, C> {
2220 self._tag = Some(new_value.to_string());
2221 self
2222 }
2223 /// When true, all returned tasks will have the same tag
2224 ///
2225 /// Sets the *group by tag* query property to the given value.
2226 pub fn group_by_tag(mut self, new_value: bool) -> TaskLeaseCall<'a, C> {
2227 self._group_by_tag = Some(new_value);
2228 self
2229 }
2230 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2231 /// while executing the actual API request.
2232 ///
2233 /// ````text
2234 /// It should be used to handle progress information, and to implement a certain level of resilience.
2235 /// ````
2236 ///
2237 /// Sets the *delegate* property to the given value.
2238 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskLeaseCall<'a, C> {
2239 self._delegate = Some(new_value);
2240 self
2241 }
2242
2243 /// Set any additional parameter of the query string used in the request.
2244 /// It should be used to set parameters which are not yet available through their own
2245 /// setters.
2246 ///
2247 /// Please note that this method must not be used to set any of the known parameters
2248 /// which have their own setter method. If done anyway, the request will fail.
2249 ///
2250 /// # Additional Parameters
2251 ///
2252 /// * *alt* (query-string) - Data format for the response.
2253 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2254 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2255 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2256 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2257 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2258 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2259 pub fn param<T>(mut self, name: T, value: T) -> TaskLeaseCall<'a, C>
2260 where
2261 T: AsRef<str>,
2262 {
2263 self._additional_params
2264 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2265 self
2266 }
2267
2268 /// Identifies the authorization scope for the method you are building.
2269 ///
2270 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2271 /// [`Scope::Full`].
2272 ///
2273 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2274 /// tokens for more than one scope.
2275 ///
2276 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2277 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2278 /// sufficient, a read-write scope will do as well.
2279 pub fn add_scope<St>(mut self, scope: St) -> TaskLeaseCall<'a, C>
2280 where
2281 St: AsRef<str>,
2282 {
2283 self._scopes.insert(String::from(scope.as_ref()));
2284 self
2285 }
2286 /// Identifies the authorization scope(s) for the method you are building.
2287 ///
2288 /// See [`Self::add_scope()`] for details.
2289 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskLeaseCall<'a, C>
2290 where
2291 I: IntoIterator<Item = St>,
2292 St: AsRef<str>,
2293 {
2294 self._scopes
2295 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2296 self
2297 }
2298
2299 /// Removes all scopes, and no default scope will be used either.
2300 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2301 /// for details).
2302 pub fn clear_scopes(mut self) -> TaskLeaseCall<'a, C> {
2303 self._scopes.clear();
2304 self
2305 }
2306}
2307
2308/// List Tasks in a TaskQueue
2309///
2310/// A builder for the *list* method supported by a *task* resource.
2311/// It is not used directly, but through a [`TaskMethods`] instance.
2312///
2313/// # Example
2314///
2315/// Instantiate a resource method builder
2316///
2317/// ```test_harness,no_run
2318/// # extern crate hyper;
2319/// # extern crate hyper_rustls;
2320/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
2321/// # async fn dox() {
2322/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2323///
2324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2325/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2326/// # .with_native_roots()
2327/// # .unwrap()
2328/// # .https_only()
2329/// # .enable_http2()
2330/// # .build();
2331///
2332/// # let executor = hyper_util::rt::TokioExecutor::new();
2333/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2334/// # secret,
2335/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2336/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2337/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2338/// # ),
2339/// # ).build().await.unwrap();
2340///
2341/// # let client = hyper_util::client::legacy::Client::builder(
2342/// # hyper_util::rt::TokioExecutor::new()
2343/// # )
2344/// # .build(
2345/// # hyper_rustls::HttpsConnectorBuilder::new()
2346/// # .with_native_roots()
2347/// # .unwrap()
2348/// # .https_or_http()
2349/// # .enable_http2()
2350/// # .build()
2351/// # );
2352/// # let mut hub = Taskqueue::new(client, auth);
2353/// // You can configure optional parameters by calling the respective setters at will, and
2354/// // execute the final call using `doit()`.
2355/// // Values shown here are possibly random and not representative !
2356/// let result = hub.tasks().list("project", "taskqueue")
2357/// .doit().await;
2358/// # }
2359/// ```
2360pub struct TaskListCall<'a, C>
2361where
2362 C: 'a,
2363{
2364 hub: &'a Taskqueue<C>,
2365 _project: String,
2366 _taskqueue: String,
2367 _delegate: Option<&'a mut dyn common::Delegate>,
2368 _additional_params: HashMap<String, String>,
2369 _scopes: BTreeSet<String>,
2370}
2371
2372impl<'a, C> common::CallBuilder for TaskListCall<'a, C> {}
2373
2374impl<'a, C> TaskListCall<'a, C>
2375where
2376 C: common::Connector,
2377{
2378 /// Perform the operation you have build so far.
2379 pub async fn doit(mut self) -> common::Result<(common::Response, Tasks2)> {
2380 use std::borrow::Cow;
2381 use std::io::{Read, Seek};
2382
2383 use common::{url::Params, ToParts};
2384 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2385
2386 let mut dd = common::DefaultDelegate;
2387 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2388 dlg.begin(common::MethodInfo {
2389 id: "taskqueue.tasks.list",
2390 http_method: hyper::Method::GET,
2391 });
2392
2393 for &field in ["alt", "project", "taskqueue"].iter() {
2394 if self._additional_params.contains_key(field) {
2395 dlg.finished(false);
2396 return Err(common::Error::FieldClash(field));
2397 }
2398 }
2399
2400 let mut params = Params::with_capacity(4 + self._additional_params.len());
2401 params.push("project", self._project);
2402 params.push("taskqueue", self._taskqueue);
2403
2404 params.extend(self._additional_params.iter());
2405
2406 params.push("alt", "json");
2407 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks";
2408 if self._scopes.is_empty() {
2409 self._scopes.insert(Scope::Full.as_ref().to_string());
2410 }
2411
2412 #[allow(clippy::single_element_loop)]
2413 for &(find_this, param_name) in
2414 [("{project}", "project"), ("{taskqueue}", "taskqueue")].iter()
2415 {
2416 url = params.uri_replacement(url, param_name, find_this, false);
2417 }
2418 {
2419 let to_remove = ["taskqueue", "project"];
2420 params.remove_params(&to_remove);
2421 }
2422
2423 let url = params.parse_with_url(&url);
2424
2425 loop {
2426 let token = match self
2427 .hub
2428 .auth
2429 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2430 .await
2431 {
2432 Ok(token) => token,
2433 Err(e) => match dlg.token(e) {
2434 Ok(token) => token,
2435 Err(e) => {
2436 dlg.finished(false);
2437 return Err(common::Error::MissingToken(e));
2438 }
2439 },
2440 };
2441 let mut req_result = {
2442 let client = &self.hub.client;
2443 dlg.pre_request();
2444 let mut req_builder = hyper::Request::builder()
2445 .method(hyper::Method::GET)
2446 .uri(url.as_str())
2447 .header(USER_AGENT, self.hub._user_agent.clone());
2448
2449 if let Some(token) = token.as_ref() {
2450 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2451 }
2452
2453 let request = req_builder
2454 .header(CONTENT_LENGTH, 0_u64)
2455 .body(common::to_body::<String>(None));
2456
2457 client.request(request.unwrap()).await
2458 };
2459
2460 match req_result {
2461 Err(err) => {
2462 if let common::Retry::After(d) = dlg.http_error(&err) {
2463 sleep(d).await;
2464 continue;
2465 }
2466 dlg.finished(false);
2467 return Err(common::Error::HttpError(err));
2468 }
2469 Ok(res) => {
2470 let (mut parts, body) = res.into_parts();
2471 let mut body = common::Body::new(body);
2472 if !parts.status.is_success() {
2473 let bytes = common::to_bytes(body).await.unwrap_or_default();
2474 let error = serde_json::from_str(&common::to_string(&bytes));
2475 let response = common::to_response(parts, bytes.into());
2476
2477 if let common::Retry::After(d) =
2478 dlg.http_failure(&response, error.as_ref().ok())
2479 {
2480 sleep(d).await;
2481 continue;
2482 }
2483
2484 dlg.finished(false);
2485
2486 return Err(match error {
2487 Ok(value) => common::Error::BadRequest(value),
2488 _ => common::Error::Failure(response),
2489 });
2490 }
2491 let response = {
2492 let bytes = common::to_bytes(body).await.unwrap_or_default();
2493 let encoded = common::to_string(&bytes);
2494 match serde_json::from_str(&encoded) {
2495 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2496 Err(error) => {
2497 dlg.response_json_decode_error(&encoded, &error);
2498 return Err(common::Error::JsonDecodeError(
2499 encoded.to_string(),
2500 error,
2501 ));
2502 }
2503 }
2504 };
2505
2506 dlg.finished(true);
2507 return Ok(response);
2508 }
2509 }
2510 }
2511 }
2512
2513 /// The project under which the queue lies.
2514 ///
2515 /// Sets the *project* path property to the given value.
2516 ///
2517 /// Even though the property as already been set when instantiating this call,
2518 /// we provide this method for API completeness.
2519 pub fn project(mut self, new_value: &str) -> TaskListCall<'a, C> {
2520 self._project = new_value.to_string();
2521 self
2522 }
2523 /// The id of the taskqueue to list tasks from.
2524 ///
2525 /// Sets the *taskqueue* path property to the given value.
2526 ///
2527 /// Even though the property as already been set when instantiating this call,
2528 /// we provide this method for API completeness.
2529 pub fn taskqueue(mut self, new_value: &str) -> TaskListCall<'a, C> {
2530 self._taskqueue = new_value.to_string();
2531 self
2532 }
2533 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2534 /// while executing the actual API request.
2535 ///
2536 /// ````text
2537 /// It should be used to handle progress information, and to implement a certain level of resilience.
2538 /// ````
2539 ///
2540 /// Sets the *delegate* property to the given value.
2541 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskListCall<'a, C> {
2542 self._delegate = Some(new_value);
2543 self
2544 }
2545
2546 /// Set any additional parameter of the query string used in the request.
2547 /// It should be used to set parameters which are not yet available through their own
2548 /// setters.
2549 ///
2550 /// Please note that this method must not be used to set any of the known parameters
2551 /// which have their own setter method. If done anyway, the request will fail.
2552 ///
2553 /// # Additional Parameters
2554 ///
2555 /// * *alt* (query-string) - Data format for the response.
2556 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2557 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2558 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2559 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2560 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2561 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2562 pub fn param<T>(mut self, name: T, value: T) -> TaskListCall<'a, C>
2563 where
2564 T: AsRef<str>,
2565 {
2566 self._additional_params
2567 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2568 self
2569 }
2570
2571 /// Identifies the authorization scope for the method you are building.
2572 ///
2573 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2574 /// [`Scope::Full`].
2575 ///
2576 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2577 /// tokens for more than one scope.
2578 ///
2579 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2580 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2581 /// sufficient, a read-write scope will do as well.
2582 pub fn add_scope<St>(mut self, scope: St) -> TaskListCall<'a, C>
2583 where
2584 St: AsRef<str>,
2585 {
2586 self._scopes.insert(String::from(scope.as_ref()));
2587 self
2588 }
2589 /// Identifies the authorization scope(s) for the method you are building.
2590 ///
2591 /// See [`Self::add_scope()`] for details.
2592 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskListCall<'a, C>
2593 where
2594 I: IntoIterator<Item = St>,
2595 St: AsRef<str>,
2596 {
2597 self._scopes
2598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2599 self
2600 }
2601
2602 /// Removes all scopes, and no default scope will be used either.
2603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2604 /// for details).
2605 pub fn clear_scopes(mut self) -> TaskListCall<'a, C> {
2606 self._scopes.clear();
2607 self
2608 }
2609}
2610
2611/// Update tasks that are leased out of a TaskQueue. This method supports patch semantics.
2612///
2613/// A builder for the *patch* method supported by a *task* resource.
2614/// It is not used directly, but through a [`TaskMethods`] instance.
2615///
2616/// # Example
2617///
2618/// Instantiate a resource method builder
2619///
2620/// ```test_harness,no_run
2621/// # extern crate hyper;
2622/// # extern crate hyper_rustls;
2623/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
2624/// use taskqueue1_beta2::api::Task;
2625/// # async fn dox() {
2626/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2627///
2628/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2629/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2630/// # .with_native_roots()
2631/// # .unwrap()
2632/// # .https_only()
2633/// # .enable_http2()
2634/// # .build();
2635///
2636/// # let executor = hyper_util::rt::TokioExecutor::new();
2637/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2638/// # secret,
2639/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2640/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2641/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2642/// # ),
2643/// # ).build().await.unwrap();
2644///
2645/// # let client = hyper_util::client::legacy::Client::builder(
2646/// # hyper_util::rt::TokioExecutor::new()
2647/// # )
2648/// # .build(
2649/// # hyper_rustls::HttpsConnectorBuilder::new()
2650/// # .with_native_roots()
2651/// # .unwrap()
2652/// # .https_or_http()
2653/// # .enable_http2()
2654/// # .build()
2655/// # );
2656/// # let mut hub = Taskqueue::new(client, auth);
2657/// // As the method needs a request, you would usually fill it with the desired information
2658/// // into the respective structure. Some of the parts shown here might not be applicable !
2659/// // Values shown here are possibly random and not representative !
2660/// let mut req = Task::default();
2661///
2662/// // You can configure optional parameters by calling the respective setters at will, and
2663/// // execute the final call using `doit()`.
2664/// // Values shown here are possibly random and not representative !
2665/// let result = hub.tasks().patch(req, "project", "taskqueue", "task", -13)
2666/// .doit().await;
2667/// # }
2668/// ```
2669pub struct TaskPatchCall<'a, C>
2670where
2671 C: 'a,
2672{
2673 hub: &'a Taskqueue<C>,
2674 _request: Task,
2675 _project: String,
2676 _taskqueue: String,
2677 _task: String,
2678 _new_lease_seconds: i32,
2679 _delegate: Option<&'a mut dyn common::Delegate>,
2680 _additional_params: HashMap<String, String>,
2681 _scopes: BTreeSet<String>,
2682}
2683
2684impl<'a, C> common::CallBuilder for TaskPatchCall<'a, C> {}
2685
2686impl<'a, C> TaskPatchCall<'a, C>
2687where
2688 C: common::Connector,
2689{
2690 /// Perform the operation you have build so far.
2691 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
2692 use std::borrow::Cow;
2693 use std::io::{Read, Seek};
2694
2695 use common::{url::Params, ToParts};
2696 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2697
2698 let mut dd = common::DefaultDelegate;
2699 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2700 dlg.begin(common::MethodInfo {
2701 id: "taskqueue.tasks.patch",
2702 http_method: hyper::Method::PATCH,
2703 });
2704
2705 for &field in ["alt", "project", "taskqueue", "task", "newLeaseSeconds"].iter() {
2706 if self._additional_params.contains_key(field) {
2707 dlg.finished(false);
2708 return Err(common::Error::FieldClash(field));
2709 }
2710 }
2711
2712 let mut params = Params::with_capacity(7 + self._additional_params.len());
2713 params.push("project", self._project);
2714 params.push("taskqueue", self._taskqueue);
2715 params.push("task", self._task);
2716 params.push("newLeaseSeconds", self._new_lease_seconds.to_string());
2717
2718 params.extend(self._additional_params.iter());
2719
2720 params.push("alt", "json");
2721 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
2722 if self._scopes.is_empty() {
2723 self._scopes.insert(Scope::Full.as_ref().to_string());
2724 }
2725
2726 #[allow(clippy::single_element_loop)]
2727 for &(find_this, param_name) in [
2728 ("{project}", "project"),
2729 ("{taskqueue}", "taskqueue"),
2730 ("{task}", "task"),
2731 ]
2732 .iter()
2733 {
2734 url = params.uri_replacement(url, param_name, find_this, false);
2735 }
2736 {
2737 let to_remove = ["task", "taskqueue", "project"];
2738 params.remove_params(&to_remove);
2739 }
2740
2741 let url = params.parse_with_url(&url);
2742
2743 let mut json_mime_type = mime::APPLICATION_JSON;
2744 let mut request_value_reader = {
2745 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2746 common::remove_json_null_values(&mut value);
2747 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2748 serde_json::to_writer(&mut dst, &value).unwrap();
2749 dst
2750 };
2751 let request_size = request_value_reader
2752 .seek(std::io::SeekFrom::End(0))
2753 .unwrap();
2754 request_value_reader
2755 .seek(std::io::SeekFrom::Start(0))
2756 .unwrap();
2757
2758 loop {
2759 let token = match self
2760 .hub
2761 .auth
2762 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2763 .await
2764 {
2765 Ok(token) => token,
2766 Err(e) => match dlg.token(e) {
2767 Ok(token) => token,
2768 Err(e) => {
2769 dlg.finished(false);
2770 return Err(common::Error::MissingToken(e));
2771 }
2772 },
2773 };
2774 request_value_reader
2775 .seek(std::io::SeekFrom::Start(0))
2776 .unwrap();
2777 let mut req_result = {
2778 let client = &self.hub.client;
2779 dlg.pre_request();
2780 let mut req_builder = hyper::Request::builder()
2781 .method(hyper::Method::PATCH)
2782 .uri(url.as_str())
2783 .header(USER_AGENT, self.hub._user_agent.clone());
2784
2785 if let Some(token) = token.as_ref() {
2786 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2787 }
2788
2789 let request = req_builder
2790 .header(CONTENT_TYPE, json_mime_type.to_string())
2791 .header(CONTENT_LENGTH, request_size as u64)
2792 .body(common::to_body(
2793 request_value_reader.get_ref().clone().into(),
2794 ));
2795
2796 client.request(request.unwrap()).await
2797 };
2798
2799 match req_result {
2800 Err(err) => {
2801 if let common::Retry::After(d) = dlg.http_error(&err) {
2802 sleep(d).await;
2803 continue;
2804 }
2805 dlg.finished(false);
2806 return Err(common::Error::HttpError(err));
2807 }
2808 Ok(res) => {
2809 let (mut parts, body) = res.into_parts();
2810 let mut body = common::Body::new(body);
2811 if !parts.status.is_success() {
2812 let bytes = common::to_bytes(body).await.unwrap_or_default();
2813 let error = serde_json::from_str(&common::to_string(&bytes));
2814 let response = common::to_response(parts, bytes.into());
2815
2816 if let common::Retry::After(d) =
2817 dlg.http_failure(&response, error.as_ref().ok())
2818 {
2819 sleep(d).await;
2820 continue;
2821 }
2822
2823 dlg.finished(false);
2824
2825 return Err(match error {
2826 Ok(value) => common::Error::BadRequest(value),
2827 _ => common::Error::Failure(response),
2828 });
2829 }
2830 let response = {
2831 let bytes = common::to_bytes(body).await.unwrap_or_default();
2832 let encoded = common::to_string(&bytes);
2833 match serde_json::from_str(&encoded) {
2834 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2835 Err(error) => {
2836 dlg.response_json_decode_error(&encoded, &error);
2837 return Err(common::Error::JsonDecodeError(
2838 encoded.to_string(),
2839 error,
2840 ));
2841 }
2842 }
2843 };
2844
2845 dlg.finished(true);
2846 return Ok(response);
2847 }
2848 }
2849 }
2850 }
2851
2852 ///
2853 /// Sets the *request* property to the given value.
2854 ///
2855 /// Even though the property as already been set when instantiating this call,
2856 /// we provide this method for API completeness.
2857 pub fn request(mut self, new_value: Task) -> TaskPatchCall<'a, C> {
2858 self._request = new_value;
2859 self
2860 }
2861 /// The project under which the queue lies.
2862 ///
2863 /// Sets the *project* path property to the given value.
2864 ///
2865 /// Even though the property as already been set when instantiating this call,
2866 /// we provide this method for API completeness.
2867 pub fn project(mut self, new_value: &str) -> TaskPatchCall<'a, C> {
2868 self._project = new_value.to_string();
2869 self
2870 }
2871 ///
2872 /// Sets the *taskqueue* path property to the given value.
2873 ///
2874 /// Even though the property as already been set when instantiating this call,
2875 /// we provide this method for API completeness.
2876 pub fn taskqueue(mut self, new_value: &str) -> TaskPatchCall<'a, C> {
2877 self._taskqueue = new_value.to_string();
2878 self
2879 }
2880 ///
2881 /// Sets the *task* path property to the given value.
2882 ///
2883 /// Even though the property as already been set when instantiating this call,
2884 /// we provide this method for API completeness.
2885 pub fn task(mut self, new_value: &str) -> TaskPatchCall<'a, C> {
2886 self._task = new_value.to_string();
2887 self
2888 }
2889 /// The new lease in seconds.
2890 ///
2891 /// Sets the *new lease seconds* query property to the given value.
2892 ///
2893 /// Even though the property as already been set when instantiating this call,
2894 /// we provide this method for API completeness.
2895 pub fn new_lease_seconds(mut self, new_value: i32) -> TaskPatchCall<'a, C> {
2896 self._new_lease_seconds = new_value;
2897 self
2898 }
2899 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2900 /// while executing the actual API request.
2901 ///
2902 /// ````text
2903 /// It should be used to handle progress information, and to implement a certain level of resilience.
2904 /// ````
2905 ///
2906 /// Sets the *delegate* property to the given value.
2907 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskPatchCall<'a, C> {
2908 self._delegate = Some(new_value);
2909 self
2910 }
2911
2912 /// Set any additional parameter of the query string used in the request.
2913 /// It should be used to set parameters which are not yet available through their own
2914 /// setters.
2915 ///
2916 /// Please note that this method must not be used to set any of the known parameters
2917 /// which have their own setter method. If done anyway, the request will fail.
2918 ///
2919 /// # Additional Parameters
2920 ///
2921 /// * *alt* (query-string) - Data format for the response.
2922 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2923 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2924 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2925 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2926 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
2927 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
2928 pub fn param<T>(mut self, name: T, value: T) -> TaskPatchCall<'a, C>
2929 where
2930 T: AsRef<str>,
2931 {
2932 self._additional_params
2933 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2934 self
2935 }
2936
2937 /// Identifies the authorization scope for the method you are building.
2938 ///
2939 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2940 /// [`Scope::Full`].
2941 ///
2942 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2943 /// tokens for more than one scope.
2944 ///
2945 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2946 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2947 /// sufficient, a read-write scope will do as well.
2948 pub fn add_scope<St>(mut self, scope: St) -> TaskPatchCall<'a, C>
2949 where
2950 St: AsRef<str>,
2951 {
2952 self._scopes.insert(String::from(scope.as_ref()));
2953 self
2954 }
2955 /// Identifies the authorization scope(s) for the method you are building.
2956 ///
2957 /// See [`Self::add_scope()`] for details.
2958 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskPatchCall<'a, C>
2959 where
2960 I: IntoIterator<Item = St>,
2961 St: AsRef<str>,
2962 {
2963 self._scopes
2964 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2965 self
2966 }
2967
2968 /// Removes all scopes, and no default scope will be used either.
2969 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2970 /// for details).
2971 pub fn clear_scopes(mut self) -> TaskPatchCall<'a, C> {
2972 self._scopes.clear();
2973 self
2974 }
2975}
2976
2977/// Update tasks that are leased out of a TaskQueue.
2978///
2979/// A builder for the *update* method supported by a *task* resource.
2980/// It is not used directly, but through a [`TaskMethods`] instance.
2981///
2982/// # Example
2983///
2984/// Instantiate a resource method builder
2985///
2986/// ```test_harness,no_run
2987/// # extern crate hyper;
2988/// # extern crate hyper_rustls;
2989/// # extern crate google_taskqueue1_beta2 as taskqueue1_beta2;
2990/// use taskqueue1_beta2::api::Task;
2991/// # async fn dox() {
2992/// # use taskqueue1_beta2::{Taskqueue, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2993///
2994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2995/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2996/// # .with_native_roots()
2997/// # .unwrap()
2998/// # .https_only()
2999/// # .enable_http2()
3000/// # .build();
3001///
3002/// # let executor = hyper_util::rt::TokioExecutor::new();
3003/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3004/// # secret,
3005/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3006/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3007/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3008/// # ),
3009/// # ).build().await.unwrap();
3010///
3011/// # let client = hyper_util::client::legacy::Client::builder(
3012/// # hyper_util::rt::TokioExecutor::new()
3013/// # )
3014/// # .build(
3015/// # hyper_rustls::HttpsConnectorBuilder::new()
3016/// # .with_native_roots()
3017/// # .unwrap()
3018/// # .https_or_http()
3019/// # .enable_http2()
3020/// # .build()
3021/// # );
3022/// # let mut hub = Taskqueue::new(client, auth);
3023/// // As the method needs a request, you would usually fill it with the desired information
3024/// // into the respective structure. Some of the parts shown here might not be applicable !
3025/// // Values shown here are possibly random and not representative !
3026/// let mut req = Task::default();
3027///
3028/// // You can configure optional parameters by calling the respective setters at will, and
3029/// // execute the final call using `doit()`.
3030/// // Values shown here are possibly random and not representative !
3031/// let result = hub.tasks().update(req, "project", "taskqueue", "task", -68)
3032/// .doit().await;
3033/// # }
3034/// ```
3035pub struct TaskUpdateCall<'a, C>
3036where
3037 C: 'a,
3038{
3039 hub: &'a Taskqueue<C>,
3040 _request: Task,
3041 _project: String,
3042 _taskqueue: String,
3043 _task: String,
3044 _new_lease_seconds: i32,
3045 _delegate: Option<&'a mut dyn common::Delegate>,
3046 _additional_params: HashMap<String, String>,
3047 _scopes: BTreeSet<String>,
3048}
3049
3050impl<'a, C> common::CallBuilder for TaskUpdateCall<'a, C> {}
3051
3052impl<'a, C> TaskUpdateCall<'a, C>
3053where
3054 C: common::Connector,
3055{
3056 /// Perform the operation you have build so far.
3057 pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3058 use std::borrow::Cow;
3059 use std::io::{Read, Seek};
3060
3061 use common::{url::Params, ToParts};
3062 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3063
3064 let mut dd = common::DefaultDelegate;
3065 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3066 dlg.begin(common::MethodInfo {
3067 id: "taskqueue.tasks.update",
3068 http_method: hyper::Method::POST,
3069 });
3070
3071 for &field in ["alt", "project", "taskqueue", "task", "newLeaseSeconds"].iter() {
3072 if self._additional_params.contains_key(field) {
3073 dlg.finished(false);
3074 return Err(common::Error::FieldClash(field));
3075 }
3076 }
3077
3078 let mut params = Params::with_capacity(7 + self._additional_params.len());
3079 params.push("project", self._project);
3080 params.push("taskqueue", self._taskqueue);
3081 params.push("task", self._task);
3082 params.push("newLeaseSeconds", self._new_lease_seconds.to_string());
3083
3084 params.extend(self._additional_params.iter());
3085
3086 params.push("alt", "json");
3087 let mut url = self.hub._base_url.clone() + "{project}/taskqueues/{taskqueue}/tasks/{task}";
3088 if self._scopes.is_empty() {
3089 self._scopes.insert(Scope::Full.as_ref().to_string());
3090 }
3091
3092 #[allow(clippy::single_element_loop)]
3093 for &(find_this, param_name) in [
3094 ("{project}", "project"),
3095 ("{taskqueue}", "taskqueue"),
3096 ("{task}", "task"),
3097 ]
3098 .iter()
3099 {
3100 url = params.uri_replacement(url, param_name, find_this, false);
3101 }
3102 {
3103 let to_remove = ["task", "taskqueue", "project"];
3104 params.remove_params(&to_remove);
3105 }
3106
3107 let url = params.parse_with_url(&url);
3108
3109 let mut json_mime_type = mime::APPLICATION_JSON;
3110 let mut request_value_reader = {
3111 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3112 common::remove_json_null_values(&mut value);
3113 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3114 serde_json::to_writer(&mut dst, &value).unwrap();
3115 dst
3116 };
3117 let request_size = request_value_reader
3118 .seek(std::io::SeekFrom::End(0))
3119 .unwrap();
3120 request_value_reader
3121 .seek(std::io::SeekFrom::Start(0))
3122 .unwrap();
3123
3124 loop {
3125 let token = match self
3126 .hub
3127 .auth
3128 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3129 .await
3130 {
3131 Ok(token) => token,
3132 Err(e) => match dlg.token(e) {
3133 Ok(token) => token,
3134 Err(e) => {
3135 dlg.finished(false);
3136 return Err(common::Error::MissingToken(e));
3137 }
3138 },
3139 };
3140 request_value_reader
3141 .seek(std::io::SeekFrom::Start(0))
3142 .unwrap();
3143 let mut req_result = {
3144 let client = &self.hub.client;
3145 dlg.pre_request();
3146 let mut req_builder = hyper::Request::builder()
3147 .method(hyper::Method::POST)
3148 .uri(url.as_str())
3149 .header(USER_AGENT, self.hub._user_agent.clone());
3150
3151 if let Some(token) = token.as_ref() {
3152 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3153 }
3154
3155 let request = req_builder
3156 .header(CONTENT_TYPE, json_mime_type.to_string())
3157 .header(CONTENT_LENGTH, request_size as u64)
3158 .body(common::to_body(
3159 request_value_reader.get_ref().clone().into(),
3160 ));
3161
3162 client.request(request.unwrap()).await
3163 };
3164
3165 match req_result {
3166 Err(err) => {
3167 if let common::Retry::After(d) = dlg.http_error(&err) {
3168 sleep(d).await;
3169 continue;
3170 }
3171 dlg.finished(false);
3172 return Err(common::Error::HttpError(err));
3173 }
3174 Ok(res) => {
3175 let (mut parts, body) = res.into_parts();
3176 let mut body = common::Body::new(body);
3177 if !parts.status.is_success() {
3178 let bytes = common::to_bytes(body).await.unwrap_or_default();
3179 let error = serde_json::from_str(&common::to_string(&bytes));
3180 let response = common::to_response(parts, bytes.into());
3181
3182 if let common::Retry::After(d) =
3183 dlg.http_failure(&response, error.as_ref().ok())
3184 {
3185 sleep(d).await;
3186 continue;
3187 }
3188
3189 dlg.finished(false);
3190
3191 return Err(match error {
3192 Ok(value) => common::Error::BadRequest(value),
3193 _ => common::Error::Failure(response),
3194 });
3195 }
3196 let response = {
3197 let bytes = common::to_bytes(body).await.unwrap_or_default();
3198 let encoded = common::to_string(&bytes);
3199 match serde_json::from_str(&encoded) {
3200 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3201 Err(error) => {
3202 dlg.response_json_decode_error(&encoded, &error);
3203 return Err(common::Error::JsonDecodeError(
3204 encoded.to_string(),
3205 error,
3206 ));
3207 }
3208 }
3209 };
3210
3211 dlg.finished(true);
3212 return Ok(response);
3213 }
3214 }
3215 }
3216 }
3217
3218 ///
3219 /// Sets the *request* property to the given value.
3220 ///
3221 /// Even though the property as already been set when instantiating this call,
3222 /// we provide this method for API completeness.
3223 pub fn request(mut self, new_value: Task) -> TaskUpdateCall<'a, C> {
3224 self._request = new_value;
3225 self
3226 }
3227 /// The project under which the queue lies.
3228 ///
3229 /// Sets the *project* path property to the given value.
3230 ///
3231 /// Even though the property as already been set when instantiating this call,
3232 /// we provide this method for API completeness.
3233 pub fn project(mut self, new_value: &str) -> TaskUpdateCall<'a, C> {
3234 self._project = new_value.to_string();
3235 self
3236 }
3237 ///
3238 /// Sets the *taskqueue* path property to the given value.
3239 ///
3240 /// Even though the property as already been set when instantiating this call,
3241 /// we provide this method for API completeness.
3242 pub fn taskqueue(mut self, new_value: &str) -> TaskUpdateCall<'a, C> {
3243 self._taskqueue = new_value.to_string();
3244 self
3245 }
3246 ///
3247 /// Sets the *task* path property to the given value.
3248 ///
3249 /// Even though the property as already been set when instantiating this call,
3250 /// we provide this method for API completeness.
3251 pub fn task(mut self, new_value: &str) -> TaskUpdateCall<'a, C> {
3252 self._task = new_value.to_string();
3253 self
3254 }
3255 /// The new lease in seconds.
3256 ///
3257 /// Sets the *new lease seconds* query property to the given value.
3258 ///
3259 /// Even though the property as already been set when instantiating this call,
3260 /// we provide this method for API completeness.
3261 pub fn new_lease_seconds(mut self, new_value: i32) -> TaskUpdateCall<'a, C> {
3262 self._new_lease_seconds = new_value;
3263 self
3264 }
3265 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3266 /// while executing the actual API request.
3267 ///
3268 /// ````text
3269 /// It should be used to handle progress information, and to implement a certain level of resilience.
3270 /// ````
3271 ///
3272 /// Sets the *delegate* property to the given value.
3273 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskUpdateCall<'a, C> {
3274 self._delegate = Some(new_value);
3275 self
3276 }
3277
3278 /// Set any additional parameter of the query string used in the request.
3279 /// It should be used to set parameters which are not yet available through their own
3280 /// setters.
3281 ///
3282 /// Please note that this method must not be used to set any of the known parameters
3283 /// which have their own setter method. If done anyway, the request will fail.
3284 ///
3285 /// # Additional Parameters
3286 ///
3287 /// * *alt* (query-string) - Data format for the response.
3288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3289 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3292 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. Overrides userIp if both are provided.
3293 /// * *userIp* (query-string) - IP address of the site where the request originates. Use this if you want to enforce per-user limits.
3294 pub fn param<T>(mut self, name: T, value: T) -> TaskUpdateCall<'a, C>
3295 where
3296 T: AsRef<str>,
3297 {
3298 self._additional_params
3299 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3300 self
3301 }
3302
3303 /// Identifies the authorization scope for the method you are building.
3304 ///
3305 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3306 /// [`Scope::Full`].
3307 ///
3308 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3309 /// tokens for more than one scope.
3310 ///
3311 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3312 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3313 /// sufficient, a read-write scope will do as well.
3314 pub fn add_scope<St>(mut self, scope: St) -> TaskUpdateCall<'a, C>
3315 where
3316 St: AsRef<str>,
3317 {
3318 self._scopes.insert(String::from(scope.as_ref()));
3319 self
3320 }
3321 /// Identifies the authorization scope(s) for the method you are building.
3322 ///
3323 /// See [`Self::add_scope()`] for details.
3324 pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskUpdateCall<'a, C>
3325 where
3326 I: IntoIterator<Item = St>,
3327 St: AsRef<str>,
3328 {
3329 self._scopes
3330 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3331 self
3332 }
3333
3334 /// Removes all scopes, and no default scope will be used either.
3335 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3336 /// for details).
3337 pub fn clear_scopes(mut self) -> TaskUpdateCall<'a, C> {
3338 self._scopes.clear();
3339 self
3340 }
3341}