google_tasks1/
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    /// Create, edit, organize, and delete all your tasks
17    Full,
18
19    /// View your tasks
20    Readonly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::Full => "https://www.googleapis.com/auth/tasks",
27            Scope::Readonly => "https://www.googleapis.com/auth/tasks.readonly",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Readonly
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all TasksHub 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_tasks1 as tasks1;
53/// use tasks1::{Result, Error};
54/// # async fn dox() {
55/// use tasks1::{TasksHub, 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 = TasksHub::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().list("tasklist")
97///              .updated_min("est")
98///              .show_hidden(true)
99///              .show_deleted(false)
100///              .show_completed(true)
101///              .show_assigned(false)
102///              .page_token("sed")
103///              .max_results(-70)
104///              .due_min("sed")
105///              .due_max("no")
106///              .completed_min("Stet")
107///              .completed_max("kasd")
108///              .doit().await;
109///
110/// match result {
111///     Err(e) => match e {
112///         // The Error enum provides details about what exactly happened.
113///         // You can also just use its `Debug`, `Display` or `Error` traits
114///          Error::HttpError(_)
115///         |Error::Io(_)
116///         |Error::MissingAPIKey
117///         |Error::MissingToken(_)
118///         |Error::Cancelled
119///         |Error::UploadSizeLimitExceeded(_, _)
120///         |Error::Failure(_)
121///         |Error::BadRequest(_)
122///         |Error::FieldClash(_)
123///         |Error::JsonDecodeError(_, _) => println!("{}", e),
124///     },
125///     Ok(res) => println!("Success: {:?}", res),
126/// }
127/// # }
128/// ```
129#[derive(Clone)]
130pub struct TasksHub<C> {
131    pub client: common::Client<C>,
132    pub auth: Box<dyn common::GetToken>,
133    _user_agent: String,
134    _base_url: String,
135    _root_url: String,
136}
137
138impl<C> common::Hub for TasksHub<C> {}
139
140impl<'a, C> TasksHub<C> {
141    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> TasksHub<C> {
142        TasksHub {
143            client,
144            auth: Box::new(auth),
145            _user_agent: "google-api-rust-client/7.0.0".to_string(),
146            _base_url: "https://tasks.googleapis.com/".to_string(),
147            _root_url: "https://tasks.googleapis.com/".to_string(),
148        }
149    }
150
151    pub fn tasklists(&'a self) -> TasklistMethods<'a, C> {
152        TasklistMethods { hub: self }
153    }
154    pub fn tasks(&'a self) -> TaskMethods<'a, C> {
155        TaskMethods { hub: self }
156    }
157
158    /// Set the user-agent header field to use in all requests to the server.
159    /// It defaults to `google-api-rust-client/7.0.0`.
160    ///
161    /// Returns the previously set user-agent.
162    pub fn user_agent(&mut self, agent_name: String) -> String {
163        std::mem::replace(&mut self._user_agent, agent_name)
164    }
165
166    /// Set the base url to use in all requests to the server.
167    /// It defaults to `https://tasks.googleapis.com/`.
168    ///
169    /// Returns the previously set base url.
170    pub fn base_url(&mut self, new_base_url: String) -> String {
171        std::mem::replace(&mut self._base_url, new_base_url)
172    }
173
174    /// Set the root url to use in all requests to the server.
175    /// It defaults to `https://tasks.googleapis.com/`.
176    ///
177    /// Returns the previously set root url.
178    pub fn root_url(&mut self, new_root_url: String) -> String {
179        std::mem::replace(&mut self._root_url, new_root_url)
180    }
181}
182
183// ############
184// SCHEMAS ###
185// ##########
186/// Information about the source of the task assignment (Document, Chat Space).
187///
188/// This type is not used in any activity, and only used as *part* of another schema.
189///
190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
191#[serde_with::serde_as]
192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
193pub struct AssignmentInfo {
194    /// Output only. Information about the Drive file where this task originates from. Currently, the Drive file can only be a document. This field is read-only.
195    #[serde(rename = "driveResourceInfo")]
196    pub drive_resource_info: Option<DriveResourceInfo>,
197    /// Output only. An absolute link to the original task in the surface of assignment (Docs, Chat spaces, etc.).
198    #[serde(rename = "linkToTask")]
199    pub link_to_task: Option<String>,
200    /// Output only. Information about the Chat Space where this task originates from. This field is read-only.
201    #[serde(rename = "spaceInfo")]
202    pub space_info: Option<SpaceInfo>,
203    /// Output only. The type of surface this assigned task originates from. Currently limited to DOCUMENT or SPACE.
204    #[serde(rename = "surfaceType")]
205    pub surface_type: Option<String>,
206}
207
208impl common::Part for AssignmentInfo {}
209
210/// Information about the Drive resource where a task was assigned from (the document, sheet, etc.).
211///
212/// This type is not used in any activity, and only used as *part* of another schema.
213///
214#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
215#[serde_with::serde_as]
216#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
217pub struct DriveResourceInfo {
218    /// Output only. Identifier of the file in the Drive API.
219    #[serde(rename = "driveFileId")]
220    pub drive_file_id: Option<String>,
221    /// Output only. Resource key required to access files shared via a shared link. Not required for all files. See also developers.google.com/drive/api/guides/resource-keys.
222    #[serde(rename = "resourceKey")]
223    pub resource_key: Option<String>,
224}
225
226impl common::Part for DriveResourceInfo {}
227
228/// Information about the Chat Space where a task was assigned from.
229///
230/// This type is not used in any activity, and only used as *part* of another schema.
231///
232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
233#[serde_with::serde_as]
234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
235pub struct SpaceInfo {
236    /// Output only. The Chat space where this task originates from. The format is "spaces/{space}".
237    pub space: Option<String>,
238}
239
240impl common::Part for SpaceInfo {}
241
242/// There is no detailed description.
243///
244/// # Activities
245///
246/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
247/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
248///
249/// * [clear tasks](TaskClearCall) (none)
250/// * [delete tasks](TaskDeleteCall) (none)
251/// * [get tasks](TaskGetCall) (response)
252/// * [insert tasks](TaskInsertCall) (request|response)
253/// * [list tasks](TaskListCall) (none)
254/// * [move tasks](TaskMoveCall) (response)
255/// * [patch tasks](TaskPatchCall) (request|response)
256/// * [update tasks](TaskUpdateCall) (request|response)
257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
258#[serde_with::serde_as]
259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
260pub struct Task {
261    /// Output only. Context information for assigned tasks. A task can be assigned to a user, currently possible from surfaces like Docs and Chat Spaces. This field is populated for tasks assigned to the current user and identifies where the task was assigned from. This field is read-only.
262    #[serde(rename = "assignmentInfo")]
263    pub assignment_info: Option<AssignmentInfo>,
264    /// Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.
265    pub completed: Option<String>,
266    /// Flag indicating whether the task has been deleted. For assigned tasks this field is read-only. They can only be deleted by calling tasks.delete, in which case both the assigned task and the original task (in Docs or Chat Spaces) are deleted. To delete the assigned task only, navigate to the assignment surface and unassign the task from there. The default is False.
267    pub deleted: Option<bool>,
268    /// Scheduled date for the task (as an RFC 3339 timestamp). Optional. This represents the day that the task should be done, or that the task is visible on the calendar grid. It doesn't represent the deadline of the task. Only date information is recorded; the time portion of the timestamp is discarded when setting this field. It isn't possible to read or write the time that a task is scheduled for using the API.
269    pub due: Option<String>,
270    /// ETag of the resource.
271    pub etag: Option<String>,
272    /// Flag indicating whether the task is hidden. This is the case if the task had been marked completed when the task list was last cleared. The default is False. This field is read-only.
273    pub hidden: Option<bool>,
274    /// Task identifier.
275    pub id: Option<String>,
276    /// Output only. Type of the resource. This is always "tasks#task".
277    pub kind: Option<String>,
278    /// Output only. Collection of links. This collection is read-only.
279    pub links: Option<Vec<TaskLinks>>,
280    /// Notes describing the task. Tasks assigned from Google Docs cannot have notes. Optional. Maximum length allowed: 8192 characters.
281    pub notes: Option<String>,
282    /// Output only. Parent task identifier. This field is omitted if it is a top-level task. Use the "move" method to move the task under a different parent or to the top level. A parent task can never be an assigned task (from Chat Spaces, Docs). This field is read-only.
283    pub parent: Option<String>,
284    /// Output only. String indicating the position of the task among its sibling tasks under the same parent task or at the top level. If this string is greater than another task's corresponding position string according to lexicographical ordering, the task is positioned after the other task under the same parent task (or at the top level). Use the "move" method to move the task to another position.
285    pub position: Option<String>,
286    /// Output only. URL pointing to this task. Used to retrieve, update, or delete this task.
287    #[serde(rename = "selfLink")]
288    pub self_link: Option<String>,
289    /// Status of the task. This is either "needsAction" or "completed".
290    pub status: Option<String>,
291    /// Title of the task. Maximum length allowed: 1024 characters.
292    pub title: Option<String>,
293    /// Output only. Last modification time of the task (as a RFC 3339 timestamp).
294    pub updated: Option<String>,
295    /// Output only. An absolute link to the task in the Google Tasks Web UI.
296    #[serde(rename = "webViewLink")]
297    pub web_view_link: Option<String>,
298}
299
300impl common::RequestValue for Task {}
301impl common::Resource for Task {}
302impl common::ResponseResult for Task {}
303
304/// There is no detailed description.
305///
306/// # Activities
307///
308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
310///
311/// * [get tasklists](TasklistGetCall) (response)
312/// * [insert tasklists](TasklistInsertCall) (request|response)
313/// * [patch tasklists](TasklistPatchCall) (request|response)
314/// * [update tasklists](TasklistUpdateCall) (request|response)
315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
316#[serde_with::serde_as]
317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
318pub struct TaskList {
319    /// ETag of the resource.
320    pub etag: Option<String>,
321    /// Task list identifier.
322    pub id: Option<String>,
323    /// Output only. Type of the resource. This is always "tasks#taskList".
324    pub kind: Option<String>,
325    /// Output only. URL pointing to this task list. Used to retrieve, update, or delete this task list.
326    #[serde(rename = "selfLink")]
327    pub self_link: Option<String>,
328    /// Title of the task list. Maximum length allowed: 1024 characters.
329    pub title: Option<String>,
330    /// Output only. Last modification time of the task list (as a RFC 3339 timestamp).
331    pub updated: Option<String>,
332}
333
334impl common::RequestValue for TaskList {}
335impl common::Resource for TaskList {}
336impl common::ResponseResult for TaskList {}
337
338/// There is no detailed description.
339///
340/// # Activities
341///
342/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
343/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
344///
345/// * [list tasklists](TasklistListCall) (response)
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct TaskLists {
350    /// ETag of the resource.
351    pub etag: Option<String>,
352    /// Collection of task lists.
353    pub items: Option<Vec<TaskList>>,
354    /// Type of the resource. This is always "tasks#taskLists".
355    pub kind: Option<String>,
356    /// Token that can be used to request the next page of this result.
357    #[serde(rename = "nextPageToken")]
358    pub next_page_token: Option<String>,
359}
360
361impl common::ResponseResult for TaskLists {}
362
363/// There is no detailed description.
364///
365/// # Activities
366///
367/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
368/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
369///
370/// * [list tasks](TaskListCall) (response)
371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
372#[serde_with::serde_as]
373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
374pub struct Tasks {
375    /// ETag of the resource.
376    pub etag: Option<String>,
377    /// Collection of tasks.
378    pub items: Option<Vec<Task>>,
379    /// Type of the resource. This is always "tasks#tasks".
380    pub kind: Option<String>,
381    /// Token used to access the next page of this result.
382    #[serde(rename = "nextPageToken")]
383    pub next_page_token: Option<String>,
384}
385
386impl common::ResponseResult for Tasks {}
387
388/// Output only. Collection of links. This collection is read-only.
389///
390/// This type is not used in any activity, and only used as *part* of another schema.
391///
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct TaskLinks {
396    /// The description (might be empty).
397    pub description: Option<String>,
398    /// The URL.
399    pub link: Option<String>,
400    /// Type of the link, e.g. "email", "generic", "chat_message", "keep_note".
401    #[serde(rename = "type")]
402    pub type_: Option<String>,
403}
404
405impl common::NestedType for TaskLinks {}
406impl common::Part for TaskLinks {}
407
408// ###################
409// MethodBuilders ###
410// #################
411
412/// A builder providing access to all methods supported on *tasklist* resources.
413/// It is not used directly, but through the [`TasksHub`] hub.
414///
415/// # Example
416///
417/// Instantiate a resource builder
418///
419/// ```test_harness,no_run
420/// extern crate hyper;
421/// extern crate hyper_rustls;
422/// extern crate google_tasks1 as tasks1;
423///
424/// # async fn dox() {
425/// use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
426///
427/// let secret: yup_oauth2::ApplicationSecret = Default::default();
428/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
429///     .with_native_roots()
430///     .unwrap()
431///     .https_only()
432///     .enable_http2()
433///     .build();
434///
435/// let executor = hyper_util::rt::TokioExecutor::new();
436/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
437///     secret,
438///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
439///     yup_oauth2::client::CustomHyperClientBuilder::from(
440///         hyper_util::client::legacy::Client::builder(executor).build(connector),
441///     ),
442/// ).build().await.unwrap();
443///
444/// let client = hyper_util::client::legacy::Client::builder(
445///     hyper_util::rt::TokioExecutor::new()
446/// )
447/// .build(
448///     hyper_rustls::HttpsConnectorBuilder::new()
449///         .with_native_roots()
450///         .unwrap()
451///         .https_or_http()
452///         .enable_http2()
453///         .build()
454/// );
455/// let mut hub = TasksHub::new(client, auth);
456/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
457/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
458/// // to build up your call.
459/// let rb = hub.tasklists();
460/// # }
461/// ```
462pub struct TasklistMethods<'a, C>
463where
464    C: 'a,
465{
466    hub: &'a TasksHub<C>,
467}
468
469impl<'a, C> common::MethodsBuilder for TasklistMethods<'a, C> {}
470
471impl<'a, C> TasklistMethods<'a, C> {
472    /// Create a builder to help you perform the following task:
473    ///
474    /// Deletes the authenticated user's specified task list. If the list contains assigned tasks, both the assigned tasks and the original tasks in the assignment surface (Docs, Chat Spaces) are deleted.
475    ///
476    /// # Arguments
477    ///
478    /// * `tasklist` - Task list identifier.
479    pub fn delete(&self, tasklist: &str) -> TasklistDeleteCall<'a, C> {
480        TasklistDeleteCall {
481            hub: self.hub,
482            _tasklist: tasklist.to_string(),
483            _delegate: Default::default(),
484            _additional_params: Default::default(),
485            _scopes: Default::default(),
486        }
487    }
488
489    /// Create a builder to help you perform the following task:
490    ///
491    /// Returns the authenticated user's specified task list.
492    ///
493    /// # Arguments
494    ///
495    /// * `tasklist` - Task list identifier.
496    pub fn get(&self, tasklist: &str) -> TasklistGetCall<'a, C> {
497        TasklistGetCall {
498            hub: self.hub,
499            _tasklist: tasklist.to_string(),
500            _delegate: Default::default(),
501            _additional_params: Default::default(),
502            _scopes: Default::default(),
503        }
504    }
505
506    /// Create a builder to help you perform the following task:
507    ///
508    /// Creates a new task list and adds it to the authenticated user's task lists. A user can have up to 2000 lists at a time.
509    ///
510    /// # Arguments
511    ///
512    /// * `request` - No description provided.
513    pub fn insert(&self, request: TaskList) -> TasklistInsertCall<'a, C> {
514        TasklistInsertCall {
515            hub: self.hub,
516            _request: request,
517            _delegate: Default::default(),
518            _additional_params: Default::default(),
519            _scopes: Default::default(),
520        }
521    }
522
523    /// Create a builder to help you perform the following task:
524    ///
525    /// Returns all the authenticated user's task lists. A user can have up to 2000 lists at a time.
526    pub fn list(&self) -> TasklistListCall<'a, C> {
527        TasklistListCall {
528            hub: self.hub,
529            _page_token: Default::default(),
530            _max_results: Default::default(),
531            _delegate: Default::default(),
532            _additional_params: Default::default(),
533            _scopes: Default::default(),
534        }
535    }
536
537    /// Create a builder to help you perform the following task:
538    ///
539    /// Updates the authenticated user's specified task list. This method supports patch semantics.
540    ///
541    /// # Arguments
542    ///
543    /// * `request` - No description provided.
544    /// * `tasklist` - Task list identifier.
545    pub fn patch(&self, request: TaskList, tasklist: &str) -> TasklistPatchCall<'a, C> {
546        TasklistPatchCall {
547            hub: self.hub,
548            _request: request,
549            _tasklist: tasklist.to_string(),
550            _delegate: Default::default(),
551            _additional_params: Default::default(),
552            _scopes: Default::default(),
553        }
554    }
555
556    /// Create a builder to help you perform the following task:
557    ///
558    /// Updates the authenticated user's specified task list.
559    ///
560    /// # Arguments
561    ///
562    /// * `request` - No description provided.
563    /// * `tasklist` - Task list identifier.
564    pub fn update(&self, request: TaskList, tasklist: &str) -> TasklistUpdateCall<'a, C> {
565        TasklistUpdateCall {
566            hub: self.hub,
567            _request: request,
568            _tasklist: tasklist.to_string(),
569            _delegate: Default::default(),
570            _additional_params: Default::default(),
571            _scopes: Default::default(),
572        }
573    }
574}
575
576/// A builder providing access to all methods supported on *task* resources.
577/// It is not used directly, but through the [`TasksHub`] hub.
578///
579/// # Example
580///
581/// Instantiate a resource builder
582///
583/// ```test_harness,no_run
584/// extern crate hyper;
585/// extern crate hyper_rustls;
586/// extern crate google_tasks1 as tasks1;
587///
588/// # async fn dox() {
589/// use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
590///
591/// let secret: yup_oauth2::ApplicationSecret = Default::default();
592/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
593///     .with_native_roots()
594///     .unwrap()
595///     .https_only()
596///     .enable_http2()
597///     .build();
598///
599/// let executor = hyper_util::rt::TokioExecutor::new();
600/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
601///     secret,
602///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
603///     yup_oauth2::client::CustomHyperClientBuilder::from(
604///         hyper_util::client::legacy::Client::builder(executor).build(connector),
605///     ),
606/// ).build().await.unwrap();
607///
608/// let client = hyper_util::client::legacy::Client::builder(
609///     hyper_util::rt::TokioExecutor::new()
610/// )
611/// .build(
612///     hyper_rustls::HttpsConnectorBuilder::new()
613///         .with_native_roots()
614///         .unwrap()
615///         .https_or_http()
616///         .enable_http2()
617///         .build()
618/// );
619/// let mut hub = TasksHub::new(client, auth);
620/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
621/// // like `clear(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `move_(...)`, `patch(...)` and `update(...)`
622/// // to build up your call.
623/// let rb = hub.tasks();
624/// # }
625/// ```
626pub struct TaskMethods<'a, C>
627where
628    C: 'a,
629{
630    hub: &'a TasksHub<C>,
631}
632
633impl<'a, C> common::MethodsBuilder for TaskMethods<'a, C> {}
634
635impl<'a, C> TaskMethods<'a, C> {
636    /// Create a builder to help you perform the following task:
637    ///
638    /// Clears all completed tasks from the specified task list. The affected tasks will be marked as 'hidden' and no longer be returned by default when retrieving all tasks for a task list.
639    ///
640    /// # Arguments
641    ///
642    /// * `tasklist` - Task list identifier.
643    pub fn clear(&self, tasklist: &str) -> TaskClearCall<'a, C> {
644        TaskClearCall {
645            hub: self.hub,
646            _tasklist: tasklist.to_string(),
647            _delegate: Default::default(),
648            _additional_params: Default::default(),
649            _scopes: Default::default(),
650        }
651    }
652
653    /// Create a builder to help you perform the following task:
654    ///
655    /// Deletes the specified task from the task list. If the task is assigned, both the assigned task and the original task (in Docs, Chat Spaces) are deleted. To delete the assigned task only, navigate to the assignment surface and unassign the task from there.
656    ///
657    /// # Arguments
658    ///
659    /// * `tasklist` - Task list identifier.
660    /// * `task` - Task identifier.
661    pub fn delete(&self, tasklist: &str, task: &str) -> TaskDeleteCall<'a, C> {
662        TaskDeleteCall {
663            hub: self.hub,
664            _tasklist: tasklist.to_string(),
665            _task: task.to_string(),
666            _delegate: Default::default(),
667            _additional_params: Default::default(),
668            _scopes: Default::default(),
669        }
670    }
671
672    /// Create a builder to help you perform the following task:
673    ///
674    /// Returns the specified task.
675    ///
676    /// # Arguments
677    ///
678    /// * `tasklist` - Task list identifier.
679    /// * `task` - Task identifier.
680    pub fn get(&self, tasklist: &str, task: &str) -> TaskGetCall<'a, C> {
681        TaskGetCall {
682            hub: self.hub,
683            _tasklist: tasklist.to_string(),
684            _task: task.to_string(),
685            _delegate: Default::default(),
686            _additional_params: Default::default(),
687            _scopes: Default::default(),
688        }
689    }
690
691    /// Create a builder to help you perform the following task:
692    ///
693    /// Creates a new task on the specified task list. Tasks assigned from Docs or Chat Spaces cannot be inserted from Tasks Public API; they can only be created by assigning them from Docs or Chat Spaces. A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.
694    ///
695    /// # Arguments
696    ///
697    /// * `request` - No description provided.
698    /// * `tasklist` - Task list identifier.
699    pub fn insert(&self, request: Task, tasklist: &str) -> TaskInsertCall<'a, C> {
700        TaskInsertCall {
701            hub: self.hub,
702            _request: request,
703            _tasklist: tasklist.to_string(),
704            _previous: Default::default(),
705            _parent: Default::default(),
706            _delegate: Default::default(),
707            _additional_params: Default::default(),
708            _scopes: Default::default(),
709        }
710    }
711
712    /// Create a builder to help you perform the following task:
713    ///
714    /// Returns all tasks in the specified task list. Doesn't return assigned tasks by default (from Docs, Chat Spaces). A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.
715    ///
716    /// # Arguments
717    ///
718    /// * `tasklist` - Task list identifier.
719    pub fn list(&self, tasklist: &str) -> TaskListCall<'a, C> {
720        TaskListCall {
721            hub: self.hub,
722            _tasklist: tasklist.to_string(),
723            _updated_min: Default::default(),
724            _show_hidden: Default::default(),
725            _show_deleted: Default::default(),
726            _show_completed: Default::default(),
727            _show_assigned: Default::default(),
728            _page_token: Default::default(),
729            _max_results: Default::default(),
730            _due_min: Default::default(),
731            _due_max: Default::default(),
732            _completed_min: Default::default(),
733            _completed_max: Default::default(),
734            _delegate: Default::default(),
735            _additional_params: Default::default(),
736            _scopes: Default::default(),
737        }
738    }
739
740    /// Create a builder to help you perform the following task:
741    ///
742    /// Moves the specified task to another position in the destination task list. If the destination list is not specified, the task is moved within its current list. This can include putting it as a child task under a new parent and/or move it to a different position among its sibling tasks. A user can have up to 2,000 subtasks per task.
743    ///
744    /// # Arguments
745    ///
746    /// * `tasklist` - Task list identifier.
747    /// * `task` - Task identifier.
748    pub fn move_(&self, tasklist: &str, task: &str) -> TaskMoveCall<'a, C> {
749        TaskMoveCall {
750            hub: self.hub,
751            _tasklist: tasklist.to_string(),
752            _task: task.to_string(),
753            _previous: Default::default(),
754            _parent: Default::default(),
755            _destination_tasklist: Default::default(),
756            _delegate: Default::default(),
757            _additional_params: Default::default(),
758            _scopes: Default::default(),
759        }
760    }
761
762    /// Create a builder to help you perform the following task:
763    ///
764    /// Updates the specified task. This method supports patch semantics.
765    ///
766    /// # Arguments
767    ///
768    /// * `request` - No description provided.
769    /// * `tasklist` - Task list identifier.
770    /// * `task` - Task identifier.
771    pub fn patch(&self, request: Task, tasklist: &str, task: &str) -> TaskPatchCall<'a, C> {
772        TaskPatchCall {
773            hub: self.hub,
774            _request: request,
775            _tasklist: tasklist.to_string(),
776            _task: task.to_string(),
777            _delegate: Default::default(),
778            _additional_params: Default::default(),
779            _scopes: Default::default(),
780        }
781    }
782
783    /// Create a builder to help you perform the following task:
784    ///
785    /// Updates the specified task.
786    ///
787    /// # Arguments
788    ///
789    /// * `request` - No description provided.
790    /// * `tasklist` - Task list identifier.
791    /// * `task` - Task identifier.
792    pub fn update(&self, request: Task, tasklist: &str, task: &str) -> TaskUpdateCall<'a, C> {
793        TaskUpdateCall {
794            hub: self.hub,
795            _request: request,
796            _tasklist: tasklist.to_string(),
797            _task: task.to_string(),
798            _delegate: Default::default(),
799            _additional_params: Default::default(),
800            _scopes: Default::default(),
801        }
802    }
803}
804
805// ###################
806// CallBuilders   ###
807// #################
808
809/// Deletes the authenticated user's specified task list. If the list contains assigned tasks, both the assigned tasks and the original tasks in the assignment surface (Docs, Chat Spaces) are deleted.
810///
811/// A builder for the *delete* method supported by a *tasklist* resource.
812/// It is not used directly, but through a [`TasklistMethods`] instance.
813///
814/// # Example
815///
816/// Instantiate a resource method builder
817///
818/// ```test_harness,no_run
819/// # extern crate hyper;
820/// # extern crate hyper_rustls;
821/// # extern crate google_tasks1 as tasks1;
822/// # async fn dox() {
823/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
824///
825/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
826/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
827/// #     .with_native_roots()
828/// #     .unwrap()
829/// #     .https_only()
830/// #     .enable_http2()
831/// #     .build();
832///
833/// # let executor = hyper_util::rt::TokioExecutor::new();
834/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
835/// #     secret,
836/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
837/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
838/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
839/// #     ),
840/// # ).build().await.unwrap();
841///
842/// # let client = hyper_util::client::legacy::Client::builder(
843/// #     hyper_util::rt::TokioExecutor::new()
844/// # )
845/// # .build(
846/// #     hyper_rustls::HttpsConnectorBuilder::new()
847/// #         .with_native_roots()
848/// #         .unwrap()
849/// #         .https_or_http()
850/// #         .enable_http2()
851/// #         .build()
852/// # );
853/// # let mut hub = TasksHub::new(client, auth);
854/// // You can configure optional parameters by calling the respective setters at will, and
855/// // execute the final call using `doit()`.
856/// // Values shown here are possibly random and not representative !
857/// let result = hub.tasklists().delete("tasklist")
858///              .doit().await;
859/// # }
860/// ```
861pub struct TasklistDeleteCall<'a, C>
862where
863    C: 'a,
864{
865    hub: &'a TasksHub<C>,
866    _tasklist: String,
867    _delegate: Option<&'a mut dyn common::Delegate>,
868    _additional_params: HashMap<String, String>,
869    _scopes: BTreeSet<String>,
870}
871
872impl<'a, C> common::CallBuilder for TasklistDeleteCall<'a, C> {}
873
874impl<'a, C> TasklistDeleteCall<'a, C>
875where
876    C: common::Connector,
877{
878    /// Perform the operation you have build so far.
879    pub async fn doit(mut self) -> common::Result<common::Response> {
880        use std::borrow::Cow;
881        use std::io::{Read, Seek};
882
883        use common::{url::Params, ToParts};
884        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
885
886        let mut dd = common::DefaultDelegate;
887        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
888        dlg.begin(common::MethodInfo {
889            id: "tasks.tasklists.delete",
890            http_method: hyper::Method::DELETE,
891        });
892
893        for &field in ["tasklist"].iter() {
894            if self._additional_params.contains_key(field) {
895                dlg.finished(false);
896                return Err(common::Error::FieldClash(field));
897            }
898        }
899
900        let mut params = Params::with_capacity(2 + self._additional_params.len());
901        params.push("tasklist", self._tasklist);
902
903        params.extend(self._additional_params.iter());
904
905        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists/{tasklist}";
906        if self._scopes.is_empty() {
907            self._scopes.insert(Scope::Full.as_ref().to_string());
908        }
909
910        #[allow(clippy::single_element_loop)]
911        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
912            url = params.uri_replacement(url, param_name, find_this, false);
913        }
914        {
915            let to_remove = ["tasklist"];
916            params.remove_params(&to_remove);
917        }
918
919        let url = params.parse_with_url(&url);
920
921        loop {
922            let token = match self
923                .hub
924                .auth
925                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
926                .await
927            {
928                Ok(token) => token,
929                Err(e) => match dlg.token(e) {
930                    Ok(token) => token,
931                    Err(e) => {
932                        dlg.finished(false);
933                        return Err(common::Error::MissingToken(e));
934                    }
935                },
936            };
937            let mut req_result = {
938                let client = &self.hub.client;
939                dlg.pre_request();
940                let mut req_builder = hyper::Request::builder()
941                    .method(hyper::Method::DELETE)
942                    .uri(url.as_str())
943                    .header(USER_AGENT, self.hub._user_agent.clone());
944
945                if let Some(token) = token.as_ref() {
946                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
947                }
948
949                let request = req_builder
950                    .header(CONTENT_LENGTH, 0_u64)
951                    .body(common::to_body::<String>(None));
952
953                client.request(request.unwrap()).await
954            };
955
956            match req_result {
957                Err(err) => {
958                    if let common::Retry::After(d) = dlg.http_error(&err) {
959                        sleep(d).await;
960                        continue;
961                    }
962                    dlg.finished(false);
963                    return Err(common::Error::HttpError(err));
964                }
965                Ok(res) => {
966                    let (mut parts, body) = res.into_parts();
967                    let mut body = common::Body::new(body);
968                    if !parts.status.is_success() {
969                        let bytes = common::to_bytes(body).await.unwrap_or_default();
970                        let error = serde_json::from_str(&common::to_string(&bytes));
971                        let response = common::to_response(parts, bytes.into());
972
973                        if let common::Retry::After(d) =
974                            dlg.http_failure(&response, error.as_ref().ok())
975                        {
976                            sleep(d).await;
977                            continue;
978                        }
979
980                        dlg.finished(false);
981
982                        return Err(match error {
983                            Ok(value) => common::Error::BadRequest(value),
984                            _ => common::Error::Failure(response),
985                        });
986                    }
987                    let response = common::Response::from_parts(parts, body);
988
989                    dlg.finished(true);
990                    return Ok(response);
991                }
992            }
993        }
994    }
995
996    /// Task list identifier.
997    ///
998    /// Sets the *tasklist* path property to the given value.
999    ///
1000    /// Even though the property as already been set when instantiating this call,
1001    /// we provide this method for API completeness.
1002    pub fn tasklist(mut self, new_value: &str) -> TasklistDeleteCall<'a, C> {
1003        self._tasklist = new_value.to_string();
1004        self
1005    }
1006    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1007    /// while executing the actual API request.
1008    ///
1009    /// ````text
1010    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1011    /// ````
1012    ///
1013    /// Sets the *delegate* property to the given value.
1014    pub fn delegate(
1015        mut self,
1016        new_value: &'a mut dyn common::Delegate,
1017    ) -> TasklistDeleteCall<'a, C> {
1018        self._delegate = Some(new_value);
1019        self
1020    }
1021
1022    /// Set any additional parameter of the query string used in the request.
1023    /// It should be used to set parameters which are not yet available through their own
1024    /// setters.
1025    ///
1026    /// Please note that this method must not be used to set any of the known parameters
1027    /// which have their own setter method. If done anyway, the request will fail.
1028    ///
1029    /// # Additional Parameters
1030    ///
1031    /// * *$.xgafv* (query-string) - V1 error format.
1032    /// * *access_token* (query-string) - OAuth access token.
1033    /// * *alt* (query-string) - Data format for response.
1034    /// * *callback* (query-string) - JSONP
1035    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1036    /// * *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.
1037    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1038    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1039    /// * *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.
1040    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1041    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1042    pub fn param<T>(mut self, name: T, value: T) -> TasklistDeleteCall<'a, C>
1043    where
1044        T: AsRef<str>,
1045    {
1046        self._additional_params
1047            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1048        self
1049    }
1050
1051    /// Identifies the authorization scope for the method you are building.
1052    ///
1053    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1054    /// [`Scope::Full`].
1055    ///
1056    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1057    /// tokens for more than one scope.
1058    ///
1059    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1060    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1061    /// sufficient, a read-write scope will do as well.
1062    pub fn add_scope<St>(mut self, scope: St) -> TasklistDeleteCall<'a, C>
1063    where
1064        St: AsRef<str>,
1065    {
1066        self._scopes.insert(String::from(scope.as_ref()));
1067        self
1068    }
1069    /// Identifies the authorization scope(s) for the method you are building.
1070    ///
1071    /// See [`Self::add_scope()`] for details.
1072    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistDeleteCall<'a, C>
1073    where
1074        I: IntoIterator<Item = St>,
1075        St: AsRef<str>,
1076    {
1077        self._scopes
1078            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1079        self
1080    }
1081
1082    /// Removes all scopes, and no default scope will be used either.
1083    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1084    /// for details).
1085    pub fn clear_scopes(mut self) -> TasklistDeleteCall<'a, C> {
1086        self._scopes.clear();
1087        self
1088    }
1089}
1090
1091/// Returns the authenticated user's specified task list.
1092///
1093/// A builder for the *get* method supported by a *tasklist* resource.
1094/// It is not used directly, but through a [`TasklistMethods`] instance.
1095///
1096/// # Example
1097///
1098/// Instantiate a resource method builder
1099///
1100/// ```test_harness,no_run
1101/// # extern crate hyper;
1102/// # extern crate hyper_rustls;
1103/// # extern crate google_tasks1 as tasks1;
1104/// # async fn dox() {
1105/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1106///
1107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1108/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1109/// #     .with_native_roots()
1110/// #     .unwrap()
1111/// #     .https_only()
1112/// #     .enable_http2()
1113/// #     .build();
1114///
1115/// # let executor = hyper_util::rt::TokioExecutor::new();
1116/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1117/// #     secret,
1118/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1119/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1120/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1121/// #     ),
1122/// # ).build().await.unwrap();
1123///
1124/// # let client = hyper_util::client::legacy::Client::builder(
1125/// #     hyper_util::rt::TokioExecutor::new()
1126/// # )
1127/// # .build(
1128/// #     hyper_rustls::HttpsConnectorBuilder::new()
1129/// #         .with_native_roots()
1130/// #         .unwrap()
1131/// #         .https_or_http()
1132/// #         .enable_http2()
1133/// #         .build()
1134/// # );
1135/// # let mut hub = TasksHub::new(client, auth);
1136/// // You can configure optional parameters by calling the respective setters at will, and
1137/// // execute the final call using `doit()`.
1138/// // Values shown here are possibly random and not representative !
1139/// let result = hub.tasklists().get("tasklist")
1140///              .doit().await;
1141/// # }
1142/// ```
1143pub struct TasklistGetCall<'a, C>
1144where
1145    C: 'a,
1146{
1147    hub: &'a TasksHub<C>,
1148    _tasklist: String,
1149    _delegate: Option<&'a mut dyn common::Delegate>,
1150    _additional_params: HashMap<String, String>,
1151    _scopes: BTreeSet<String>,
1152}
1153
1154impl<'a, C> common::CallBuilder for TasklistGetCall<'a, C> {}
1155
1156impl<'a, C> TasklistGetCall<'a, C>
1157where
1158    C: common::Connector,
1159{
1160    /// Perform the operation you have build so far.
1161    pub async fn doit(mut self) -> common::Result<(common::Response, TaskList)> {
1162        use std::borrow::Cow;
1163        use std::io::{Read, Seek};
1164
1165        use common::{url::Params, ToParts};
1166        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1167
1168        let mut dd = common::DefaultDelegate;
1169        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1170        dlg.begin(common::MethodInfo {
1171            id: "tasks.tasklists.get",
1172            http_method: hyper::Method::GET,
1173        });
1174
1175        for &field in ["alt", "tasklist"].iter() {
1176            if self._additional_params.contains_key(field) {
1177                dlg.finished(false);
1178                return Err(common::Error::FieldClash(field));
1179            }
1180        }
1181
1182        let mut params = Params::with_capacity(3 + self._additional_params.len());
1183        params.push("tasklist", self._tasklist);
1184
1185        params.extend(self._additional_params.iter());
1186
1187        params.push("alt", "json");
1188        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists/{tasklist}";
1189        if self._scopes.is_empty() {
1190            self._scopes.insert(Scope::Readonly.as_ref().to_string());
1191        }
1192
1193        #[allow(clippy::single_element_loop)]
1194        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
1195            url = params.uri_replacement(url, param_name, find_this, false);
1196        }
1197        {
1198            let to_remove = ["tasklist"];
1199            params.remove_params(&to_remove);
1200        }
1201
1202        let url = params.parse_with_url(&url);
1203
1204        loop {
1205            let token = match self
1206                .hub
1207                .auth
1208                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1209                .await
1210            {
1211                Ok(token) => token,
1212                Err(e) => match dlg.token(e) {
1213                    Ok(token) => token,
1214                    Err(e) => {
1215                        dlg.finished(false);
1216                        return Err(common::Error::MissingToken(e));
1217                    }
1218                },
1219            };
1220            let mut req_result = {
1221                let client = &self.hub.client;
1222                dlg.pre_request();
1223                let mut req_builder = hyper::Request::builder()
1224                    .method(hyper::Method::GET)
1225                    .uri(url.as_str())
1226                    .header(USER_AGENT, self.hub._user_agent.clone());
1227
1228                if let Some(token) = token.as_ref() {
1229                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1230                }
1231
1232                let request = req_builder
1233                    .header(CONTENT_LENGTH, 0_u64)
1234                    .body(common::to_body::<String>(None));
1235
1236                client.request(request.unwrap()).await
1237            };
1238
1239            match req_result {
1240                Err(err) => {
1241                    if let common::Retry::After(d) = dlg.http_error(&err) {
1242                        sleep(d).await;
1243                        continue;
1244                    }
1245                    dlg.finished(false);
1246                    return Err(common::Error::HttpError(err));
1247                }
1248                Ok(res) => {
1249                    let (mut parts, body) = res.into_parts();
1250                    let mut body = common::Body::new(body);
1251                    if !parts.status.is_success() {
1252                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1253                        let error = serde_json::from_str(&common::to_string(&bytes));
1254                        let response = common::to_response(parts, bytes.into());
1255
1256                        if let common::Retry::After(d) =
1257                            dlg.http_failure(&response, error.as_ref().ok())
1258                        {
1259                            sleep(d).await;
1260                            continue;
1261                        }
1262
1263                        dlg.finished(false);
1264
1265                        return Err(match error {
1266                            Ok(value) => common::Error::BadRequest(value),
1267                            _ => common::Error::Failure(response),
1268                        });
1269                    }
1270                    let response = {
1271                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1272                        let encoded = common::to_string(&bytes);
1273                        match serde_json::from_str(&encoded) {
1274                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1275                            Err(error) => {
1276                                dlg.response_json_decode_error(&encoded, &error);
1277                                return Err(common::Error::JsonDecodeError(
1278                                    encoded.to_string(),
1279                                    error,
1280                                ));
1281                            }
1282                        }
1283                    };
1284
1285                    dlg.finished(true);
1286                    return Ok(response);
1287                }
1288            }
1289        }
1290    }
1291
1292    /// Task list identifier.
1293    ///
1294    /// Sets the *tasklist* path property to the given value.
1295    ///
1296    /// Even though the property as already been set when instantiating this call,
1297    /// we provide this method for API completeness.
1298    pub fn tasklist(mut self, new_value: &str) -> TasklistGetCall<'a, C> {
1299        self._tasklist = new_value.to_string();
1300        self
1301    }
1302    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1303    /// while executing the actual API request.
1304    ///
1305    /// ````text
1306    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1307    /// ````
1308    ///
1309    /// Sets the *delegate* property to the given value.
1310    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TasklistGetCall<'a, C> {
1311        self._delegate = Some(new_value);
1312        self
1313    }
1314
1315    /// Set any additional parameter of the query string used in the request.
1316    /// It should be used to set parameters which are not yet available through their own
1317    /// setters.
1318    ///
1319    /// Please note that this method must not be used to set any of the known parameters
1320    /// which have their own setter method. If done anyway, the request will fail.
1321    ///
1322    /// # Additional Parameters
1323    ///
1324    /// * *$.xgafv* (query-string) - V1 error format.
1325    /// * *access_token* (query-string) - OAuth access token.
1326    /// * *alt* (query-string) - Data format for response.
1327    /// * *callback* (query-string) - JSONP
1328    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1329    /// * *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.
1330    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1331    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1332    /// * *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.
1333    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1334    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1335    pub fn param<T>(mut self, name: T, value: T) -> TasklistGetCall<'a, C>
1336    where
1337        T: AsRef<str>,
1338    {
1339        self._additional_params
1340            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1341        self
1342    }
1343
1344    /// Identifies the authorization scope for the method you are building.
1345    ///
1346    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1347    /// [`Scope::Readonly`].
1348    ///
1349    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1350    /// tokens for more than one scope.
1351    ///
1352    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1353    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1354    /// sufficient, a read-write scope will do as well.
1355    pub fn add_scope<St>(mut self, scope: St) -> TasklistGetCall<'a, C>
1356    where
1357        St: AsRef<str>,
1358    {
1359        self._scopes.insert(String::from(scope.as_ref()));
1360        self
1361    }
1362    /// Identifies the authorization scope(s) for the method you are building.
1363    ///
1364    /// See [`Self::add_scope()`] for details.
1365    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistGetCall<'a, C>
1366    where
1367        I: IntoIterator<Item = St>,
1368        St: AsRef<str>,
1369    {
1370        self._scopes
1371            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1372        self
1373    }
1374
1375    /// Removes all scopes, and no default scope will be used either.
1376    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1377    /// for details).
1378    pub fn clear_scopes(mut self) -> TasklistGetCall<'a, C> {
1379        self._scopes.clear();
1380        self
1381    }
1382}
1383
1384/// Creates a new task list and adds it to the authenticated user's task lists. A user can have up to 2000 lists at a time.
1385///
1386/// A builder for the *insert* method supported by a *tasklist* resource.
1387/// It is not used directly, but through a [`TasklistMethods`] instance.
1388///
1389/// # Example
1390///
1391/// Instantiate a resource method builder
1392///
1393/// ```test_harness,no_run
1394/// # extern crate hyper;
1395/// # extern crate hyper_rustls;
1396/// # extern crate google_tasks1 as tasks1;
1397/// use tasks1::api::TaskList;
1398/// # async fn dox() {
1399/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1400///
1401/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1402/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1403/// #     .with_native_roots()
1404/// #     .unwrap()
1405/// #     .https_only()
1406/// #     .enable_http2()
1407/// #     .build();
1408///
1409/// # let executor = hyper_util::rt::TokioExecutor::new();
1410/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1411/// #     secret,
1412/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1413/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1414/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1415/// #     ),
1416/// # ).build().await.unwrap();
1417///
1418/// # let client = hyper_util::client::legacy::Client::builder(
1419/// #     hyper_util::rt::TokioExecutor::new()
1420/// # )
1421/// # .build(
1422/// #     hyper_rustls::HttpsConnectorBuilder::new()
1423/// #         .with_native_roots()
1424/// #         .unwrap()
1425/// #         .https_or_http()
1426/// #         .enable_http2()
1427/// #         .build()
1428/// # );
1429/// # let mut hub = TasksHub::new(client, auth);
1430/// // As the method needs a request, you would usually fill it with the desired information
1431/// // into the respective structure. Some of the parts shown here might not be applicable !
1432/// // Values shown here are possibly random and not representative !
1433/// let mut req = TaskList::default();
1434///
1435/// // You can configure optional parameters by calling the respective setters at will, and
1436/// // execute the final call using `doit()`.
1437/// // Values shown here are possibly random and not representative !
1438/// let result = hub.tasklists().insert(req)
1439///              .doit().await;
1440/// # }
1441/// ```
1442pub struct TasklistInsertCall<'a, C>
1443where
1444    C: 'a,
1445{
1446    hub: &'a TasksHub<C>,
1447    _request: TaskList,
1448    _delegate: Option<&'a mut dyn common::Delegate>,
1449    _additional_params: HashMap<String, String>,
1450    _scopes: BTreeSet<String>,
1451}
1452
1453impl<'a, C> common::CallBuilder for TasklistInsertCall<'a, C> {}
1454
1455impl<'a, C> TasklistInsertCall<'a, C>
1456where
1457    C: common::Connector,
1458{
1459    /// Perform the operation you have build so far.
1460    pub async fn doit(mut self) -> common::Result<(common::Response, TaskList)> {
1461        use std::borrow::Cow;
1462        use std::io::{Read, Seek};
1463
1464        use common::{url::Params, ToParts};
1465        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1466
1467        let mut dd = common::DefaultDelegate;
1468        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1469        dlg.begin(common::MethodInfo {
1470            id: "tasks.tasklists.insert",
1471            http_method: hyper::Method::POST,
1472        });
1473
1474        for &field in ["alt"].iter() {
1475            if self._additional_params.contains_key(field) {
1476                dlg.finished(false);
1477                return Err(common::Error::FieldClash(field));
1478            }
1479        }
1480
1481        let mut params = Params::with_capacity(3 + self._additional_params.len());
1482
1483        params.extend(self._additional_params.iter());
1484
1485        params.push("alt", "json");
1486        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists";
1487        if self._scopes.is_empty() {
1488            self._scopes.insert(Scope::Full.as_ref().to_string());
1489        }
1490
1491        let url = params.parse_with_url(&url);
1492
1493        let mut json_mime_type = mime::APPLICATION_JSON;
1494        let mut request_value_reader = {
1495            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1496            common::remove_json_null_values(&mut value);
1497            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1498            serde_json::to_writer(&mut dst, &value).unwrap();
1499            dst
1500        };
1501        let request_size = request_value_reader
1502            .seek(std::io::SeekFrom::End(0))
1503            .unwrap();
1504        request_value_reader
1505            .seek(std::io::SeekFrom::Start(0))
1506            .unwrap();
1507
1508        loop {
1509            let token = match self
1510                .hub
1511                .auth
1512                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1513                .await
1514            {
1515                Ok(token) => token,
1516                Err(e) => match dlg.token(e) {
1517                    Ok(token) => token,
1518                    Err(e) => {
1519                        dlg.finished(false);
1520                        return Err(common::Error::MissingToken(e));
1521                    }
1522                },
1523            };
1524            request_value_reader
1525                .seek(std::io::SeekFrom::Start(0))
1526                .unwrap();
1527            let mut req_result = {
1528                let client = &self.hub.client;
1529                dlg.pre_request();
1530                let mut req_builder = hyper::Request::builder()
1531                    .method(hyper::Method::POST)
1532                    .uri(url.as_str())
1533                    .header(USER_AGENT, self.hub._user_agent.clone());
1534
1535                if let Some(token) = token.as_ref() {
1536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1537                }
1538
1539                let request = req_builder
1540                    .header(CONTENT_TYPE, json_mime_type.to_string())
1541                    .header(CONTENT_LENGTH, request_size as u64)
1542                    .body(common::to_body(
1543                        request_value_reader.get_ref().clone().into(),
1544                    ));
1545
1546                client.request(request.unwrap()).await
1547            };
1548
1549            match req_result {
1550                Err(err) => {
1551                    if let common::Retry::After(d) = dlg.http_error(&err) {
1552                        sleep(d).await;
1553                        continue;
1554                    }
1555                    dlg.finished(false);
1556                    return Err(common::Error::HttpError(err));
1557                }
1558                Ok(res) => {
1559                    let (mut parts, body) = res.into_parts();
1560                    let mut body = common::Body::new(body);
1561                    if !parts.status.is_success() {
1562                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1563                        let error = serde_json::from_str(&common::to_string(&bytes));
1564                        let response = common::to_response(parts, bytes.into());
1565
1566                        if let common::Retry::After(d) =
1567                            dlg.http_failure(&response, error.as_ref().ok())
1568                        {
1569                            sleep(d).await;
1570                            continue;
1571                        }
1572
1573                        dlg.finished(false);
1574
1575                        return Err(match error {
1576                            Ok(value) => common::Error::BadRequest(value),
1577                            _ => common::Error::Failure(response),
1578                        });
1579                    }
1580                    let response = {
1581                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1582                        let encoded = common::to_string(&bytes);
1583                        match serde_json::from_str(&encoded) {
1584                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1585                            Err(error) => {
1586                                dlg.response_json_decode_error(&encoded, &error);
1587                                return Err(common::Error::JsonDecodeError(
1588                                    encoded.to_string(),
1589                                    error,
1590                                ));
1591                            }
1592                        }
1593                    };
1594
1595                    dlg.finished(true);
1596                    return Ok(response);
1597                }
1598            }
1599        }
1600    }
1601
1602    ///
1603    /// Sets the *request* property to the given value.
1604    ///
1605    /// Even though the property as already been set when instantiating this call,
1606    /// we provide this method for API completeness.
1607    pub fn request(mut self, new_value: TaskList) -> TasklistInsertCall<'a, C> {
1608        self._request = new_value;
1609        self
1610    }
1611    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1612    /// while executing the actual API request.
1613    ///
1614    /// ````text
1615    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1616    /// ````
1617    ///
1618    /// Sets the *delegate* property to the given value.
1619    pub fn delegate(
1620        mut self,
1621        new_value: &'a mut dyn common::Delegate,
1622    ) -> TasklistInsertCall<'a, C> {
1623        self._delegate = Some(new_value);
1624        self
1625    }
1626
1627    /// Set any additional parameter of the query string used in the request.
1628    /// It should be used to set parameters which are not yet available through their own
1629    /// setters.
1630    ///
1631    /// Please note that this method must not be used to set any of the known parameters
1632    /// which have their own setter method. If done anyway, the request will fail.
1633    ///
1634    /// # Additional Parameters
1635    ///
1636    /// * *$.xgafv* (query-string) - V1 error format.
1637    /// * *access_token* (query-string) - OAuth access token.
1638    /// * *alt* (query-string) - Data format for response.
1639    /// * *callback* (query-string) - JSONP
1640    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1641    /// * *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.
1642    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1643    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1644    /// * *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.
1645    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1646    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1647    pub fn param<T>(mut self, name: T, value: T) -> TasklistInsertCall<'a, C>
1648    where
1649        T: AsRef<str>,
1650    {
1651        self._additional_params
1652            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1653        self
1654    }
1655
1656    /// Identifies the authorization scope for the method you are building.
1657    ///
1658    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1659    /// [`Scope::Full`].
1660    ///
1661    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1662    /// tokens for more than one scope.
1663    ///
1664    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1665    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1666    /// sufficient, a read-write scope will do as well.
1667    pub fn add_scope<St>(mut self, scope: St) -> TasklistInsertCall<'a, C>
1668    where
1669        St: AsRef<str>,
1670    {
1671        self._scopes.insert(String::from(scope.as_ref()));
1672        self
1673    }
1674    /// Identifies the authorization scope(s) for the method you are building.
1675    ///
1676    /// See [`Self::add_scope()`] for details.
1677    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistInsertCall<'a, C>
1678    where
1679        I: IntoIterator<Item = St>,
1680        St: AsRef<str>,
1681    {
1682        self._scopes
1683            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1684        self
1685    }
1686
1687    /// Removes all scopes, and no default scope will be used either.
1688    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1689    /// for details).
1690    pub fn clear_scopes(mut self) -> TasklistInsertCall<'a, C> {
1691        self._scopes.clear();
1692        self
1693    }
1694}
1695
1696/// Returns all the authenticated user's task lists. A user can have up to 2000 lists at a time.
1697///
1698/// A builder for the *list* method supported by a *tasklist* resource.
1699/// It is not used directly, but through a [`TasklistMethods`] instance.
1700///
1701/// # Example
1702///
1703/// Instantiate a resource method builder
1704///
1705/// ```test_harness,no_run
1706/// # extern crate hyper;
1707/// # extern crate hyper_rustls;
1708/// # extern crate google_tasks1 as tasks1;
1709/// # async fn dox() {
1710/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1711///
1712/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1713/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1714/// #     .with_native_roots()
1715/// #     .unwrap()
1716/// #     .https_only()
1717/// #     .enable_http2()
1718/// #     .build();
1719///
1720/// # let executor = hyper_util::rt::TokioExecutor::new();
1721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1722/// #     secret,
1723/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1724/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1725/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1726/// #     ),
1727/// # ).build().await.unwrap();
1728///
1729/// # let client = hyper_util::client::legacy::Client::builder(
1730/// #     hyper_util::rt::TokioExecutor::new()
1731/// # )
1732/// # .build(
1733/// #     hyper_rustls::HttpsConnectorBuilder::new()
1734/// #         .with_native_roots()
1735/// #         .unwrap()
1736/// #         .https_or_http()
1737/// #         .enable_http2()
1738/// #         .build()
1739/// # );
1740/// # let mut hub = TasksHub::new(client, auth);
1741/// // You can configure optional parameters by calling the respective setters at will, and
1742/// // execute the final call using `doit()`.
1743/// // Values shown here are possibly random and not representative !
1744/// let result = hub.tasklists().list()
1745///              .page_token("et")
1746///              .max_results(-68)
1747///              .doit().await;
1748/// # }
1749/// ```
1750pub struct TasklistListCall<'a, C>
1751where
1752    C: 'a,
1753{
1754    hub: &'a TasksHub<C>,
1755    _page_token: Option<String>,
1756    _max_results: Option<i32>,
1757    _delegate: Option<&'a mut dyn common::Delegate>,
1758    _additional_params: HashMap<String, String>,
1759    _scopes: BTreeSet<String>,
1760}
1761
1762impl<'a, C> common::CallBuilder for TasklistListCall<'a, C> {}
1763
1764impl<'a, C> TasklistListCall<'a, C>
1765where
1766    C: common::Connector,
1767{
1768    /// Perform the operation you have build so far.
1769    pub async fn doit(mut self) -> common::Result<(common::Response, TaskLists)> {
1770        use std::borrow::Cow;
1771        use std::io::{Read, Seek};
1772
1773        use common::{url::Params, ToParts};
1774        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1775
1776        let mut dd = common::DefaultDelegate;
1777        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1778        dlg.begin(common::MethodInfo {
1779            id: "tasks.tasklists.list",
1780            http_method: hyper::Method::GET,
1781        });
1782
1783        for &field in ["alt", "pageToken", "maxResults"].iter() {
1784            if self._additional_params.contains_key(field) {
1785                dlg.finished(false);
1786                return Err(common::Error::FieldClash(field));
1787            }
1788        }
1789
1790        let mut params = Params::with_capacity(4 + self._additional_params.len());
1791        if let Some(value) = self._page_token.as_ref() {
1792            params.push("pageToken", value);
1793        }
1794        if let Some(value) = self._max_results.as_ref() {
1795            params.push("maxResults", value.to_string());
1796        }
1797
1798        params.extend(self._additional_params.iter());
1799
1800        params.push("alt", "json");
1801        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists";
1802        if self._scopes.is_empty() {
1803            self._scopes.insert(Scope::Readonly.as_ref().to_string());
1804        }
1805
1806        let url = params.parse_with_url(&url);
1807
1808        loop {
1809            let token = match self
1810                .hub
1811                .auth
1812                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1813                .await
1814            {
1815                Ok(token) => token,
1816                Err(e) => match dlg.token(e) {
1817                    Ok(token) => token,
1818                    Err(e) => {
1819                        dlg.finished(false);
1820                        return Err(common::Error::MissingToken(e));
1821                    }
1822                },
1823            };
1824            let mut req_result = {
1825                let client = &self.hub.client;
1826                dlg.pre_request();
1827                let mut req_builder = hyper::Request::builder()
1828                    .method(hyper::Method::GET)
1829                    .uri(url.as_str())
1830                    .header(USER_AGENT, self.hub._user_agent.clone());
1831
1832                if let Some(token) = token.as_ref() {
1833                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1834                }
1835
1836                let request = req_builder
1837                    .header(CONTENT_LENGTH, 0_u64)
1838                    .body(common::to_body::<String>(None));
1839
1840                client.request(request.unwrap()).await
1841            };
1842
1843            match req_result {
1844                Err(err) => {
1845                    if let common::Retry::After(d) = dlg.http_error(&err) {
1846                        sleep(d).await;
1847                        continue;
1848                    }
1849                    dlg.finished(false);
1850                    return Err(common::Error::HttpError(err));
1851                }
1852                Ok(res) => {
1853                    let (mut parts, body) = res.into_parts();
1854                    let mut body = common::Body::new(body);
1855                    if !parts.status.is_success() {
1856                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1857                        let error = serde_json::from_str(&common::to_string(&bytes));
1858                        let response = common::to_response(parts, bytes.into());
1859
1860                        if let common::Retry::After(d) =
1861                            dlg.http_failure(&response, error.as_ref().ok())
1862                        {
1863                            sleep(d).await;
1864                            continue;
1865                        }
1866
1867                        dlg.finished(false);
1868
1869                        return Err(match error {
1870                            Ok(value) => common::Error::BadRequest(value),
1871                            _ => common::Error::Failure(response),
1872                        });
1873                    }
1874                    let response = {
1875                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1876                        let encoded = common::to_string(&bytes);
1877                        match serde_json::from_str(&encoded) {
1878                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1879                            Err(error) => {
1880                                dlg.response_json_decode_error(&encoded, &error);
1881                                return Err(common::Error::JsonDecodeError(
1882                                    encoded.to_string(),
1883                                    error,
1884                                ));
1885                            }
1886                        }
1887                    };
1888
1889                    dlg.finished(true);
1890                    return Ok(response);
1891                }
1892            }
1893        }
1894    }
1895
1896    /// Token specifying the result page to return. Optional.
1897    ///
1898    /// Sets the *page token* query property to the given value.
1899    pub fn page_token(mut self, new_value: &str) -> TasklistListCall<'a, C> {
1900        self._page_token = Some(new_value.to_string());
1901        self
1902    }
1903    /// Maximum number of task lists returned on one page. Optional. The default is 1000 (max allowed: 1000).
1904    ///
1905    /// Sets the *max results* query property to the given value.
1906    pub fn max_results(mut self, new_value: i32) -> TasklistListCall<'a, C> {
1907        self._max_results = Some(new_value);
1908        self
1909    }
1910    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1911    /// while executing the actual API request.
1912    ///
1913    /// ````text
1914    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1915    /// ````
1916    ///
1917    /// Sets the *delegate* property to the given value.
1918    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TasklistListCall<'a, C> {
1919        self._delegate = Some(new_value);
1920        self
1921    }
1922
1923    /// Set any additional parameter of the query string used in the request.
1924    /// It should be used to set parameters which are not yet available through their own
1925    /// setters.
1926    ///
1927    /// Please note that this method must not be used to set any of the known parameters
1928    /// which have their own setter method. If done anyway, the request will fail.
1929    ///
1930    /// # Additional Parameters
1931    ///
1932    /// * *$.xgafv* (query-string) - V1 error format.
1933    /// * *access_token* (query-string) - OAuth access token.
1934    /// * *alt* (query-string) - Data format for response.
1935    /// * *callback* (query-string) - JSONP
1936    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1937    /// * *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.
1938    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1939    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1940    /// * *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.
1941    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1942    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1943    pub fn param<T>(mut self, name: T, value: T) -> TasklistListCall<'a, C>
1944    where
1945        T: AsRef<str>,
1946    {
1947        self._additional_params
1948            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1949        self
1950    }
1951
1952    /// Identifies the authorization scope for the method you are building.
1953    ///
1954    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1955    /// [`Scope::Readonly`].
1956    ///
1957    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1958    /// tokens for more than one scope.
1959    ///
1960    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1961    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1962    /// sufficient, a read-write scope will do as well.
1963    pub fn add_scope<St>(mut self, scope: St) -> TasklistListCall<'a, C>
1964    where
1965        St: AsRef<str>,
1966    {
1967        self._scopes.insert(String::from(scope.as_ref()));
1968        self
1969    }
1970    /// Identifies the authorization scope(s) for the method you are building.
1971    ///
1972    /// See [`Self::add_scope()`] for details.
1973    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistListCall<'a, C>
1974    where
1975        I: IntoIterator<Item = St>,
1976        St: AsRef<str>,
1977    {
1978        self._scopes
1979            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1980        self
1981    }
1982
1983    /// Removes all scopes, and no default scope will be used either.
1984    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1985    /// for details).
1986    pub fn clear_scopes(mut self) -> TasklistListCall<'a, C> {
1987        self._scopes.clear();
1988        self
1989    }
1990}
1991
1992/// Updates the authenticated user's specified task list. This method supports patch semantics.
1993///
1994/// A builder for the *patch* method supported by a *tasklist* resource.
1995/// It is not used directly, but through a [`TasklistMethods`] instance.
1996///
1997/// # Example
1998///
1999/// Instantiate a resource method builder
2000///
2001/// ```test_harness,no_run
2002/// # extern crate hyper;
2003/// # extern crate hyper_rustls;
2004/// # extern crate google_tasks1 as tasks1;
2005/// use tasks1::api::TaskList;
2006/// # async fn dox() {
2007/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2008///
2009/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2010/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2011/// #     .with_native_roots()
2012/// #     .unwrap()
2013/// #     .https_only()
2014/// #     .enable_http2()
2015/// #     .build();
2016///
2017/// # let executor = hyper_util::rt::TokioExecutor::new();
2018/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2019/// #     secret,
2020/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2021/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2022/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2023/// #     ),
2024/// # ).build().await.unwrap();
2025///
2026/// # let client = hyper_util::client::legacy::Client::builder(
2027/// #     hyper_util::rt::TokioExecutor::new()
2028/// # )
2029/// # .build(
2030/// #     hyper_rustls::HttpsConnectorBuilder::new()
2031/// #         .with_native_roots()
2032/// #         .unwrap()
2033/// #         .https_or_http()
2034/// #         .enable_http2()
2035/// #         .build()
2036/// # );
2037/// # let mut hub = TasksHub::new(client, auth);
2038/// // As the method needs a request, you would usually fill it with the desired information
2039/// // into the respective structure. Some of the parts shown here might not be applicable !
2040/// // Values shown here are possibly random and not representative !
2041/// let mut req = TaskList::default();
2042///
2043/// // You can configure optional parameters by calling the respective setters at will, and
2044/// // execute the final call using `doit()`.
2045/// // Values shown here are possibly random and not representative !
2046/// let result = hub.tasklists().patch(req, "tasklist")
2047///              .doit().await;
2048/// # }
2049/// ```
2050pub struct TasklistPatchCall<'a, C>
2051where
2052    C: 'a,
2053{
2054    hub: &'a TasksHub<C>,
2055    _request: TaskList,
2056    _tasklist: String,
2057    _delegate: Option<&'a mut dyn common::Delegate>,
2058    _additional_params: HashMap<String, String>,
2059    _scopes: BTreeSet<String>,
2060}
2061
2062impl<'a, C> common::CallBuilder for TasklistPatchCall<'a, C> {}
2063
2064impl<'a, C> TasklistPatchCall<'a, C>
2065where
2066    C: common::Connector,
2067{
2068    /// Perform the operation you have build so far.
2069    pub async fn doit(mut self) -> common::Result<(common::Response, TaskList)> {
2070        use std::borrow::Cow;
2071        use std::io::{Read, Seek};
2072
2073        use common::{url::Params, ToParts};
2074        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2075
2076        let mut dd = common::DefaultDelegate;
2077        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2078        dlg.begin(common::MethodInfo {
2079            id: "tasks.tasklists.patch",
2080            http_method: hyper::Method::PATCH,
2081        });
2082
2083        for &field in ["alt", "tasklist"].iter() {
2084            if self._additional_params.contains_key(field) {
2085                dlg.finished(false);
2086                return Err(common::Error::FieldClash(field));
2087            }
2088        }
2089
2090        let mut params = Params::with_capacity(4 + self._additional_params.len());
2091        params.push("tasklist", self._tasklist);
2092
2093        params.extend(self._additional_params.iter());
2094
2095        params.push("alt", "json");
2096        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists/{tasklist}";
2097        if self._scopes.is_empty() {
2098            self._scopes.insert(Scope::Full.as_ref().to_string());
2099        }
2100
2101        #[allow(clippy::single_element_loop)]
2102        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
2103            url = params.uri_replacement(url, param_name, find_this, false);
2104        }
2105        {
2106            let to_remove = ["tasklist"];
2107            params.remove_params(&to_remove);
2108        }
2109
2110        let url = params.parse_with_url(&url);
2111
2112        let mut json_mime_type = mime::APPLICATION_JSON;
2113        let mut request_value_reader = {
2114            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2115            common::remove_json_null_values(&mut value);
2116            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2117            serde_json::to_writer(&mut dst, &value).unwrap();
2118            dst
2119        };
2120        let request_size = request_value_reader
2121            .seek(std::io::SeekFrom::End(0))
2122            .unwrap();
2123        request_value_reader
2124            .seek(std::io::SeekFrom::Start(0))
2125            .unwrap();
2126
2127        loop {
2128            let token = match self
2129                .hub
2130                .auth
2131                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2132                .await
2133            {
2134                Ok(token) => token,
2135                Err(e) => match dlg.token(e) {
2136                    Ok(token) => token,
2137                    Err(e) => {
2138                        dlg.finished(false);
2139                        return Err(common::Error::MissingToken(e));
2140                    }
2141                },
2142            };
2143            request_value_reader
2144                .seek(std::io::SeekFrom::Start(0))
2145                .unwrap();
2146            let mut req_result = {
2147                let client = &self.hub.client;
2148                dlg.pre_request();
2149                let mut req_builder = hyper::Request::builder()
2150                    .method(hyper::Method::PATCH)
2151                    .uri(url.as_str())
2152                    .header(USER_AGENT, self.hub._user_agent.clone());
2153
2154                if let Some(token) = token.as_ref() {
2155                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2156                }
2157
2158                let request = req_builder
2159                    .header(CONTENT_TYPE, json_mime_type.to_string())
2160                    .header(CONTENT_LENGTH, request_size as u64)
2161                    .body(common::to_body(
2162                        request_value_reader.get_ref().clone().into(),
2163                    ));
2164
2165                client.request(request.unwrap()).await
2166            };
2167
2168            match req_result {
2169                Err(err) => {
2170                    if let common::Retry::After(d) = dlg.http_error(&err) {
2171                        sleep(d).await;
2172                        continue;
2173                    }
2174                    dlg.finished(false);
2175                    return Err(common::Error::HttpError(err));
2176                }
2177                Ok(res) => {
2178                    let (mut parts, body) = res.into_parts();
2179                    let mut body = common::Body::new(body);
2180                    if !parts.status.is_success() {
2181                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2182                        let error = serde_json::from_str(&common::to_string(&bytes));
2183                        let response = common::to_response(parts, bytes.into());
2184
2185                        if let common::Retry::After(d) =
2186                            dlg.http_failure(&response, error.as_ref().ok())
2187                        {
2188                            sleep(d).await;
2189                            continue;
2190                        }
2191
2192                        dlg.finished(false);
2193
2194                        return Err(match error {
2195                            Ok(value) => common::Error::BadRequest(value),
2196                            _ => common::Error::Failure(response),
2197                        });
2198                    }
2199                    let response = {
2200                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2201                        let encoded = common::to_string(&bytes);
2202                        match serde_json::from_str(&encoded) {
2203                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2204                            Err(error) => {
2205                                dlg.response_json_decode_error(&encoded, &error);
2206                                return Err(common::Error::JsonDecodeError(
2207                                    encoded.to_string(),
2208                                    error,
2209                                ));
2210                            }
2211                        }
2212                    };
2213
2214                    dlg.finished(true);
2215                    return Ok(response);
2216                }
2217            }
2218        }
2219    }
2220
2221    ///
2222    /// Sets the *request* property to the given value.
2223    ///
2224    /// Even though the property as already been set when instantiating this call,
2225    /// we provide this method for API completeness.
2226    pub fn request(mut self, new_value: TaskList) -> TasklistPatchCall<'a, C> {
2227        self._request = new_value;
2228        self
2229    }
2230    /// Task list identifier.
2231    ///
2232    /// Sets the *tasklist* path property to the given value.
2233    ///
2234    /// Even though the property as already been set when instantiating this call,
2235    /// we provide this method for API completeness.
2236    pub fn tasklist(mut self, new_value: &str) -> TasklistPatchCall<'a, C> {
2237        self._tasklist = new_value.to_string();
2238        self
2239    }
2240    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2241    /// while executing the actual API request.
2242    ///
2243    /// ````text
2244    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2245    /// ````
2246    ///
2247    /// Sets the *delegate* property to the given value.
2248    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TasklistPatchCall<'a, C> {
2249        self._delegate = Some(new_value);
2250        self
2251    }
2252
2253    /// Set any additional parameter of the query string used in the request.
2254    /// It should be used to set parameters which are not yet available through their own
2255    /// setters.
2256    ///
2257    /// Please note that this method must not be used to set any of the known parameters
2258    /// which have their own setter method. If done anyway, the request will fail.
2259    ///
2260    /// # Additional Parameters
2261    ///
2262    /// * *$.xgafv* (query-string) - V1 error format.
2263    /// * *access_token* (query-string) - OAuth access token.
2264    /// * *alt* (query-string) - Data format for response.
2265    /// * *callback* (query-string) - JSONP
2266    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2267    /// * *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.
2268    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2269    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2270    /// * *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.
2271    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2272    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2273    pub fn param<T>(mut self, name: T, value: T) -> TasklistPatchCall<'a, C>
2274    where
2275        T: AsRef<str>,
2276    {
2277        self._additional_params
2278            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2279        self
2280    }
2281
2282    /// Identifies the authorization scope for the method you are building.
2283    ///
2284    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2285    /// [`Scope::Full`].
2286    ///
2287    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2288    /// tokens for more than one scope.
2289    ///
2290    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2291    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2292    /// sufficient, a read-write scope will do as well.
2293    pub fn add_scope<St>(mut self, scope: St) -> TasklistPatchCall<'a, C>
2294    where
2295        St: AsRef<str>,
2296    {
2297        self._scopes.insert(String::from(scope.as_ref()));
2298        self
2299    }
2300    /// Identifies the authorization scope(s) for the method you are building.
2301    ///
2302    /// See [`Self::add_scope()`] for details.
2303    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistPatchCall<'a, C>
2304    where
2305        I: IntoIterator<Item = St>,
2306        St: AsRef<str>,
2307    {
2308        self._scopes
2309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2310        self
2311    }
2312
2313    /// Removes all scopes, and no default scope will be used either.
2314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2315    /// for details).
2316    pub fn clear_scopes(mut self) -> TasklistPatchCall<'a, C> {
2317        self._scopes.clear();
2318        self
2319    }
2320}
2321
2322/// Updates the authenticated user's specified task list.
2323///
2324/// A builder for the *update* method supported by a *tasklist* resource.
2325/// It is not used directly, but through a [`TasklistMethods`] instance.
2326///
2327/// # Example
2328///
2329/// Instantiate a resource method builder
2330///
2331/// ```test_harness,no_run
2332/// # extern crate hyper;
2333/// # extern crate hyper_rustls;
2334/// # extern crate google_tasks1 as tasks1;
2335/// use tasks1::api::TaskList;
2336/// # async fn dox() {
2337/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2338///
2339/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2340/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2341/// #     .with_native_roots()
2342/// #     .unwrap()
2343/// #     .https_only()
2344/// #     .enable_http2()
2345/// #     .build();
2346///
2347/// # let executor = hyper_util::rt::TokioExecutor::new();
2348/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2349/// #     secret,
2350/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2351/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2352/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2353/// #     ),
2354/// # ).build().await.unwrap();
2355///
2356/// # let client = hyper_util::client::legacy::Client::builder(
2357/// #     hyper_util::rt::TokioExecutor::new()
2358/// # )
2359/// # .build(
2360/// #     hyper_rustls::HttpsConnectorBuilder::new()
2361/// #         .with_native_roots()
2362/// #         .unwrap()
2363/// #         .https_or_http()
2364/// #         .enable_http2()
2365/// #         .build()
2366/// # );
2367/// # let mut hub = TasksHub::new(client, auth);
2368/// // As the method needs a request, you would usually fill it with the desired information
2369/// // into the respective structure. Some of the parts shown here might not be applicable !
2370/// // Values shown here are possibly random and not representative !
2371/// let mut req = TaskList::default();
2372///
2373/// // You can configure optional parameters by calling the respective setters at will, and
2374/// // execute the final call using `doit()`.
2375/// // Values shown here are possibly random and not representative !
2376/// let result = hub.tasklists().update(req, "tasklist")
2377///              .doit().await;
2378/// # }
2379/// ```
2380pub struct TasklistUpdateCall<'a, C>
2381where
2382    C: 'a,
2383{
2384    hub: &'a TasksHub<C>,
2385    _request: TaskList,
2386    _tasklist: String,
2387    _delegate: Option<&'a mut dyn common::Delegate>,
2388    _additional_params: HashMap<String, String>,
2389    _scopes: BTreeSet<String>,
2390}
2391
2392impl<'a, C> common::CallBuilder for TasklistUpdateCall<'a, C> {}
2393
2394impl<'a, C> TasklistUpdateCall<'a, C>
2395where
2396    C: common::Connector,
2397{
2398    /// Perform the operation you have build so far.
2399    pub async fn doit(mut self) -> common::Result<(common::Response, TaskList)> {
2400        use std::borrow::Cow;
2401        use std::io::{Read, Seek};
2402
2403        use common::{url::Params, ToParts};
2404        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2405
2406        let mut dd = common::DefaultDelegate;
2407        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2408        dlg.begin(common::MethodInfo {
2409            id: "tasks.tasklists.update",
2410            http_method: hyper::Method::PUT,
2411        });
2412
2413        for &field in ["alt", "tasklist"].iter() {
2414            if self._additional_params.contains_key(field) {
2415                dlg.finished(false);
2416                return Err(common::Error::FieldClash(field));
2417            }
2418        }
2419
2420        let mut params = Params::with_capacity(4 + self._additional_params.len());
2421        params.push("tasklist", self._tasklist);
2422
2423        params.extend(self._additional_params.iter());
2424
2425        params.push("alt", "json");
2426        let mut url = self.hub._base_url.clone() + "tasks/v1/users/@me/lists/{tasklist}";
2427        if self._scopes.is_empty() {
2428            self._scopes.insert(Scope::Full.as_ref().to_string());
2429        }
2430
2431        #[allow(clippy::single_element_loop)]
2432        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
2433            url = params.uri_replacement(url, param_name, find_this, false);
2434        }
2435        {
2436            let to_remove = ["tasklist"];
2437            params.remove_params(&to_remove);
2438        }
2439
2440        let url = params.parse_with_url(&url);
2441
2442        let mut json_mime_type = mime::APPLICATION_JSON;
2443        let mut request_value_reader = {
2444            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2445            common::remove_json_null_values(&mut value);
2446            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2447            serde_json::to_writer(&mut dst, &value).unwrap();
2448            dst
2449        };
2450        let request_size = request_value_reader
2451            .seek(std::io::SeekFrom::End(0))
2452            .unwrap();
2453        request_value_reader
2454            .seek(std::io::SeekFrom::Start(0))
2455            .unwrap();
2456
2457        loop {
2458            let token = match self
2459                .hub
2460                .auth
2461                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2462                .await
2463            {
2464                Ok(token) => token,
2465                Err(e) => match dlg.token(e) {
2466                    Ok(token) => token,
2467                    Err(e) => {
2468                        dlg.finished(false);
2469                        return Err(common::Error::MissingToken(e));
2470                    }
2471                },
2472            };
2473            request_value_reader
2474                .seek(std::io::SeekFrom::Start(0))
2475                .unwrap();
2476            let mut req_result = {
2477                let client = &self.hub.client;
2478                dlg.pre_request();
2479                let mut req_builder = hyper::Request::builder()
2480                    .method(hyper::Method::PUT)
2481                    .uri(url.as_str())
2482                    .header(USER_AGENT, self.hub._user_agent.clone());
2483
2484                if let Some(token) = token.as_ref() {
2485                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2486                }
2487
2488                let request = req_builder
2489                    .header(CONTENT_TYPE, json_mime_type.to_string())
2490                    .header(CONTENT_LENGTH, request_size as u64)
2491                    .body(common::to_body(
2492                        request_value_reader.get_ref().clone().into(),
2493                    ));
2494
2495                client.request(request.unwrap()).await
2496            };
2497
2498            match req_result {
2499                Err(err) => {
2500                    if let common::Retry::After(d) = dlg.http_error(&err) {
2501                        sleep(d).await;
2502                        continue;
2503                    }
2504                    dlg.finished(false);
2505                    return Err(common::Error::HttpError(err));
2506                }
2507                Ok(res) => {
2508                    let (mut parts, body) = res.into_parts();
2509                    let mut body = common::Body::new(body);
2510                    if !parts.status.is_success() {
2511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2512                        let error = serde_json::from_str(&common::to_string(&bytes));
2513                        let response = common::to_response(parts, bytes.into());
2514
2515                        if let common::Retry::After(d) =
2516                            dlg.http_failure(&response, error.as_ref().ok())
2517                        {
2518                            sleep(d).await;
2519                            continue;
2520                        }
2521
2522                        dlg.finished(false);
2523
2524                        return Err(match error {
2525                            Ok(value) => common::Error::BadRequest(value),
2526                            _ => common::Error::Failure(response),
2527                        });
2528                    }
2529                    let response = {
2530                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2531                        let encoded = common::to_string(&bytes);
2532                        match serde_json::from_str(&encoded) {
2533                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2534                            Err(error) => {
2535                                dlg.response_json_decode_error(&encoded, &error);
2536                                return Err(common::Error::JsonDecodeError(
2537                                    encoded.to_string(),
2538                                    error,
2539                                ));
2540                            }
2541                        }
2542                    };
2543
2544                    dlg.finished(true);
2545                    return Ok(response);
2546                }
2547            }
2548        }
2549    }
2550
2551    ///
2552    /// Sets the *request* property to the given value.
2553    ///
2554    /// Even though the property as already been set when instantiating this call,
2555    /// we provide this method for API completeness.
2556    pub fn request(mut self, new_value: TaskList) -> TasklistUpdateCall<'a, C> {
2557        self._request = new_value;
2558        self
2559    }
2560    /// Task list identifier.
2561    ///
2562    /// Sets the *tasklist* path property to the given value.
2563    ///
2564    /// Even though the property as already been set when instantiating this call,
2565    /// we provide this method for API completeness.
2566    pub fn tasklist(mut self, new_value: &str) -> TasklistUpdateCall<'a, C> {
2567        self._tasklist = new_value.to_string();
2568        self
2569    }
2570    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2571    /// while executing the actual API request.
2572    ///
2573    /// ````text
2574    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2575    /// ````
2576    ///
2577    /// Sets the *delegate* property to the given value.
2578    pub fn delegate(
2579        mut self,
2580        new_value: &'a mut dyn common::Delegate,
2581    ) -> TasklistUpdateCall<'a, C> {
2582        self._delegate = Some(new_value);
2583        self
2584    }
2585
2586    /// Set any additional parameter of the query string used in the request.
2587    /// It should be used to set parameters which are not yet available through their own
2588    /// setters.
2589    ///
2590    /// Please note that this method must not be used to set any of the known parameters
2591    /// which have their own setter method. If done anyway, the request will fail.
2592    ///
2593    /// # Additional Parameters
2594    ///
2595    /// * *$.xgafv* (query-string) - V1 error format.
2596    /// * *access_token* (query-string) - OAuth access token.
2597    /// * *alt* (query-string) - Data format for response.
2598    /// * *callback* (query-string) - JSONP
2599    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2600    /// * *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.
2601    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2602    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2603    /// * *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.
2604    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2605    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2606    pub fn param<T>(mut self, name: T, value: T) -> TasklistUpdateCall<'a, C>
2607    where
2608        T: AsRef<str>,
2609    {
2610        self._additional_params
2611            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2612        self
2613    }
2614
2615    /// Identifies the authorization scope for the method you are building.
2616    ///
2617    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2618    /// [`Scope::Full`].
2619    ///
2620    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2621    /// tokens for more than one scope.
2622    ///
2623    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2624    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2625    /// sufficient, a read-write scope will do as well.
2626    pub fn add_scope<St>(mut self, scope: St) -> TasklistUpdateCall<'a, C>
2627    where
2628        St: AsRef<str>,
2629    {
2630        self._scopes.insert(String::from(scope.as_ref()));
2631        self
2632    }
2633    /// Identifies the authorization scope(s) for the method you are building.
2634    ///
2635    /// See [`Self::add_scope()`] for details.
2636    pub fn add_scopes<I, St>(mut self, scopes: I) -> TasklistUpdateCall<'a, C>
2637    where
2638        I: IntoIterator<Item = St>,
2639        St: AsRef<str>,
2640    {
2641        self._scopes
2642            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2643        self
2644    }
2645
2646    /// Removes all scopes, and no default scope will be used either.
2647    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2648    /// for details).
2649    pub fn clear_scopes(mut self) -> TasklistUpdateCall<'a, C> {
2650        self._scopes.clear();
2651        self
2652    }
2653}
2654
2655/// Clears all completed tasks from the specified task list. The affected tasks will be marked as 'hidden' and no longer be returned by default when retrieving all tasks for a task list.
2656///
2657/// A builder for the *clear* method supported by a *task* resource.
2658/// It is not used directly, but through a [`TaskMethods`] instance.
2659///
2660/// # Example
2661///
2662/// Instantiate a resource method builder
2663///
2664/// ```test_harness,no_run
2665/// # extern crate hyper;
2666/// # extern crate hyper_rustls;
2667/// # extern crate google_tasks1 as tasks1;
2668/// # async fn dox() {
2669/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2670///
2671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2672/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2673/// #     .with_native_roots()
2674/// #     .unwrap()
2675/// #     .https_only()
2676/// #     .enable_http2()
2677/// #     .build();
2678///
2679/// # let executor = hyper_util::rt::TokioExecutor::new();
2680/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2681/// #     secret,
2682/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2683/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2684/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2685/// #     ),
2686/// # ).build().await.unwrap();
2687///
2688/// # let client = hyper_util::client::legacy::Client::builder(
2689/// #     hyper_util::rt::TokioExecutor::new()
2690/// # )
2691/// # .build(
2692/// #     hyper_rustls::HttpsConnectorBuilder::new()
2693/// #         .with_native_roots()
2694/// #         .unwrap()
2695/// #         .https_or_http()
2696/// #         .enable_http2()
2697/// #         .build()
2698/// # );
2699/// # let mut hub = TasksHub::new(client, auth);
2700/// // You can configure optional parameters by calling the respective setters at will, and
2701/// // execute the final call using `doit()`.
2702/// // Values shown here are possibly random and not representative !
2703/// let result = hub.tasks().clear("tasklist")
2704///              .doit().await;
2705/// # }
2706/// ```
2707pub struct TaskClearCall<'a, C>
2708where
2709    C: 'a,
2710{
2711    hub: &'a TasksHub<C>,
2712    _tasklist: String,
2713    _delegate: Option<&'a mut dyn common::Delegate>,
2714    _additional_params: HashMap<String, String>,
2715    _scopes: BTreeSet<String>,
2716}
2717
2718impl<'a, C> common::CallBuilder for TaskClearCall<'a, C> {}
2719
2720impl<'a, C> TaskClearCall<'a, C>
2721where
2722    C: common::Connector,
2723{
2724    /// Perform the operation you have build so far.
2725    pub async fn doit(mut self) -> common::Result<common::Response> {
2726        use std::borrow::Cow;
2727        use std::io::{Read, Seek};
2728
2729        use common::{url::Params, ToParts};
2730        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2731
2732        let mut dd = common::DefaultDelegate;
2733        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2734        dlg.begin(common::MethodInfo {
2735            id: "tasks.tasks.clear",
2736            http_method: hyper::Method::POST,
2737        });
2738
2739        for &field in ["tasklist"].iter() {
2740            if self._additional_params.contains_key(field) {
2741                dlg.finished(false);
2742                return Err(common::Error::FieldClash(field));
2743            }
2744        }
2745
2746        let mut params = Params::with_capacity(2 + self._additional_params.len());
2747        params.push("tasklist", self._tasklist);
2748
2749        params.extend(self._additional_params.iter());
2750
2751        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/clear";
2752        if self._scopes.is_empty() {
2753            self._scopes.insert(Scope::Full.as_ref().to_string());
2754        }
2755
2756        #[allow(clippy::single_element_loop)]
2757        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
2758            url = params.uri_replacement(url, param_name, find_this, false);
2759        }
2760        {
2761            let to_remove = ["tasklist"];
2762            params.remove_params(&to_remove);
2763        }
2764
2765        let url = params.parse_with_url(&url);
2766
2767        loop {
2768            let token = match self
2769                .hub
2770                .auth
2771                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2772                .await
2773            {
2774                Ok(token) => token,
2775                Err(e) => match dlg.token(e) {
2776                    Ok(token) => token,
2777                    Err(e) => {
2778                        dlg.finished(false);
2779                        return Err(common::Error::MissingToken(e));
2780                    }
2781                },
2782            };
2783            let mut req_result = {
2784                let client = &self.hub.client;
2785                dlg.pre_request();
2786                let mut req_builder = hyper::Request::builder()
2787                    .method(hyper::Method::POST)
2788                    .uri(url.as_str())
2789                    .header(USER_AGENT, self.hub._user_agent.clone());
2790
2791                if let Some(token) = token.as_ref() {
2792                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2793                }
2794
2795                let request = req_builder
2796                    .header(CONTENT_LENGTH, 0_u64)
2797                    .body(common::to_body::<String>(None));
2798
2799                client.request(request.unwrap()).await
2800            };
2801
2802            match req_result {
2803                Err(err) => {
2804                    if let common::Retry::After(d) = dlg.http_error(&err) {
2805                        sleep(d).await;
2806                        continue;
2807                    }
2808                    dlg.finished(false);
2809                    return Err(common::Error::HttpError(err));
2810                }
2811                Ok(res) => {
2812                    let (mut parts, body) = res.into_parts();
2813                    let mut body = common::Body::new(body);
2814                    if !parts.status.is_success() {
2815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2816                        let error = serde_json::from_str(&common::to_string(&bytes));
2817                        let response = common::to_response(parts, bytes.into());
2818
2819                        if let common::Retry::After(d) =
2820                            dlg.http_failure(&response, error.as_ref().ok())
2821                        {
2822                            sleep(d).await;
2823                            continue;
2824                        }
2825
2826                        dlg.finished(false);
2827
2828                        return Err(match error {
2829                            Ok(value) => common::Error::BadRequest(value),
2830                            _ => common::Error::Failure(response),
2831                        });
2832                    }
2833                    let response = common::Response::from_parts(parts, body);
2834
2835                    dlg.finished(true);
2836                    return Ok(response);
2837                }
2838            }
2839        }
2840    }
2841
2842    /// Task list identifier.
2843    ///
2844    /// Sets the *tasklist* path property to the given value.
2845    ///
2846    /// Even though the property as already been set when instantiating this call,
2847    /// we provide this method for API completeness.
2848    pub fn tasklist(mut self, new_value: &str) -> TaskClearCall<'a, C> {
2849        self._tasklist = new_value.to_string();
2850        self
2851    }
2852    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2853    /// while executing the actual API request.
2854    ///
2855    /// ````text
2856    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2857    /// ````
2858    ///
2859    /// Sets the *delegate* property to the given value.
2860    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskClearCall<'a, C> {
2861        self._delegate = Some(new_value);
2862        self
2863    }
2864
2865    /// Set any additional parameter of the query string used in the request.
2866    /// It should be used to set parameters which are not yet available through their own
2867    /// setters.
2868    ///
2869    /// Please note that this method must not be used to set any of the known parameters
2870    /// which have their own setter method. If done anyway, the request will fail.
2871    ///
2872    /// # Additional Parameters
2873    ///
2874    /// * *$.xgafv* (query-string) - V1 error format.
2875    /// * *access_token* (query-string) - OAuth access token.
2876    /// * *alt* (query-string) - Data format for response.
2877    /// * *callback* (query-string) - JSONP
2878    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2879    /// * *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.
2880    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2881    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2882    /// * *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.
2883    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2884    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2885    pub fn param<T>(mut self, name: T, value: T) -> TaskClearCall<'a, C>
2886    where
2887        T: AsRef<str>,
2888    {
2889        self._additional_params
2890            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2891        self
2892    }
2893
2894    /// Identifies the authorization scope for the method you are building.
2895    ///
2896    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2897    /// [`Scope::Full`].
2898    ///
2899    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2900    /// tokens for more than one scope.
2901    ///
2902    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2903    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2904    /// sufficient, a read-write scope will do as well.
2905    pub fn add_scope<St>(mut self, scope: St) -> TaskClearCall<'a, C>
2906    where
2907        St: AsRef<str>,
2908    {
2909        self._scopes.insert(String::from(scope.as_ref()));
2910        self
2911    }
2912    /// Identifies the authorization scope(s) for the method you are building.
2913    ///
2914    /// See [`Self::add_scope()`] for details.
2915    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskClearCall<'a, C>
2916    where
2917        I: IntoIterator<Item = St>,
2918        St: AsRef<str>,
2919    {
2920        self._scopes
2921            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2922        self
2923    }
2924
2925    /// Removes all scopes, and no default scope will be used either.
2926    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2927    /// for details).
2928    pub fn clear_scopes(mut self) -> TaskClearCall<'a, C> {
2929        self._scopes.clear();
2930        self
2931    }
2932}
2933
2934/// Deletes the specified task from the task list. If the task is assigned, both the assigned task and the original task (in Docs, Chat Spaces) are deleted. To delete the assigned task only, navigate to the assignment surface and unassign the task from there.
2935///
2936/// A builder for the *delete* method supported by a *task* resource.
2937/// It is not used directly, but through a [`TaskMethods`] instance.
2938///
2939/// # Example
2940///
2941/// Instantiate a resource method builder
2942///
2943/// ```test_harness,no_run
2944/// # extern crate hyper;
2945/// # extern crate hyper_rustls;
2946/// # extern crate google_tasks1 as tasks1;
2947/// # async fn dox() {
2948/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2949///
2950/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2951/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2952/// #     .with_native_roots()
2953/// #     .unwrap()
2954/// #     .https_only()
2955/// #     .enable_http2()
2956/// #     .build();
2957///
2958/// # let executor = hyper_util::rt::TokioExecutor::new();
2959/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2960/// #     secret,
2961/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2962/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2963/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2964/// #     ),
2965/// # ).build().await.unwrap();
2966///
2967/// # let client = hyper_util::client::legacy::Client::builder(
2968/// #     hyper_util::rt::TokioExecutor::new()
2969/// # )
2970/// # .build(
2971/// #     hyper_rustls::HttpsConnectorBuilder::new()
2972/// #         .with_native_roots()
2973/// #         .unwrap()
2974/// #         .https_or_http()
2975/// #         .enable_http2()
2976/// #         .build()
2977/// # );
2978/// # let mut hub = TasksHub::new(client, auth);
2979/// // You can configure optional parameters by calling the respective setters at will, and
2980/// // execute the final call using `doit()`.
2981/// // Values shown here are possibly random and not representative !
2982/// let result = hub.tasks().delete("tasklist", "task")
2983///              .doit().await;
2984/// # }
2985/// ```
2986pub struct TaskDeleteCall<'a, C>
2987where
2988    C: 'a,
2989{
2990    hub: &'a TasksHub<C>,
2991    _tasklist: String,
2992    _task: String,
2993    _delegate: Option<&'a mut dyn common::Delegate>,
2994    _additional_params: HashMap<String, String>,
2995    _scopes: BTreeSet<String>,
2996}
2997
2998impl<'a, C> common::CallBuilder for TaskDeleteCall<'a, C> {}
2999
3000impl<'a, C> TaskDeleteCall<'a, C>
3001where
3002    C: common::Connector,
3003{
3004    /// Perform the operation you have build so far.
3005    pub async fn doit(mut self) -> common::Result<common::Response> {
3006        use std::borrow::Cow;
3007        use std::io::{Read, Seek};
3008
3009        use common::{url::Params, ToParts};
3010        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3011
3012        let mut dd = common::DefaultDelegate;
3013        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3014        dlg.begin(common::MethodInfo {
3015            id: "tasks.tasks.delete",
3016            http_method: hyper::Method::DELETE,
3017        });
3018
3019        for &field in ["tasklist", "task"].iter() {
3020            if self._additional_params.contains_key(field) {
3021                dlg.finished(false);
3022                return Err(common::Error::FieldClash(field));
3023            }
3024        }
3025
3026        let mut params = Params::with_capacity(3 + self._additional_params.len());
3027        params.push("tasklist", self._tasklist);
3028        params.push("task", self._task);
3029
3030        params.extend(self._additional_params.iter());
3031
3032        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks/{task}";
3033        if self._scopes.is_empty() {
3034            self._scopes.insert(Scope::Full.as_ref().to_string());
3035        }
3036
3037        #[allow(clippy::single_element_loop)]
3038        for &(find_this, param_name) in [("{tasklist}", "tasklist"), ("{task}", "task")].iter() {
3039            url = params.uri_replacement(url, param_name, find_this, false);
3040        }
3041        {
3042            let to_remove = ["task", "tasklist"];
3043            params.remove_params(&to_remove);
3044        }
3045
3046        let url = params.parse_with_url(&url);
3047
3048        loop {
3049            let token = match self
3050                .hub
3051                .auth
3052                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3053                .await
3054            {
3055                Ok(token) => token,
3056                Err(e) => match dlg.token(e) {
3057                    Ok(token) => token,
3058                    Err(e) => {
3059                        dlg.finished(false);
3060                        return Err(common::Error::MissingToken(e));
3061                    }
3062                },
3063            };
3064            let mut req_result = {
3065                let client = &self.hub.client;
3066                dlg.pre_request();
3067                let mut req_builder = hyper::Request::builder()
3068                    .method(hyper::Method::DELETE)
3069                    .uri(url.as_str())
3070                    .header(USER_AGENT, self.hub._user_agent.clone());
3071
3072                if let Some(token) = token.as_ref() {
3073                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3074                }
3075
3076                let request = req_builder
3077                    .header(CONTENT_LENGTH, 0_u64)
3078                    .body(common::to_body::<String>(None));
3079
3080                client.request(request.unwrap()).await
3081            };
3082
3083            match req_result {
3084                Err(err) => {
3085                    if let common::Retry::After(d) = dlg.http_error(&err) {
3086                        sleep(d).await;
3087                        continue;
3088                    }
3089                    dlg.finished(false);
3090                    return Err(common::Error::HttpError(err));
3091                }
3092                Ok(res) => {
3093                    let (mut parts, body) = res.into_parts();
3094                    let mut body = common::Body::new(body);
3095                    if !parts.status.is_success() {
3096                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3097                        let error = serde_json::from_str(&common::to_string(&bytes));
3098                        let response = common::to_response(parts, bytes.into());
3099
3100                        if let common::Retry::After(d) =
3101                            dlg.http_failure(&response, error.as_ref().ok())
3102                        {
3103                            sleep(d).await;
3104                            continue;
3105                        }
3106
3107                        dlg.finished(false);
3108
3109                        return Err(match error {
3110                            Ok(value) => common::Error::BadRequest(value),
3111                            _ => common::Error::Failure(response),
3112                        });
3113                    }
3114                    let response = common::Response::from_parts(parts, body);
3115
3116                    dlg.finished(true);
3117                    return Ok(response);
3118                }
3119            }
3120        }
3121    }
3122
3123    /// Task list identifier.
3124    ///
3125    /// Sets the *tasklist* path property to the given value.
3126    ///
3127    /// Even though the property as already been set when instantiating this call,
3128    /// we provide this method for API completeness.
3129    pub fn tasklist(mut self, new_value: &str) -> TaskDeleteCall<'a, C> {
3130        self._tasklist = new_value.to_string();
3131        self
3132    }
3133    /// Task identifier.
3134    ///
3135    /// Sets the *task* path property to the given value.
3136    ///
3137    /// Even though the property as already been set when instantiating this call,
3138    /// we provide this method for API completeness.
3139    pub fn task(mut self, new_value: &str) -> TaskDeleteCall<'a, C> {
3140        self._task = new_value.to_string();
3141        self
3142    }
3143    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3144    /// while executing the actual API request.
3145    ///
3146    /// ````text
3147    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3148    /// ````
3149    ///
3150    /// Sets the *delegate* property to the given value.
3151    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskDeleteCall<'a, C> {
3152        self._delegate = Some(new_value);
3153        self
3154    }
3155
3156    /// Set any additional parameter of the query string used in the request.
3157    /// It should be used to set parameters which are not yet available through their own
3158    /// setters.
3159    ///
3160    /// Please note that this method must not be used to set any of the known parameters
3161    /// which have their own setter method. If done anyway, the request will fail.
3162    ///
3163    /// # Additional Parameters
3164    ///
3165    /// * *$.xgafv* (query-string) - V1 error format.
3166    /// * *access_token* (query-string) - OAuth access token.
3167    /// * *alt* (query-string) - Data format for response.
3168    /// * *callback* (query-string) - JSONP
3169    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3170    /// * *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.
3171    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3172    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3173    /// * *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.
3174    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3175    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3176    pub fn param<T>(mut self, name: T, value: T) -> TaskDeleteCall<'a, C>
3177    where
3178        T: AsRef<str>,
3179    {
3180        self._additional_params
3181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3182        self
3183    }
3184
3185    /// Identifies the authorization scope for the method you are building.
3186    ///
3187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3188    /// [`Scope::Full`].
3189    ///
3190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3191    /// tokens for more than one scope.
3192    ///
3193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3195    /// sufficient, a read-write scope will do as well.
3196    pub fn add_scope<St>(mut self, scope: St) -> TaskDeleteCall<'a, C>
3197    where
3198        St: AsRef<str>,
3199    {
3200        self._scopes.insert(String::from(scope.as_ref()));
3201        self
3202    }
3203    /// Identifies the authorization scope(s) for the method you are building.
3204    ///
3205    /// See [`Self::add_scope()`] for details.
3206    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskDeleteCall<'a, C>
3207    where
3208        I: IntoIterator<Item = St>,
3209        St: AsRef<str>,
3210    {
3211        self._scopes
3212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3213        self
3214    }
3215
3216    /// Removes all scopes, and no default scope will be used either.
3217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3218    /// for details).
3219    pub fn clear_scopes(mut self) -> TaskDeleteCall<'a, C> {
3220        self._scopes.clear();
3221        self
3222    }
3223}
3224
3225/// Returns the specified task.
3226///
3227/// A builder for the *get* method supported by a *task* resource.
3228/// It is not used directly, but through a [`TaskMethods`] instance.
3229///
3230/// # Example
3231///
3232/// Instantiate a resource method builder
3233///
3234/// ```test_harness,no_run
3235/// # extern crate hyper;
3236/// # extern crate hyper_rustls;
3237/// # extern crate google_tasks1 as tasks1;
3238/// # async fn dox() {
3239/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3240///
3241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3242/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3243/// #     .with_native_roots()
3244/// #     .unwrap()
3245/// #     .https_only()
3246/// #     .enable_http2()
3247/// #     .build();
3248///
3249/// # let executor = hyper_util::rt::TokioExecutor::new();
3250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3251/// #     secret,
3252/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3253/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3254/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3255/// #     ),
3256/// # ).build().await.unwrap();
3257///
3258/// # let client = hyper_util::client::legacy::Client::builder(
3259/// #     hyper_util::rt::TokioExecutor::new()
3260/// # )
3261/// # .build(
3262/// #     hyper_rustls::HttpsConnectorBuilder::new()
3263/// #         .with_native_roots()
3264/// #         .unwrap()
3265/// #         .https_or_http()
3266/// #         .enable_http2()
3267/// #         .build()
3268/// # );
3269/// # let mut hub = TasksHub::new(client, auth);
3270/// // You can configure optional parameters by calling the respective setters at will, and
3271/// // execute the final call using `doit()`.
3272/// // Values shown here are possibly random and not representative !
3273/// let result = hub.tasks().get("tasklist", "task")
3274///              .doit().await;
3275/// # }
3276/// ```
3277pub struct TaskGetCall<'a, C>
3278where
3279    C: 'a,
3280{
3281    hub: &'a TasksHub<C>,
3282    _tasklist: String,
3283    _task: String,
3284    _delegate: Option<&'a mut dyn common::Delegate>,
3285    _additional_params: HashMap<String, String>,
3286    _scopes: BTreeSet<String>,
3287}
3288
3289impl<'a, C> common::CallBuilder for TaskGetCall<'a, C> {}
3290
3291impl<'a, C> TaskGetCall<'a, C>
3292where
3293    C: common::Connector,
3294{
3295    /// Perform the operation you have build so far.
3296    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3297        use std::borrow::Cow;
3298        use std::io::{Read, Seek};
3299
3300        use common::{url::Params, ToParts};
3301        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3302
3303        let mut dd = common::DefaultDelegate;
3304        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3305        dlg.begin(common::MethodInfo {
3306            id: "tasks.tasks.get",
3307            http_method: hyper::Method::GET,
3308        });
3309
3310        for &field in ["alt", "tasklist", "task"].iter() {
3311            if self._additional_params.contains_key(field) {
3312                dlg.finished(false);
3313                return Err(common::Error::FieldClash(field));
3314            }
3315        }
3316
3317        let mut params = Params::with_capacity(4 + self._additional_params.len());
3318        params.push("tasklist", self._tasklist);
3319        params.push("task", self._task);
3320
3321        params.extend(self._additional_params.iter());
3322
3323        params.push("alt", "json");
3324        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks/{task}";
3325        if self._scopes.is_empty() {
3326            self._scopes.insert(Scope::Readonly.as_ref().to_string());
3327        }
3328
3329        #[allow(clippy::single_element_loop)]
3330        for &(find_this, param_name) in [("{tasklist}", "tasklist"), ("{task}", "task")].iter() {
3331            url = params.uri_replacement(url, param_name, find_this, false);
3332        }
3333        {
3334            let to_remove = ["task", "tasklist"];
3335            params.remove_params(&to_remove);
3336        }
3337
3338        let url = params.parse_with_url(&url);
3339
3340        loop {
3341            let token = match self
3342                .hub
3343                .auth
3344                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3345                .await
3346            {
3347                Ok(token) => token,
3348                Err(e) => match dlg.token(e) {
3349                    Ok(token) => token,
3350                    Err(e) => {
3351                        dlg.finished(false);
3352                        return Err(common::Error::MissingToken(e));
3353                    }
3354                },
3355            };
3356            let mut req_result = {
3357                let client = &self.hub.client;
3358                dlg.pre_request();
3359                let mut req_builder = hyper::Request::builder()
3360                    .method(hyper::Method::GET)
3361                    .uri(url.as_str())
3362                    .header(USER_AGENT, self.hub._user_agent.clone());
3363
3364                if let Some(token) = token.as_ref() {
3365                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3366                }
3367
3368                let request = req_builder
3369                    .header(CONTENT_LENGTH, 0_u64)
3370                    .body(common::to_body::<String>(None));
3371
3372                client.request(request.unwrap()).await
3373            };
3374
3375            match req_result {
3376                Err(err) => {
3377                    if let common::Retry::After(d) = dlg.http_error(&err) {
3378                        sleep(d).await;
3379                        continue;
3380                    }
3381                    dlg.finished(false);
3382                    return Err(common::Error::HttpError(err));
3383                }
3384                Ok(res) => {
3385                    let (mut parts, body) = res.into_parts();
3386                    let mut body = common::Body::new(body);
3387                    if !parts.status.is_success() {
3388                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3389                        let error = serde_json::from_str(&common::to_string(&bytes));
3390                        let response = common::to_response(parts, bytes.into());
3391
3392                        if let common::Retry::After(d) =
3393                            dlg.http_failure(&response, error.as_ref().ok())
3394                        {
3395                            sleep(d).await;
3396                            continue;
3397                        }
3398
3399                        dlg.finished(false);
3400
3401                        return Err(match error {
3402                            Ok(value) => common::Error::BadRequest(value),
3403                            _ => common::Error::Failure(response),
3404                        });
3405                    }
3406                    let response = {
3407                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3408                        let encoded = common::to_string(&bytes);
3409                        match serde_json::from_str(&encoded) {
3410                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3411                            Err(error) => {
3412                                dlg.response_json_decode_error(&encoded, &error);
3413                                return Err(common::Error::JsonDecodeError(
3414                                    encoded.to_string(),
3415                                    error,
3416                                ));
3417                            }
3418                        }
3419                    };
3420
3421                    dlg.finished(true);
3422                    return Ok(response);
3423                }
3424            }
3425        }
3426    }
3427
3428    /// Task list identifier.
3429    ///
3430    /// Sets the *tasklist* path property to the given value.
3431    ///
3432    /// Even though the property as already been set when instantiating this call,
3433    /// we provide this method for API completeness.
3434    pub fn tasklist(mut self, new_value: &str) -> TaskGetCall<'a, C> {
3435        self._tasklist = new_value.to_string();
3436        self
3437    }
3438    /// Task identifier.
3439    ///
3440    /// Sets the *task* path property to the given value.
3441    ///
3442    /// Even though the property as already been set when instantiating this call,
3443    /// we provide this method for API completeness.
3444    pub fn task(mut self, new_value: &str) -> TaskGetCall<'a, C> {
3445        self._task = new_value.to_string();
3446        self
3447    }
3448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3449    /// while executing the actual API request.
3450    ///
3451    /// ````text
3452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3453    /// ````
3454    ///
3455    /// Sets the *delegate* property to the given value.
3456    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskGetCall<'a, C> {
3457        self._delegate = Some(new_value);
3458        self
3459    }
3460
3461    /// Set any additional parameter of the query string used in the request.
3462    /// It should be used to set parameters which are not yet available through their own
3463    /// setters.
3464    ///
3465    /// Please note that this method must not be used to set any of the known parameters
3466    /// which have their own setter method. If done anyway, the request will fail.
3467    ///
3468    /// # Additional Parameters
3469    ///
3470    /// * *$.xgafv* (query-string) - V1 error format.
3471    /// * *access_token* (query-string) - OAuth access token.
3472    /// * *alt* (query-string) - Data format for response.
3473    /// * *callback* (query-string) - JSONP
3474    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3475    /// * *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.
3476    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3477    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3478    /// * *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.
3479    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3480    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3481    pub fn param<T>(mut self, name: T, value: T) -> TaskGetCall<'a, C>
3482    where
3483        T: AsRef<str>,
3484    {
3485        self._additional_params
3486            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3487        self
3488    }
3489
3490    /// Identifies the authorization scope for the method you are building.
3491    ///
3492    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3493    /// [`Scope::Readonly`].
3494    ///
3495    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3496    /// tokens for more than one scope.
3497    ///
3498    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3499    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3500    /// sufficient, a read-write scope will do as well.
3501    pub fn add_scope<St>(mut self, scope: St) -> TaskGetCall<'a, C>
3502    where
3503        St: AsRef<str>,
3504    {
3505        self._scopes.insert(String::from(scope.as_ref()));
3506        self
3507    }
3508    /// Identifies the authorization scope(s) for the method you are building.
3509    ///
3510    /// See [`Self::add_scope()`] for details.
3511    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskGetCall<'a, C>
3512    where
3513        I: IntoIterator<Item = St>,
3514        St: AsRef<str>,
3515    {
3516        self._scopes
3517            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3518        self
3519    }
3520
3521    /// Removes all scopes, and no default scope will be used either.
3522    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3523    /// for details).
3524    pub fn clear_scopes(mut self) -> TaskGetCall<'a, C> {
3525        self._scopes.clear();
3526        self
3527    }
3528}
3529
3530/// Creates a new task on the specified task list. Tasks assigned from Docs or Chat Spaces cannot be inserted from Tasks Public API; they can only be created by assigning them from Docs or Chat Spaces. A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.
3531///
3532/// A builder for the *insert* method supported by a *task* resource.
3533/// It is not used directly, but through a [`TaskMethods`] instance.
3534///
3535/// # Example
3536///
3537/// Instantiate a resource method builder
3538///
3539/// ```test_harness,no_run
3540/// # extern crate hyper;
3541/// # extern crate hyper_rustls;
3542/// # extern crate google_tasks1 as tasks1;
3543/// use tasks1::api::Task;
3544/// # async fn dox() {
3545/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3546///
3547/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3548/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3549/// #     .with_native_roots()
3550/// #     .unwrap()
3551/// #     .https_only()
3552/// #     .enable_http2()
3553/// #     .build();
3554///
3555/// # let executor = hyper_util::rt::TokioExecutor::new();
3556/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3557/// #     secret,
3558/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3559/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3560/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3561/// #     ),
3562/// # ).build().await.unwrap();
3563///
3564/// # let client = hyper_util::client::legacy::Client::builder(
3565/// #     hyper_util::rt::TokioExecutor::new()
3566/// # )
3567/// # .build(
3568/// #     hyper_rustls::HttpsConnectorBuilder::new()
3569/// #         .with_native_roots()
3570/// #         .unwrap()
3571/// #         .https_or_http()
3572/// #         .enable_http2()
3573/// #         .build()
3574/// # );
3575/// # let mut hub = TasksHub::new(client, auth);
3576/// // As the method needs a request, you would usually fill it with the desired information
3577/// // into the respective structure. Some of the parts shown here might not be applicable !
3578/// // Values shown here are possibly random and not representative !
3579/// let mut req = Task::default();
3580///
3581/// // You can configure optional parameters by calling the respective setters at will, and
3582/// // execute the final call using `doit()`.
3583/// // Values shown here are possibly random and not representative !
3584/// let result = hub.tasks().insert(req, "tasklist")
3585///              .previous("consetetur")
3586///              .parent("diam")
3587///              .doit().await;
3588/// # }
3589/// ```
3590pub struct TaskInsertCall<'a, C>
3591where
3592    C: 'a,
3593{
3594    hub: &'a TasksHub<C>,
3595    _request: Task,
3596    _tasklist: String,
3597    _previous: Option<String>,
3598    _parent: Option<String>,
3599    _delegate: Option<&'a mut dyn common::Delegate>,
3600    _additional_params: HashMap<String, String>,
3601    _scopes: BTreeSet<String>,
3602}
3603
3604impl<'a, C> common::CallBuilder for TaskInsertCall<'a, C> {}
3605
3606impl<'a, C> TaskInsertCall<'a, C>
3607where
3608    C: common::Connector,
3609{
3610    /// Perform the operation you have build so far.
3611    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
3612        use std::borrow::Cow;
3613        use std::io::{Read, Seek};
3614
3615        use common::{url::Params, ToParts};
3616        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3617
3618        let mut dd = common::DefaultDelegate;
3619        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3620        dlg.begin(common::MethodInfo {
3621            id: "tasks.tasks.insert",
3622            http_method: hyper::Method::POST,
3623        });
3624
3625        for &field in ["alt", "tasklist", "previous", "parent"].iter() {
3626            if self._additional_params.contains_key(field) {
3627                dlg.finished(false);
3628                return Err(common::Error::FieldClash(field));
3629            }
3630        }
3631
3632        let mut params = Params::with_capacity(6 + self._additional_params.len());
3633        params.push("tasklist", self._tasklist);
3634        if let Some(value) = self._previous.as_ref() {
3635            params.push("previous", value);
3636        }
3637        if let Some(value) = self._parent.as_ref() {
3638            params.push("parent", value);
3639        }
3640
3641        params.extend(self._additional_params.iter());
3642
3643        params.push("alt", "json");
3644        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks";
3645        if self._scopes.is_empty() {
3646            self._scopes.insert(Scope::Full.as_ref().to_string());
3647        }
3648
3649        #[allow(clippy::single_element_loop)]
3650        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
3651            url = params.uri_replacement(url, param_name, find_this, false);
3652        }
3653        {
3654            let to_remove = ["tasklist"];
3655            params.remove_params(&to_remove);
3656        }
3657
3658        let url = params.parse_with_url(&url);
3659
3660        let mut json_mime_type = mime::APPLICATION_JSON;
3661        let mut request_value_reader = {
3662            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3663            common::remove_json_null_values(&mut value);
3664            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3665            serde_json::to_writer(&mut dst, &value).unwrap();
3666            dst
3667        };
3668        let request_size = request_value_reader
3669            .seek(std::io::SeekFrom::End(0))
3670            .unwrap();
3671        request_value_reader
3672            .seek(std::io::SeekFrom::Start(0))
3673            .unwrap();
3674
3675        loop {
3676            let token = match self
3677                .hub
3678                .auth
3679                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3680                .await
3681            {
3682                Ok(token) => token,
3683                Err(e) => match dlg.token(e) {
3684                    Ok(token) => token,
3685                    Err(e) => {
3686                        dlg.finished(false);
3687                        return Err(common::Error::MissingToken(e));
3688                    }
3689                },
3690            };
3691            request_value_reader
3692                .seek(std::io::SeekFrom::Start(0))
3693                .unwrap();
3694            let mut req_result = {
3695                let client = &self.hub.client;
3696                dlg.pre_request();
3697                let mut req_builder = hyper::Request::builder()
3698                    .method(hyper::Method::POST)
3699                    .uri(url.as_str())
3700                    .header(USER_AGENT, self.hub._user_agent.clone());
3701
3702                if let Some(token) = token.as_ref() {
3703                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3704                }
3705
3706                let request = req_builder
3707                    .header(CONTENT_TYPE, json_mime_type.to_string())
3708                    .header(CONTENT_LENGTH, request_size as u64)
3709                    .body(common::to_body(
3710                        request_value_reader.get_ref().clone().into(),
3711                    ));
3712
3713                client.request(request.unwrap()).await
3714            };
3715
3716            match req_result {
3717                Err(err) => {
3718                    if let common::Retry::After(d) = dlg.http_error(&err) {
3719                        sleep(d).await;
3720                        continue;
3721                    }
3722                    dlg.finished(false);
3723                    return Err(common::Error::HttpError(err));
3724                }
3725                Ok(res) => {
3726                    let (mut parts, body) = res.into_parts();
3727                    let mut body = common::Body::new(body);
3728                    if !parts.status.is_success() {
3729                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3730                        let error = serde_json::from_str(&common::to_string(&bytes));
3731                        let response = common::to_response(parts, bytes.into());
3732
3733                        if let common::Retry::After(d) =
3734                            dlg.http_failure(&response, error.as_ref().ok())
3735                        {
3736                            sleep(d).await;
3737                            continue;
3738                        }
3739
3740                        dlg.finished(false);
3741
3742                        return Err(match error {
3743                            Ok(value) => common::Error::BadRequest(value),
3744                            _ => common::Error::Failure(response),
3745                        });
3746                    }
3747                    let response = {
3748                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3749                        let encoded = common::to_string(&bytes);
3750                        match serde_json::from_str(&encoded) {
3751                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3752                            Err(error) => {
3753                                dlg.response_json_decode_error(&encoded, &error);
3754                                return Err(common::Error::JsonDecodeError(
3755                                    encoded.to_string(),
3756                                    error,
3757                                ));
3758                            }
3759                        }
3760                    };
3761
3762                    dlg.finished(true);
3763                    return Ok(response);
3764                }
3765            }
3766        }
3767    }
3768
3769    ///
3770    /// Sets the *request* property to the given value.
3771    ///
3772    /// Even though the property as already been set when instantiating this call,
3773    /// we provide this method for API completeness.
3774    pub fn request(mut self, new_value: Task) -> TaskInsertCall<'a, C> {
3775        self._request = new_value;
3776        self
3777    }
3778    /// Task list identifier.
3779    ///
3780    /// Sets the *tasklist* path property to the given value.
3781    ///
3782    /// Even though the property as already been set when instantiating this call,
3783    /// we provide this method for API completeness.
3784    pub fn tasklist(mut self, new_value: &str) -> TaskInsertCall<'a, C> {
3785        self._tasklist = new_value.to_string();
3786        self
3787    }
3788    /// Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted. Optional.
3789    ///
3790    /// Sets the *previous* query property to the given value.
3791    pub fn previous(mut self, new_value: &str) -> TaskInsertCall<'a, C> {
3792        self._previous = Some(new_value.to_string());
3793        self
3794    }
3795    /// Parent task identifier. If the task is created at the top level, this parameter is omitted. An assigned task cannot be a parent task, nor can it have a parent. Setting the parent to an assigned task results in failure of the request. Optional.
3796    ///
3797    /// Sets the *parent* query property to the given value.
3798    pub fn parent(mut self, new_value: &str) -> TaskInsertCall<'a, C> {
3799        self._parent = Some(new_value.to_string());
3800        self
3801    }
3802    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3803    /// while executing the actual API request.
3804    ///
3805    /// ````text
3806    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3807    /// ````
3808    ///
3809    /// Sets the *delegate* property to the given value.
3810    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskInsertCall<'a, C> {
3811        self._delegate = Some(new_value);
3812        self
3813    }
3814
3815    /// Set any additional parameter of the query string used in the request.
3816    /// It should be used to set parameters which are not yet available through their own
3817    /// setters.
3818    ///
3819    /// Please note that this method must not be used to set any of the known parameters
3820    /// which have their own setter method. If done anyway, the request will fail.
3821    ///
3822    /// # Additional Parameters
3823    ///
3824    /// * *$.xgafv* (query-string) - V1 error format.
3825    /// * *access_token* (query-string) - OAuth access token.
3826    /// * *alt* (query-string) - Data format for response.
3827    /// * *callback* (query-string) - JSONP
3828    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3829    /// * *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.
3830    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3831    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3832    /// * *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.
3833    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3834    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3835    pub fn param<T>(mut self, name: T, value: T) -> TaskInsertCall<'a, C>
3836    where
3837        T: AsRef<str>,
3838    {
3839        self._additional_params
3840            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3841        self
3842    }
3843
3844    /// Identifies the authorization scope for the method you are building.
3845    ///
3846    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3847    /// [`Scope::Full`].
3848    ///
3849    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3850    /// tokens for more than one scope.
3851    ///
3852    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3853    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3854    /// sufficient, a read-write scope will do as well.
3855    pub fn add_scope<St>(mut self, scope: St) -> TaskInsertCall<'a, C>
3856    where
3857        St: AsRef<str>,
3858    {
3859        self._scopes.insert(String::from(scope.as_ref()));
3860        self
3861    }
3862    /// Identifies the authorization scope(s) for the method you are building.
3863    ///
3864    /// See [`Self::add_scope()`] for details.
3865    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskInsertCall<'a, C>
3866    where
3867        I: IntoIterator<Item = St>,
3868        St: AsRef<str>,
3869    {
3870        self._scopes
3871            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3872        self
3873    }
3874
3875    /// Removes all scopes, and no default scope will be used either.
3876    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3877    /// for details).
3878    pub fn clear_scopes(mut self) -> TaskInsertCall<'a, C> {
3879        self._scopes.clear();
3880        self
3881    }
3882}
3883
3884/// Returns all tasks in the specified task list. Doesn't return assigned tasks by default (from Docs, Chat Spaces). A user can have up to 20,000 non-hidden tasks per list and up to 100,000 tasks in total at a time.
3885///
3886/// A builder for the *list* method supported by a *task* resource.
3887/// It is not used directly, but through a [`TaskMethods`] instance.
3888///
3889/// # Example
3890///
3891/// Instantiate a resource method builder
3892///
3893/// ```test_harness,no_run
3894/// # extern crate hyper;
3895/// # extern crate hyper_rustls;
3896/// # extern crate google_tasks1 as tasks1;
3897/// # async fn dox() {
3898/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3899///
3900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3902/// #     .with_native_roots()
3903/// #     .unwrap()
3904/// #     .https_only()
3905/// #     .enable_http2()
3906/// #     .build();
3907///
3908/// # let executor = hyper_util::rt::TokioExecutor::new();
3909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3910/// #     secret,
3911/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3912/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3913/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3914/// #     ),
3915/// # ).build().await.unwrap();
3916///
3917/// # let client = hyper_util::client::legacy::Client::builder(
3918/// #     hyper_util::rt::TokioExecutor::new()
3919/// # )
3920/// # .build(
3921/// #     hyper_rustls::HttpsConnectorBuilder::new()
3922/// #         .with_native_roots()
3923/// #         .unwrap()
3924/// #         .https_or_http()
3925/// #         .enable_http2()
3926/// #         .build()
3927/// # );
3928/// # let mut hub = TasksHub::new(client, auth);
3929/// // You can configure optional parameters by calling the respective setters at will, and
3930/// // execute the final call using `doit()`.
3931/// // Values shown here are possibly random and not representative !
3932/// let result = hub.tasks().list("tasklist")
3933///              .updated_min("et")
3934///              .show_hidden(false)
3935///              .show_deleted(false)
3936///              .show_completed(false)
3937///              .show_assigned(false)
3938///              .page_token("invidunt")
3939///              .max_results(-65)
3940///              .due_min("vero")
3941///              .due_max("elitr")
3942///              .completed_min("Lorem")
3943///              .completed_max("diam")
3944///              .doit().await;
3945/// # }
3946/// ```
3947pub struct TaskListCall<'a, C>
3948where
3949    C: 'a,
3950{
3951    hub: &'a TasksHub<C>,
3952    _tasklist: String,
3953    _updated_min: Option<String>,
3954    _show_hidden: Option<bool>,
3955    _show_deleted: Option<bool>,
3956    _show_completed: Option<bool>,
3957    _show_assigned: Option<bool>,
3958    _page_token: Option<String>,
3959    _max_results: Option<i32>,
3960    _due_min: Option<String>,
3961    _due_max: Option<String>,
3962    _completed_min: Option<String>,
3963    _completed_max: Option<String>,
3964    _delegate: Option<&'a mut dyn common::Delegate>,
3965    _additional_params: HashMap<String, String>,
3966    _scopes: BTreeSet<String>,
3967}
3968
3969impl<'a, C> common::CallBuilder for TaskListCall<'a, C> {}
3970
3971impl<'a, C> TaskListCall<'a, C>
3972where
3973    C: common::Connector,
3974{
3975    /// Perform the operation you have build so far.
3976    pub async fn doit(mut self) -> common::Result<(common::Response, Tasks)> {
3977        use std::borrow::Cow;
3978        use std::io::{Read, Seek};
3979
3980        use common::{url::Params, ToParts};
3981        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3982
3983        let mut dd = common::DefaultDelegate;
3984        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3985        dlg.begin(common::MethodInfo {
3986            id: "tasks.tasks.list",
3987            http_method: hyper::Method::GET,
3988        });
3989
3990        for &field in [
3991            "alt",
3992            "tasklist",
3993            "updatedMin",
3994            "showHidden",
3995            "showDeleted",
3996            "showCompleted",
3997            "showAssigned",
3998            "pageToken",
3999            "maxResults",
4000            "dueMin",
4001            "dueMax",
4002            "completedMin",
4003            "completedMax",
4004        ]
4005        .iter()
4006        {
4007            if self._additional_params.contains_key(field) {
4008                dlg.finished(false);
4009                return Err(common::Error::FieldClash(field));
4010            }
4011        }
4012
4013        let mut params = Params::with_capacity(14 + self._additional_params.len());
4014        params.push("tasklist", self._tasklist);
4015        if let Some(value) = self._updated_min.as_ref() {
4016            params.push("updatedMin", value);
4017        }
4018        if let Some(value) = self._show_hidden.as_ref() {
4019            params.push("showHidden", value.to_string());
4020        }
4021        if let Some(value) = self._show_deleted.as_ref() {
4022            params.push("showDeleted", value.to_string());
4023        }
4024        if let Some(value) = self._show_completed.as_ref() {
4025            params.push("showCompleted", value.to_string());
4026        }
4027        if let Some(value) = self._show_assigned.as_ref() {
4028            params.push("showAssigned", value.to_string());
4029        }
4030        if let Some(value) = self._page_token.as_ref() {
4031            params.push("pageToken", value);
4032        }
4033        if let Some(value) = self._max_results.as_ref() {
4034            params.push("maxResults", value.to_string());
4035        }
4036        if let Some(value) = self._due_min.as_ref() {
4037            params.push("dueMin", value);
4038        }
4039        if let Some(value) = self._due_max.as_ref() {
4040            params.push("dueMax", value);
4041        }
4042        if let Some(value) = self._completed_min.as_ref() {
4043            params.push("completedMin", value);
4044        }
4045        if let Some(value) = self._completed_max.as_ref() {
4046            params.push("completedMax", value);
4047        }
4048
4049        params.extend(self._additional_params.iter());
4050
4051        params.push("alt", "json");
4052        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks";
4053        if self._scopes.is_empty() {
4054            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4055        }
4056
4057        #[allow(clippy::single_element_loop)]
4058        for &(find_this, param_name) in [("{tasklist}", "tasklist")].iter() {
4059            url = params.uri_replacement(url, param_name, find_this, false);
4060        }
4061        {
4062            let to_remove = ["tasklist"];
4063            params.remove_params(&to_remove);
4064        }
4065
4066        let url = params.parse_with_url(&url);
4067
4068        loop {
4069            let token = match self
4070                .hub
4071                .auth
4072                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4073                .await
4074            {
4075                Ok(token) => token,
4076                Err(e) => match dlg.token(e) {
4077                    Ok(token) => token,
4078                    Err(e) => {
4079                        dlg.finished(false);
4080                        return Err(common::Error::MissingToken(e));
4081                    }
4082                },
4083            };
4084            let mut req_result = {
4085                let client = &self.hub.client;
4086                dlg.pre_request();
4087                let mut req_builder = hyper::Request::builder()
4088                    .method(hyper::Method::GET)
4089                    .uri(url.as_str())
4090                    .header(USER_AGENT, self.hub._user_agent.clone());
4091
4092                if let Some(token) = token.as_ref() {
4093                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4094                }
4095
4096                let request = req_builder
4097                    .header(CONTENT_LENGTH, 0_u64)
4098                    .body(common::to_body::<String>(None));
4099
4100                client.request(request.unwrap()).await
4101            };
4102
4103            match req_result {
4104                Err(err) => {
4105                    if let common::Retry::After(d) = dlg.http_error(&err) {
4106                        sleep(d).await;
4107                        continue;
4108                    }
4109                    dlg.finished(false);
4110                    return Err(common::Error::HttpError(err));
4111                }
4112                Ok(res) => {
4113                    let (mut parts, body) = res.into_parts();
4114                    let mut body = common::Body::new(body);
4115                    if !parts.status.is_success() {
4116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4117                        let error = serde_json::from_str(&common::to_string(&bytes));
4118                        let response = common::to_response(parts, bytes.into());
4119
4120                        if let common::Retry::After(d) =
4121                            dlg.http_failure(&response, error.as_ref().ok())
4122                        {
4123                            sleep(d).await;
4124                            continue;
4125                        }
4126
4127                        dlg.finished(false);
4128
4129                        return Err(match error {
4130                            Ok(value) => common::Error::BadRequest(value),
4131                            _ => common::Error::Failure(response),
4132                        });
4133                    }
4134                    let response = {
4135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4136                        let encoded = common::to_string(&bytes);
4137                        match serde_json::from_str(&encoded) {
4138                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4139                            Err(error) => {
4140                                dlg.response_json_decode_error(&encoded, &error);
4141                                return Err(common::Error::JsonDecodeError(
4142                                    encoded.to_string(),
4143                                    error,
4144                                ));
4145                            }
4146                        }
4147                    };
4148
4149                    dlg.finished(true);
4150                    return Ok(response);
4151                }
4152            }
4153        }
4154    }
4155
4156    /// Task list identifier.
4157    ///
4158    /// Sets the *tasklist* path property to the given value.
4159    ///
4160    /// Even though the property as already been set when instantiating this call,
4161    /// we provide this method for API completeness.
4162    pub fn tasklist(mut self, new_value: &str) -> TaskListCall<'a, C> {
4163        self._tasklist = new_value.to_string();
4164        self
4165    }
4166    /// Lower bound for a task's last modification time (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by last modification time.
4167    ///
4168    /// Sets the *updated min* query property to the given value.
4169    pub fn updated_min(mut self, new_value: &str) -> TaskListCall<'a, C> {
4170        self._updated_min = Some(new_value.to_string());
4171        self
4172    }
4173    /// Flag indicating whether hidden tasks are returned in the result. Optional. The default is False.
4174    ///
4175    /// Sets the *show hidden* query property to the given value.
4176    pub fn show_hidden(mut self, new_value: bool) -> TaskListCall<'a, C> {
4177        self._show_hidden = Some(new_value);
4178        self
4179    }
4180    /// Flag indicating whether deleted tasks are returned in the result. Optional. The default is False.
4181    ///
4182    /// Sets the *show deleted* query property to the given value.
4183    pub fn show_deleted(mut self, new_value: bool) -> TaskListCall<'a, C> {
4184        self._show_deleted = Some(new_value);
4185        self
4186    }
4187    /// Flag indicating whether completed tasks are returned in the result. Note that showHidden must also be True to show tasks completed in first party clients, such as the web UI and Google's mobile apps. Optional. The default is True.
4188    ///
4189    /// Sets the *show completed* query property to the given value.
4190    pub fn show_completed(mut self, new_value: bool) -> TaskListCall<'a, C> {
4191        self._show_completed = Some(new_value);
4192        self
4193    }
4194    /// Optional. Flag indicating whether tasks assigned to the current user are returned in the result. Optional. The default is False.
4195    ///
4196    /// Sets the *show assigned* query property to the given value.
4197    pub fn show_assigned(mut self, new_value: bool) -> TaskListCall<'a, C> {
4198        self._show_assigned = Some(new_value);
4199        self
4200    }
4201    /// Token specifying the result page to return. Optional.
4202    ///
4203    /// Sets the *page token* query property to the given value.
4204    pub fn page_token(mut self, new_value: &str) -> TaskListCall<'a, C> {
4205        self._page_token = Some(new_value.to_string());
4206        self
4207    }
4208    /// Maximum number of tasks returned on one page. Optional. The default is 20 (max allowed: 100).
4209    ///
4210    /// Sets the *max results* query property to the given value.
4211    pub fn max_results(mut self, new_value: i32) -> TaskListCall<'a, C> {
4212        self._max_results = Some(new_value);
4213        self
4214    }
4215    /// Lower bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by due date.
4216    ///
4217    /// Sets the *due min* query property to the given value.
4218    pub fn due_min(mut self, new_value: &str) -> TaskListCall<'a, C> {
4219        self._due_min = Some(new_value.to_string());
4220        self
4221    }
4222    /// Upper bound for a task's due date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by due date.
4223    ///
4224    /// Sets the *due max* query property to the given value.
4225    pub fn due_max(mut self, new_value: &str) -> TaskListCall<'a, C> {
4226        self._due_max = Some(new_value.to_string());
4227        self
4228    }
4229    /// Lower bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by completion date.
4230    ///
4231    /// Sets the *completed min* query property to the given value.
4232    pub fn completed_min(mut self, new_value: &str) -> TaskListCall<'a, C> {
4233        self._completed_min = Some(new_value.to_string());
4234        self
4235    }
4236    /// Upper bound for a task's completion date (as a RFC 3339 timestamp) to filter by. Optional. The default is not to filter by completion date.
4237    ///
4238    /// Sets the *completed max* query property to the given value.
4239    pub fn completed_max(mut self, new_value: &str) -> TaskListCall<'a, C> {
4240        self._completed_max = Some(new_value.to_string());
4241        self
4242    }
4243    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4244    /// while executing the actual API request.
4245    ///
4246    /// ````text
4247    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4248    /// ````
4249    ///
4250    /// Sets the *delegate* property to the given value.
4251    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskListCall<'a, C> {
4252        self._delegate = Some(new_value);
4253        self
4254    }
4255
4256    /// Set any additional parameter of the query string used in the request.
4257    /// It should be used to set parameters which are not yet available through their own
4258    /// setters.
4259    ///
4260    /// Please note that this method must not be used to set any of the known parameters
4261    /// which have their own setter method. If done anyway, the request will fail.
4262    ///
4263    /// # Additional Parameters
4264    ///
4265    /// * *$.xgafv* (query-string) - V1 error format.
4266    /// * *access_token* (query-string) - OAuth access token.
4267    /// * *alt* (query-string) - Data format for response.
4268    /// * *callback* (query-string) - JSONP
4269    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4270    /// * *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.
4271    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4272    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4273    /// * *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.
4274    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4275    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4276    pub fn param<T>(mut self, name: T, value: T) -> TaskListCall<'a, C>
4277    where
4278        T: AsRef<str>,
4279    {
4280        self._additional_params
4281            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4282        self
4283    }
4284
4285    /// Identifies the authorization scope for the method you are building.
4286    ///
4287    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4288    /// [`Scope::Readonly`].
4289    ///
4290    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4291    /// tokens for more than one scope.
4292    ///
4293    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4294    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4295    /// sufficient, a read-write scope will do as well.
4296    pub fn add_scope<St>(mut self, scope: St) -> TaskListCall<'a, C>
4297    where
4298        St: AsRef<str>,
4299    {
4300        self._scopes.insert(String::from(scope.as_ref()));
4301        self
4302    }
4303    /// Identifies the authorization scope(s) for the method you are building.
4304    ///
4305    /// See [`Self::add_scope()`] for details.
4306    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskListCall<'a, C>
4307    where
4308        I: IntoIterator<Item = St>,
4309        St: AsRef<str>,
4310    {
4311        self._scopes
4312            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4313        self
4314    }
4315
4316    /// Removes all scopes, and no default scope will be used either.
4317    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4318    /// for details).
4319    pub fn clear_scopes(mut self) -> TaskListCall<'a, C> {
4320        self._scopes.clear();
4321        self
4322    }
4323}
4324
4325/// Moves the specified task to another position in the destination task list. If the destination list is not specified, the task is moved within its current list. This can include putting it as a child task under a new parent and/or move it to a different position among its sibling tasks. A user can have up to 2,000 subtasks per task.
4326///
4327/// A builder for the *move* method supported by a *task* resource.
4328/// It is not used directly, but through a [`TaskMethods`] instance.
4329///
4330/// # Example
4331///
4332/// Instantiate a resource method builder
4333///
4334/// ```test_harness,no_run
4335/// # extern crate hyper;
4336/// # extern crate hyper_rustls;
4337/// # extern crate google_tasks1 as tasks1;
4338/// # async fn dox() {
4339/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4340///
4341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4342/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4343/// #     .with_native_roots()
4344/// #     .unwrap()
4345/// #     .https_only()
4346/// #     .enable_http2()
4347/// #     .build();
4348///
4349/// # let executor = hyper_util::rt::TokioExecutor::new();
4350/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4351/// #     secret,
4352/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4353/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4354/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4355/// #     ),
4356/// # ).build().await.unwrap();
4357///
4358/// # let client = hyper_util::client::legacy::Client::builder(
4359/// #     hyper_util::rt::TokioExecutor::new()
4360/// # )
4361/// # .build(
4362/// #     hyper_rustls::HttpsConnectorBuilder::new()
4363/// #         .with_native_roots()
4364/// #         .unwrap()
4365/// #         .https_or_http()
4366/// #         .enable_http2()
4367/// #         .build()
4368/// # );
4369/// # let mut hub = TasksHub::new(client, auth);
4370/// // You can configure optional parameters by calling the respective setters at will, and
4371/// // execute the final call using `doit()`.
4372/// // Values shown here are possibly random and not representative !
4373/// let result = hub.tasks().move_("tasklist", "task")
4374///              .previous("accusam")
4375///              .parent("takimata")
4376///              .destination_tasklist("consetetur")
4377///              .doit().await;
4378/// # }
4379/// ```
4380pub struct TaskMoveCall<'a, C>
4381where
4382    C: 'a,
4383{
4384    hub: &'a TasksHub<C>,
4385    _tasklist: String,
4386    _task: String,
4387    _previous: Option<String>,
4388    _parent: Option<String>,
4389    _destination_tasklist: Option<String>,
4390    _delegate: Option<&'a mut dyn common::Delegate>,
4391    _additional_params: HashMap<String, String>,
4392    _scopes: BTreeSet<String>,
4393}
4394
4395impl<'a, C> common::CallBuilder for TaskMoveCall<'a, C> {}
4396
4397impl<'a, C> TaskMoveCall<'a, C>
4398where
4399    C: common::Connector,
4400{
4401    /// Perform the operation you have build so far.
4402    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
4403        use std::borrow::Cow;
4404        use std::io::{Read, Seek};
4405
4406        use common::{url::Params, ToParts};
4407        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4408
4409        let mut dd = common::DefaultDelegate;
4410        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4411        dlg.begin(common::MethodInfo {
4412            id: "tasks.tasks.move",
4413            http_method: hyper::Method::POST,
4414        });
4415
4416        for &field in [
4417            "alt",
4418            "tasklist",
4419            "task",
4420            "previous",
4421            "parent",
4422            "destinationTasklist",
4423        ]
4424        .iter()
4425        {
4426            if self._additional_params.contains_key(field) {
4427                dlg.finished(false);
4428                return Err(common::Error::FieldClash(field));
4429            }
4430        }
4431
4432        let mut params = Params::with_capacity(7 + self._additional_params.len());
4433        params.push("tasklist", self._tasklist);
4434        params.push("task", self._task);
4435        if let Some(value) = self._previous.as_ref() {
4436            params.push("previous", value);
4437        }
4438        if let Some(value) = self._parent.as_ref() {
4439            params.push("parent", value);
4440        }
4441        if let Some(value) = self._destination_tasklist.as_ref() {
4442            params.push("destinationTasklist", value);
4443        }
4444
4445        params.extend(self._additional_params.iter());
4446
4447        params.push("alt", "json");
4448        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks/{task}/move";
4449        if self._scopes.is_empty() {
4450            self._scopes.insert(Scope::Full.as_ref().to_string());
4451        }
4452
4453        #[allow(clippy::single_element_loop)]
4454        for &(find_this, param_name) in [("{tasklist}", "tasklist"), ("{task}", "task")].iter() {
4455            url = params.uri_replacement(url, param_name, find_this, false);
4456        }
4457        {
4458            let to_remove = ["task", "tasklist"];
4459            params.remove_params(&to_remove);
4460        }
4461
4462        let url = params.parse_with_url(&url);
4463
4464        loop {
4465            let token = match self
4466                .hub
4467                .auth
4468                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4469                .await
4470            {
4471                Ok(token) => token,
4472                Err(e) => match dlg.token(e) {
4473                    Ok(token) => token,
4474                    Err(e) => {
4475                        dlg.finished(false);
4476                        return Err(common::Error::MissingToken(e));
4477                    }
4478                },
4479            };
4480            let mut req_result = {
4481                let client = &self.hub.client;
4482                dlg.pre_request();
4483                let mut req_builder = hyper::Request::builder()
4484                    .method(hyper::Method::POST)
4485                    .uri(url.as_str())
4486                    .header(USER_AGENT, self.hub._user_agent.clone());
4487
4488                if let Some(token) = token.as_ref() {
4489                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4490                }
4491
4492                let request = req_builder
4493                    .header(CONTENT_LENGTH, 0_u64)
4494                    .body(common::to_body::<String>(None));
4495
4496                client.request(request.unwrap()).await
4497            };
4498
4499            match req_result {
4500                Err(err) => {
4501                    if let common::Retry::After(d) = dlg.http_error(&err) {
4502                        sleep(d).await;
4503                        continue;
4504                    }
4505                    dlg.finished(false);
4506                    return Err(common::Error::HttpError(err));
4507                }
4508                Ok(res) => {
4509                    let (mut parts, body) = res.into_parts();
4510                    let mut body = common::Body::new(body);
4511                    if !parts.status.is_success() {
4512                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4513                        let error = serde_json::from_str(&common::to_string(&bytes));
4514                        let response = common::to_response(parts, bytes.into());
4515
4516                        if let common::Retry::After(d) =
4517                            dlg.http_failure(&response, error.as_ref().ok())
4518                        {
4519                            sleep(d).await;
4520                            continue;
4521                        }
4522
4523                        dlg.finished(false);
4524
4525                        return Err(match error {
4526                            Ok(value) => common::Error::BadRequest(value),
4527                            _ => common::Error::Failure(response),
4528                        });
4529                    }
4530                    let response = {
4531                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4532                        let encoded = common::to_string(&bytes);
4533                        match serde_json::from_str(&encoded) {
4534                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4535                            Err(error) => {
4536                                dlg.response_json_decode_error(&encoded, &error);
4537                                return Err(common::Error::JsonDecodeError(
4538                                    encoded.to_string(),
4539                                    error,
4540                                ));
4541                            }
4542                        }
4543                    };
4544
4545                    dlg.finished(true);
4546                    return Ok(response);
4547                }
4548            }
4549        }
4550    }
4551
4552    /// Task list identifier.
4553    ///
4554    /// Sets the *tasklist* path property to the given value.
4555    ///
4556    /// Even though the property as already been set when instantiating this call,
4557    /// we provide this method for API completeness.
4558    pub fn tasklist(mut self, new_value: &str) -> TaskMoveCall<'a, C> {
4559        self._tasklist = new_value.to_string();
4560        self
4561    }
4562    /// Task identifier.
4563    ///
4564    /// Sets the *task* path property to the given value.
4565    ///
4566    /// Even though the property as already been set when instantiating this call,
4567    /// we provide this method for API completeness.
4568    pub fn task(mut self, new_value: &str) -> TaskMoveCall<'a, C> {
4569        self._task = new_value.to_string();
4570        self
4571    }
4572    /// Optional. New previous sibling task identifier. If the task is moved to the first position among its siblings, this parameter is omitted. The task set as previous must exist in the task list and can not be hidden. Exceptions: 1. Tasks that are both completed and hidden can only be moved to position 0, so the previous field must be empty.
4573    ///
4574    /// Sets the *previous* query property to the given value.
4575    pub fn previous(mut self, new_value: &str) -> TaskMoveCall<'a, C> {
4576        self._previous = Some(new_value.to_string());
4577        self
4578    }
4579    /// Optional. New parent task identifier. If the task is moved to the top level, this parameter is omitted. The task set as parent must exist in the task list and can not be hidden. Exceptions: 1. Assigned and repeating tasks cannot be set as parent tasks (have subtasks), or be moved under a parent task (become subtasks). 2. Tasks that are both completed and hidden cannot be nested, so the parent field must be empty.
4580    ///
4581    /// Sets the *parent* query property to the given value.
4582    pub fn parent(mut self, new_value: &str) -> TaskMoveCall<'a, C> {
4583        self._parent = Some(new_value.to_string());
4584        self
4585    }
4586    /// Optional. Destination task list identifier. If set, the task is moved from tasklist to the destinationTasklist list. Otherwise the task is moved within its current list. Recurrent tasks cannot currently be moved between lists.
4587    ///
4588    /// Sets the *destination tasklist* query property to the given value.
4589    pub fn destination_tasklist(mut self, new_value: &str) -> TaskMoveCall<'a, C> {
4590        self._destination_tasklist = Some(new_value.to_string());
4591        self
4592    }
4593    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4594    /// while executing the actual API request.
4595    ///
4596    /// ````text
4597    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4598    /// ````
4599    ///
4600    /// Sets the *delegate* property to the given value.
4601    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskMoveCall<'a, C> {
4602        self._delegate = Some(new_value);
4603        self
4604    }
4605
4606    /// Set any additional parameter of the query string used in the request.
4607    /// It should be used to set parameters which are not yet available through their own
4608    /// setters.
4609    ///
4610    /// Please note that this method must not be used to set any of the known parameters
4611    /// which have their own setter method. If done anyway, the request will fail.
4612    ///
4613    /// # Additional Parameters
4614    ///
4615    /// * *$.xgafv* (query-string) - V1 error format.
4616    /// * *access_token* (query-string) - OAuth access token.
4617    /// * *alt* (query-string) - Data format for response.
4618    /// * *callback* (query-string) - JSONP
4619    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4620    /// * *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.
4621    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4622    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4623    /// * *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.
4624    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4625    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4626    pub fn param<T>(mut self, name: T, value: T) -> TaskMoveCall<'a, C>
4627    where
4628        T: AsRef<str>,
4629    {
4630        self._additional_params
4631            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4632        self
4633    }
4634
4635    /// Identifies the authorization scope for the method you are building.
4636    ///
4637    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4638    /// [`Scope::Full`].
4639    ///
4640    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4641    /// tokens for more than one scope.
4642    ///
4643    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4644    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4645    /// sufficient, a read-write scope will do as well.
4646    pub fn add_scope<St>(mut self, scope: St) -> TaskMoveCall<'a, C>
4647    where
4648        St: AsRef<str>,
4649    {
4650        self._scopes.insert(String::from(scope.as_ref()));
4651        self
4652    }
4653    /// Identifies the authorization scope(s) for the method you are building.
4654    ///
4655    /// See [`Self::add_scope()`] for details.
4656    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskMoveCall<'a, C>
4657    where
4658        I: IntoIterator<Item = St>,
4659        St: AsRef<str>,
4660    {
4661        self._scopes
4662            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4663        self
4664    }
4665
4666    /// Removes all scopes, and no default scope will be used either.
4667    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4668    /// for details).
4669    pub fn clear_scopes(mut self) -> TaskMoveCall<'a, C> {
4670        self._scopes.clear();
4671        self
4672    }
4673}
4674
4675/// Updates the specified task. This method supports patch semantics.
4676///
4677/// A builder for the *patch* method supported by a *task* resource.
4678/// It is not used directly, but through a [`TaskMethods`] instance.
4679///
4680/// # Example
4681///
4682/// Instantiate a resource method builder
4683///
4684/// ```test_harness,no_run
4685/// # extern crate hyper;
4686/// # extern crate hyper_rustls;
4687/// # extern crate google_tasks1 as tasks1;
4688/// use tasks1::api::Task;
4689/// # async fn dox() {
4690/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4691///
4692/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4693/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4694/// #     .with_native_roots()
4695/// #     .unwrap()
4696/// #     .https_only()
4697/// #     .enable_http2()
4698/// #     .build();
4699///
4700/// # let executor = hyper_util::rt::TokioExecutor::new();
4701/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4702/// #     secret,
4703/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4704/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4705/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4706/// #     ),
4707/// # ).build().await.unwrap();
4708///
4709/// # let client = hyper_util::client::legacy::Client::builder(
4710/// #     hyper_util::rt::TokioExecutor::new()
4711/// # )
4712/// # .build(
4713/// #     hyper_rustls::HttpsConnectorBuilder::new()
4714/// #         .with_native_roots()
4715/// #         .unwrap()
4716/// #         .https_or_http()
4717/// #         .enable_http2()
4718/// #         .build()
4719/// # );
4720/// # let mut hub = TasksHub::new(client, auth);
4721/// // As the method needs a request, you would usually fill it with the desired information
4722/// // into the respective structure. Some of the parts shown here might not be applicable !
4723/// // Values shown here are possibly random and not representative !
4724/// let mut req = Task::default();
4725///
4726/// // You can configure optional parameters by calling the respective setters at will, and
4727/// // execute the final call using `doit()`.
4728/// // Values shown here are possibly random and not representative !
4729/// let result = hub.tasks().patch(req, "tasklist", "task")
4730///              .doit().await;
4731/// # }
4732/// ```
4733pub struct TaskPatchCall<'a, C>
4734where
4735    C: 'a,
4736{
4737    hub: &'a TasksHub<C>,
4738    _request: Task,
4739    _tasklist: String,
4740    _task: String,
4741    _delegate: Option<&'a mut dyn common::Delegate>,
4742    _additional_params: HashMap<String, String>,
4743    _scopes: BTreeSet<String>,
4744}
4745
4746impl<'a, C> common::CallBuilder for TaskPatchCall<'a, C> {}
4747
4748impl<'a, C> TaskPatchCall<'a, C>
4749where
4750    C: common::Connector,
4751{
4752    /// Perform the operation you have build so far.
4753    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
4754        use std::borrow::Cow;
4755        use std::io::{Read, Seek};
4756
4757        use common::{url::Params, ToParts};
4758        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4759
4760        let mut dd = common::DefaultDelegate;
4761        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4762        dlg.begin(common::MethodInfo {
4763            id: "tasks.tasks.patch",
4764            http_method: hyper::Method::PATCH,
4765        });
4766
4767        for &field in ["alt", "tasklist", "task"].iter() {
4768            if self._additional_params.contains_key(field) {
4769                dlg.finished(false);
4770                return Err(common::Error::FieldClash(field));
4771            }
4772        }
4773
4774        let mut params = Params::with_capacity(5 + self._additional_params.len());
4775        params.push("tasklist", self._tasklist);
4776        params.push("task", self._task);
4777
4778        params.extend(self._additional_params.iter());
4779
4780        params.push("alt", "json");
4781        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks/{task}";
4782        if self._scopes.is_empty() {
4783            self._scopes.insert(Scope::Full.as_ref().to_string());
4784        }
4785
4786        #[allow(clippy::single_element_loop)]
4787        for &(find_this, param_name) in [("{tasklist}", "tasklist"), ("{task}", "task")].iter() {
4788            url = params.uri_replacement(url, param_name, find_this, false);
4789        }
4790        {
4791            let to_remove = ["task", "tasklist"];
4792            params.remove_params(&to_remove);
4793        }
4794
4795        let url = params.parse_with_url(&url);
4796
4797        let mut json_mime_type = mime::APPLICATION_JSON;
4798        let mut request_value_reader = {
4799            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4800            common::remove_json_null_values(&mut value);
4801            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4802            serde_json::to_writer(&mut dst, &value).unwrap();
4803            dst
4804        };
4805        let request_size = request_value_reader
4806            .seek(std::io::SeekFrom::End(0))
4807            .unwrap();
4808        request_value_reader
4809            .seek(std::io::SeekFrom::Start(0))
4810            .unwrap();
4811
4812        loop {
4813            let token = match self
4814                .hub
4815                .auth
4816                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4817                .await
4818            {
4819                Ok(token) => token,
4820                Err(e) => match dlg.token(e) {
4821                    Ok(token) => token,
4822                    Err(e) => {
4823                        dlg.finished(false);
4824                        return Err(common::Error::MissingToken(e));
4825                    }
4826                },
4827            };
4828            request_value_reader
4829                .seek(std::io::SeekFrom::Start(0))
4830                .unwrap();
4831            let mut req_result = {
4832                let client = &self.hub.client;
4833                dlg.pre_request();
4834                let mut req_builder = hyper::Request::builder()
4835                    .method(hyper::Method::PATCH)
4836                    .uri(url.as_str())
4837                    .header(USER_AGENT, self.hub._user_agent.clone());
4838
4839                if let Some(token) = token.as_ref() {
4840                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4841                }
4842
4843                let request = req_builder
4844                    .header(CONTENT_TYPE, json_mime_type.to_string())
4845                    .header(CONTENT_LENGTH, request_size as u64)
4846                    .body(common::to_body(
4847                        request_value_reader.get_ref().clone().into(),
4848                    ));
4849
4850                client.request(request.unwrap()).await
4851            };
4852
4853            match req_result {
4854                Err(err) => {
4855                    if let common::Retry::After(d) = dlg.http_error(&err) {
4856                        sleep(d).await;
4857                        continue;
4858                    }
4859                    dlg.finished(false);
4860                    return Err(common::Error::HttpError(err));
4861                }
4862                Ok(res) => {
4863                    let (mut parts, body) = res.into_parts();
4864                    let mut body = common::Body::new(body);
4865                    if !parts.status.is_success() {
4866                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4867                        let error = serde_json::from_str(&common::to_string(&bytes));
4868                        let response = common::to_response(parts, bytes.into());
4869
4870                        if let common::Retry::After(d) =
4871                            dlg.http_failure(&response, error.as_ref().ok())
4872                        {
4873                            sleep(d).await;
4874                            continue;
4875                        }
4876
4877                        dlg.finished(false);
4878
4879                        return Err(match error {
4880                            Ok(value) => common::Error::BadRequest(value),
4881                            _ => common::Error::Failure(response),
4882                        });
4883                    }
4884                    let response = {
4885                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4886                        let encoded = common::to_string(&bytes);
4887                        match serde_json::from_str(&encoded) {
4888                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4889                            Err(error) => {
4890                                dlg.response_json_decode_error(&encoded, &error);
4891                                return Err(common::Error::JsonDecodeError(
4892                                    encoded.to_string(),
4893                                    error,
4894                                ));
4895                            }
4896                        }
4897                    };
4898
4899                    dlg.finished(true);
4900                    return Ok(response);
4901                }
4902            }
4903        }
4904    }
4905
4906    ///
4907    /// Sets the *request* property to the given value.
4908    ///
4909    /// Even though the property as already been set when instantiating this call,
4910    /// we provide this method for API completeness.
4911    pub fn request(mut self, new_value: Task) -> TaskPatchCall<'a, C> {
4912        self._request = new_value;
4913        self
4914    }
4915    /// Task list identifier.
4916    ///
4917    /// Sets the *tasklist* path property to the given value.
4918    ///
4919    /// Even though the property as already been set when instantiating this call,
4920    /// we provide this method for API completeness.
4921    pub fn tasklist(mut self, new_value: &str) -> TaskPatchCall<'a, C> {
4922        self._tasklist = new_value.to_string();
4923        self
4924    }
4925    /// Task identifier.
4926    ///
4927    /// Sets the *task* path property to the given value.
4928    ///
4929    /// Even though the property as already been set when instantiating this call,
4930    /// we provide this method for API completeness.
4931    pub fn task(mut self, new_value: &str) -> TaskPatchCall<'a, C> {
4932        self._task = new_value.to_string();
4933        self
4934    }
4935    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4936    /// while executing the actual API request.
4937    ///
4938    /// ````text
4939    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4940    /// ````
4941    ///
4942    /// Sets the *delegate* property to the given value.
4943    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskPatchCall<'a, C> {
4944        self._delegate = Some(new_value);
4945        self
4946    }
4947
4948    /// Set any additional parameter of the query string used in the request.
4949    /// It should be used to set parameters which are not yet available through their own
4950    /// setters.
4951    ///
4952    /// Please note that this method must not be used to set any of the known parameters
4953    /// which have their own setter method. If done anyway, the request will fail.
4954    ///
4955    /// # Additional Parameters
4956    ///
4957    /// * *$.xgafv* (query-string) - V1 error format.
4958    /// * *access_token* (query-string) - OAuth access token.
4959    /// * *alt* (query-string) - Data format for response.
4960    /// * *callback* (query-string) - JSONP
4961    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4962    /// * *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.
4963    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4964    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4965    /// * *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.
4966    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4967    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4968    pub fn param<T>(mut self, name: T, value: T) -> TaskPatchCall<'a, C>
4969    where
4970        T: AsRef<str>,
4971    {
4972        self._additional_params
4973            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4974        self
4975    }
4976
4977    /// Identifies the authorization scope for the method you are building.
4978    ///
4979    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4980    /// [`Scope::Full`].
4981    ///
4982    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4983    /// tokens for more than one scope.
4984    ///
4985    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4986    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4987    /// sufficient, a read-write scope will do as well.
4988    pub fn add_scope<St>(mut self, scope: St) -> TaskPatchCall<'a, C>
4989    where
4990        St: AsRef<str>,
4991    {
4992        self._scopes.insert(String::from(scope.as_ref()));
4993        self
4994    }
4995    /// Identifies the authorization scope(s) for the method you are building.
4996    ///
4997    /// See [`Self::add_scope()`] for details.
4998    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskPatchCall<'a, C>
4999    where
5000        I: IntoIterator<Item = St>,
5001        St: AsRef<str>,
5002    {
5003        self._scopes
5004            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5005        self
5006    }
5007
5008    /// Removes all scopes, and no default scope will be used either.
5009    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5010    /// for details).
5011    pub fn clear_scopes(mut self) -> TaskPatchCall<'a, C> {
5012        self._scopes.clear();
5013        self
5014    }
5015}
5016
5017/// Updates the specified task.
5018///
5019/// A builder for the *update* method supported by a *task* resource.
5020/// It is not used directly, but through a [`TaskMethods`] instance.
5021///
5022/// # Example
5023///
5024/// Instantiate a resource method builder
5025///
5026/// ```test_harness,no_run
5027/// # extern crate hyper;
5028/// # extern crate hyper_rustls;
5029/// # extern crate google_tasks1 as tasks1;
5030/// use tasks1::api::Task;
5031/// # async fn dox() {
5032/// # use tasks1::{TasksHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5033///
5034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5035/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5036/// #     .with_native_roots()
5037/// #     .unwrap()
5038/// #     .https_only()
5039/// #     .enable_http2()
5040/// #     .build();
5041///
5042/// # let executor = hyper_util::rt::TokioExecutor::new();
5043/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5044/// #     secret,
5045/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5046/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5047/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5048/// #     ),
5049/// # ).build().await.unwrap();
5050///
5051/// # let client = hyper_util::client::legacy::Client::builder(
5052/// #     hyper_util::rt::TokioExecutor::new()
5053/// # )
5054/// # .build(
5055/// #     hyper_rustls::HttpsConnectorBuilder::new()
5056/// #         .with_native_roots()
5057/// #         .unwrap()
5058/// #         .https_or_http()
5059/// #         .enable_http2()
5060/// #         .build()
5061/// # );
5062/// # let mut hub = TasksHub::new(client, auth);
5063/// // As the method needs a request, you would usually fill it with the desired information
5064/// // into the respective structure. Some of the parts shown here might not be applicable !
5065/// // Values shown here are possibly random and not representative !
5066/// let mut req = Task::default();
5067///
5068/// // You can configure optional parameters by calling the respective setters at will, and
5069/// // execute the final call using `doit()`.
5070/// // Values shown here are possibly random and not representative !
5071/// let result = hub.tasks().update(req, "tasklist", "task")
5072///              .doit().await;
5073/// # }
5074/// ```
5075pub struct TaskUpdateCall<'a, C>
5076where
5077    C: 'a,
5078{
5079    hub: &'a TasksHub<C>,
5080    _request: Task,
5081    _tasklist: String,
5082    _task: String,
5083    _delegate: Option<&'a mut dyn common::Delegate>,
5084    _additional_params: HashMap<String, String>,
5085    _scopes: BTreeSet<String>,
5086}
5087
5088impl<'a, C> common::CallBuilder for TaskUpdateCall<'a, C> {}
5089
5090impl<'a, C> TaskUpdateCall<'a, C>
5091where
5092    C: common::Connector,
5093{
5094    /// Perform the operation you have build so far.
5095    pub async fn doit(mut self) -> common::Result<(common::Response, Task)> {
5096        use std::borrow::Cow;
5097        use std::io::{Read, Seek};
5098
5099        use common::{url::Params, ToParts};
5100        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5101
5102        let mut dd = common::DefaultDelegate;
5103        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5104        dlg.begin(common::MethodInfo {
5105            id: "tasks.tasks.update",
5106            http_method: hyper::Method::PUT,
5107        });
5108
5109        for &field in ["alt", "tasklist", "task"].iter() {
5110            if self._additional_params.contains_key(field) {
5111                dlg.finished(false);
5112                return Err(common::Error::FieldClash(field));
5113            }
5114        }
5115
5116        let mut params = Params::with_capacity(5 + self._additional_params.len());
5117        params.push("tasklist", self._tasklist);
5118        params.push("task", self._task);
5119
5120        params.extend(self._additional_params.iter());
5121
5122        params.push("alt", "json");
5123        let mut url = self.hub._base_url.clone() + "tasks/v1/lists/{tasklist}/tasks/{task}";
5124        if self._scopes.is_empty() {
5125            self._scopes.insert(Scope::Full.as_ref().to_string());
5126        }
5127
5128        #[allow(clippy::single_element_loop)]
5129        for &(find_this, param_name) in [("{tasklist}", "tasklist"), ("{task}", "task")].iter() {
5130            url = params.uri_replacement(url, param_name, find_this, false);
5131        }
5132        {
5133            let to_remove = ["task", "tasklist"];
5134            params.remove_params(&to_remove);
5135        }
5136
5137        let url = params.parse_with_url(&url);
5138
5139        let mut json_mime_type = mime::APPLICATION_JSON;
5140        let mut request_value_reader = {
5141            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5142            common::remove_json_null_values(&mut value);
5143            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5144            serde_json::to_writer(&mut dst, &value).unwrap();
5145            dst
5146        };
5147        let request_size = request_value_reader
5148            .seek(std::io::SeekFrom::End(0))
5149            .unwrap();
5150        request_value_reader
5151            .seek(std::io::SeekFrom::Start(0))
5152            .unwrap();
5153
5154        loop {
5155            let token = match self
5156                .hub
5157                .auth
5158                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5159                .await
5160            {
5161                Ok(token) => token,
5162                Err(e) => match dlg.token(e) {
5163                    Ok(token) => token,
5164                    Err(e) => {
5165                        dlg.finished(false);
5166                        return Err(common::Error::MissingToken(e));
5167                    }
5168                },
5169            };
5170            request_value_reader
5171                .seek(std::io::SeekFrom::Start(0))
5172                .unwrap();
5173            let mut req_result = {
5174                let client = &self.hub.client;
5175                dlg.pre_request();
5176                let mut req_builder = hyper::Request::builder()
5177                    .method(hyper::Method::PUT)
5178                    .uri(url.as_str())
5179                    .header(USER_AGENT, self.hub._user_agent.clone());
5180
5181                if let Some(token) = token.as_ref() {
5182                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5183                }
5184
5185                let request = req_builder
5186                    .header(CONTENT_TYPE, json_mime_type.to_string())
5187                    .header(CONTENT_LENGTH, request_size as u64)
5188                    .body(common::to_body(
5189                        request_value_reader.get_ref().clone().into(),
5190                    ));
5191
5192                client.request(request.unwrap()).await
5193            };
5194
5195            match req_result {
5196                Err(err) => {
5197                    if let common::Retry::After(d) = dlg.http_error(&err) {
5198                        sleep(d).await;
5199                        continue;
5200                    }
5201                    dlg.finished(false);
5202                    return Err(common::Error::HttpError(err));
5203                }
5204                Ok(res) => {
5205                    let (mut parts, body) = res.into_parts();
5206                    let mut body = common::Body::new(body);
5207                    if !parts.status.is_success() {
5208                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5209                        let error = serde_json::from_str(&common::to_string(&bytes));
5210                        let response = common::to_response(parts, bytes.into());
5211
5212                        if let common::Retry::After(d) =
5213                            dlg.http_failure(&response, error.as_ref().ok())
5214                        {
5215                            sleep(d).await;
5216                            continue;
5217                        }
5218
5219                        dlg.finished(false);
5220
5221                        return Err(match error {
5222                            Ok(value) => common::Error::BadRequest(value),
5223                            _ => common::Error::Failure(response),
5224                        });
5225                    }
5226                    let response = {
5227                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5228                        let encoded = common::to_string(&bytes);
5229                        match serde_json::from_str(&encoded) {
5230                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5231                            Err(error) => {
5232                                dlg.response_json_decode_error(&encoded, &error);
5233                                return Err(common::Error::JsonDecodeError(
5234                                    encoded.to_string(),
5235                                    error,
5236                                ));
5237                            }
5238                        }
5239                    };
5240
5241                    dlg.finished(true);
5242                    return Ok(response);
5243                }
5244            }
5245        }
5246    }
5247
5248    ///
5249    /// Sets the *request* property to the given value.
5250    ///
5251    /// Even though the property as already been set when instantiating this call,
5252    /// we provide this method for API completeness.
5253    pub fn request(mut self, new_value: Task) -> TaskUpdateCall<'a, C> {
5254        self._request = new_value;
5255        self
5256    }
5257    /// Task list identifier.
5258    ///
5259    /// Sets the *tasklist* path property to the given value.
5260    ///
5261    /// Even though the property as already been set when instantiating this call,
5262    /// we provide this method for API completeness.
5263    pub fn tasklist(mut self, new_value: &str) -> TaskUpdateCall<'a, C> {
5264        self._tasklist = new_value.to_string();
5265        self
5266    }
5267    /// Task identifier.
5268    ///
5269    /// Sets the *task* path property to the given value.
5270    ///
5271    /// Even though the property as already been set when instantiating this call,
5272    /// we provide this method for API completeness.
5273    pub fn task(mut self, new_value: &str) -> TaskUpdateCall<'a, C> {
5274        self._task = new_value.to_string();
5275        self
5276    }
5277    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5278    /// while executing the actual API request.
5279    ///
5280    /// ````text
5281    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5282    /// ````
5283    ///
5284    /// Sets the *delegate* property to the given value.
5285    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TaskUpdateCall<'a, C> {
5286        self._delegate = Some(new_value);
5287        self
5288    }
5289
5290    /// Set any additional parameter of the query string used in the request.
5291    /// It should be used to set parameters which are not yet available through their own
5292    /// setters.
5293    ///
5294    /// Please note that this method must not be used to set any of the known parameters
5295    /// which have their own setter method. If done anyway, the request will fail.
5296    ///
5297    /// # Additional Parameters
5298    ///
5299    /// * *$.xgafv* (query-string) - V1 error format.
5300    /// * *access_token* (query-string) - OAuth access token.
5301    /// * *alt* (query-string) - Data format for response.
5302    /// * *callback* (query-string) - JSONP
5303    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5304    /// * *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.
5305    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5306    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5307    /// * *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.
5308    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5309    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5310    pub fn param<T>(mut self, name: T, value: T) -> TaskUpdateCall<'a, C>
5311    where
5312        T: AsRef<str>,
5313    {
5314        self._additional_params
5315            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5316        self
5317    }
5318
5319    /// Identifies the authorization scope for the method you are building.
5320    ///
5321    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5322    /// [`Scope::Full`].
5323    ///
5324    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5325    /// tokens for more than one scope.
5326    ///
5327    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5328    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5329    /// sufficient, a read-write scope will do as well.
5330    pub fn add_scope<St>(mut self, scope: St) -> TaskUpdateCall<'a, C>
5331    where
5332        St: AsRef<str>,
5333    {
5334        self._scopes.insert(String::from(scope.as_ref()));
5335        self
5336    }
5337    /// Identifies the authorization scope(s) for the method you are building.
5338    ///
5339    /// See [`Self::add_scope()`] for details.
5340    pub fn add_scopes<I, St>(mut self, scopes: I) -> TaskUpdateCall<'a, C>
5341    where
5342        I: IntoIterator<Item = St>,
5343        St: AsRef<str>,
5344    {
5345        self._scopes
5346            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5347        self
5348    }
5349
5350    /// Removes all scopes, and no default scope will be used either.
5351    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5352    /// for details).
5353    pub fn clear_scopes(mut self) -> TaskUpdateCall<'a, C> {
5354        self._scopes.clear();
5355        self
5356    }
5357}