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