google_keep1/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 /// See, edit, create and permanently delete all your Google Keep data
17 Full,
18
19 /// View all your Google Keep data
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/keep",
27 Scope::Readonly => "https://www.googleapis.com/auth/keep.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 Keep 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_keep1 as keep1;
53/// use keep1::{Result, Error};
54/// # async fn dox() {
55/// use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
56///
57/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
58/// // `client_secret`, among other things.
59/// let secret: yup_oauth2::ApplicationSecret = Default::default();
60/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
61/// // unless you replace `None` with the desired Flow.
62/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
63/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
64/// // retrieve them from storage.
65/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
66/// .with_native_roots()
67/// .unwrap()
68/// .https_only()
69/// .enable_http2()
70/// .build();
71///
72/// let executor = hyper_util::rt::TokioExecutor::new();
73/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
74/// secret,
75/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
76/// yup_oauth2::client::CustomHyperClientBuilder::from(
77/// hyper_util::client::legacy::Client::builder(executor).build(connector),
78/// ),
79/// ).build().await.unwrap();
80///
81/// let client = hyper_util::client::legacy::Client::builder(
82/// hyper_util::rt::TokioExecutor::new()
83/// )
84/// .build(
85/// hyper_rustls::HttpsConnectorBuilder::new()
86/// .with_native_roots()
87/// .unwrap()
88/// .https_or_http()
89/// .enable_http2()
90/// .build()
91/// );
92/// let mut hub = Keep::new(client, auth);
93/// // You can configure optional parameters by calling the respective setters at will, and
94/// // execute the final call using `doit()`.
95/// // Values shown here are possibly random and not representative !
96/// let result = hub.notes().list()
97/// .page_token("sanctus")
98/// .page_size(-80)
99/// .filter("amet.")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Keep<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for Keep<C> {}
131
132impl<'a, C> Keep<C> {
133 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Keep<C> {
134 Keep {
135 client,
136 auth: Box::new(auth),
137 _user_agent: "google-api-rust-client/7.0.0".to_string(),
138 _base_url: "https://keep.googleapis.com/".to_string(),
139 _root_url: "https://keep.googleapis.com/".to_string(),
140 }
141 }
142
143 pub fn media(&'a self) -> MediaMethods<'a, C> {
144 MediaMethods { hub: self }
145 }
146 pub fn notes(&'a self) -> NoteMethods<'a, C> {
147 NoteMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://keep.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://keep.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// An attachment to a note.
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [download media](MediaDownloadCall) (response)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct Attachment {
190 /// The MIME types (IANA media types) in which the attachment is available.
191 #[serde(rename = "mimeType")]
192 pub mime_type: Option<Vec<String>>,
193 /// The resource name;
194 pub name: Option<String>,
195}
196
197impl common::ResponseResult for Attachment {}
198
199/// The request to add one or more permissions on the note. Currently, only the `WRITER` role may be specified. If adding a permission fails, then the entire request fails and no changes are made.
200///
201/// # Activities
202///
203/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
204/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
205///
206/// * [permissions batch create notes](NotePermissionBatchCreateCall) (request)
207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
208#[serde_with::serde_as]
209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
210pub struct BatchCreatePermissionsRequest {
211 /// The request message specifying the resources to create.
212 pub requests: Option<Vec<CreatePermissionRequest>>,
213}
214
215impl common::RequestValue for BatchCreatePermissionsRequest {}
216
217/// The response for creating permissions on a note.
218///
219/// # Activities
220///
221/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
222/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
223///
224/// * [permissions batch create notes](NotePermissionBatchCreateCall) (response)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct BatchCreatePermissionsResponse {
229 /// Permissions created.
230 pub permissions: Option<Vec<Permission>>,
231}
232
233impl common::ResponseResult for BatchCreatePermissionsResponse {}
234
235/// The request to remove one or more permissions from a note. A permission with the `OWNER` role can’t be removed. If removing a permission fails, then the entire request fails and no changes are made. Returns a 400 bad request error if a specified permission does not exist on the note.
236///
237/// # Activities
238///
239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
241///
242/// * [permissions batch delete notes](NotePermissionBatchDeleteCall) (request)
243#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
244#[serde_with::serde_as]
245#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
246pub struct BatchDeletePermissionsRequest {
247 /// Required. The names of the permissions to delete. Format: `notes/{note}/permissions/{permission}`
248 pub names: Option<Vec<String>>,
249}
250
251impl common::RequestValue for BatchDeletePermissionsRequest {}
252
253/// The request to add a single permission on the note.
254///
255/// This type is not used in any activity, and only used as *part* of another schema.
256///
257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
258#[serde_with::serde_as]
259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
260pub struct CreatePermissionRequest {
261 /// Required. The parent note where this permission will be created. Format: `notes/{note}`
262 pub parent: Option<String>,
263 /// Required. The permission to create. One of Permission.email, User.email or Group.email must be supplied.
264 pub permission: Option<Permission>,
265}
266
267impl common::Part for CreatePermissionRequest {}
268
269/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
270///
271/// # Activities
272///
273/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
274/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
275///
276/// * [permissions batch delete notes](NotePermissionBatchDeleteCall) (response)
277/// * [delete notes](NoteDeleteCall) (response)
278#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
279#[serde_with::serde_as]
280#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
281pub struct Empty {
282 _never_set: Option<bool>,
283}
284
285impl common::ResponseResult for Empty {}
286
287/// Describes a single Google Family.
288///
289/// This type is not used in any activity, and only used as *part* of another schema.
290///
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct Family {
295 _never_set: Option<bool>,
296}
297
298impl common::Part for Family {}
299
300/// Describes a single Group.
301///
302/// This type is not used in any activity, and only used as *part* of another schema.
303///
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct Group {
308 /// The group email.
309 pub email: Option<String>,
310}
311
312impl common::Part for Group {}
313
314/// The list of items for a single list note.
315///
316/// This type is not used in any activity, and only used as *part* of another schema.
317///
318#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
319#[serde_with::serde_as]
320#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
321pub struct ListContent {
322 /// The items in the list. The number of items must be less than 1,000.
323 #[serde(rename = "listItems")]
324 pub list_items: Option<Vec<ListItem>>,
325}
326
327impl common::Part for ListContent {}
328
329/// A single list item in a note's list.
330///
331/// This type is not used in any activity, and only used as *part* of another schema.
332///
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct ListItem {
337 /// Whether this item has been checked off or not.
338 pub checked: Option<bool>,
339 /// If set, list of list items nested under this list item. Only one level of nesting is allowed.
340 #[serde(rename = "childListItems")]
341 pub child_list_items: Option<Vec<ListItem>>,
342 /// The text of this item. Length must be less than 1,000 characters.
343 pub text: Option<TextContent>,
344}
345
346impl common::Part for ListItem {}
347
348/// The response when listing a page of notes.
349///
350/// # Activities
351///
352/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
353/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
354///
355/// * [list notes](NoteListCall) (response)
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct ListNotesResponse {
360 /// Next page's `page_token` field.
361 #[serde(rename = "nextPageToken")]
362 pub next_page_token: Option<String>,
363 /// A page of notes.
364 pub notes: Option<Vec<Note>>,
365}
366
367impl common::ResponseResult for ListNotesResponse {}
368
369/// A single note.
370///
371/// # Activities
372///
373/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
374/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
375///
376/// * [permissions batch create notes](NotePermissionBatchCreateCall) (none)
377/// * [permissions batch delete notes](NotePermissionBatchDeleteCall) (none)
378/// * [create notes](NoteCreateCall) (request|response)
379/// * [delete notes](NoteDeleteCall) (none)
380/// * [get notes](NoteGetCall) (response)
381/// * [list notes](NoteListCall) (none)
382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
383#[serde_with::serde_as]
384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
385pub struct Note {
386 /// Output only. The attachments attached to this note.
387 pub attachments: Option<Vec<Attachment>>,
388 /// The body of the note.
389 pub body: Option<Section>,
390 /// Output only. When this note was created.
391 #[serde(rename = "createTime")]
392 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
393 /// Output only. The resource name of this note. See general note on identifiers in KeepService.
394 pub name: Option<String>,
395 /// Output only. The list of permissions set on the note. Contains at least one entry for the note owner.
396 pub permissions: Option<Vec<Permission>>,
397 /// The title of the note. Length must be less than 1,000 characters.
398 pub title: Option<String>,
399 /// Output only. When this note was trashed. If `trashed`, the note is eventually deleted. If the note is not trashed, this field is not set (and the trashed field is `false`).
400 #[serde(rename = "trashTime")]
401 pub trash_time: Option<chrono::DateTime<chrono::offset::Utc>>,
402 /// Output only. `true` if this note has been trashed. If trashed, the note is eventually deleted.
403 pub trashed: Option<bool>,
404 /// Output only. When this note was last modified.
405 #[serde(rename = "updateTime")]
406 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
407}
408
409impl common::RequestValue for Note {}
410impl common::Resource for Note {}
411impl common::ResponseResult for Note {}
412
413/// A single permission on the note. Associates a `member` with a `role`.
414///
415/// This type is not used in any activity, and only used as *part* of another schema.
416///
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct Permission {
421 /// Output only. Whether this member has been deleted. If the member is recovered, this value is set to false and the recovered member retains the role on the note.
422 pub deleted: Option<bool>,
423 /// The email associated with the member. If set on create, the `email` field in the `User` or `Group` message must either be empty or match this field. On read, may be unset if the member does not have an associated email.
424 pub email: Option<String>,
425 /// Output only. The Google Family to which this role applies.
426 pub family: Option<Family>,
427 /// Output only. The group to which this role applies.
428 pub group: Option<Group>,
429 /// Output only. The resource name.
430 pub name: Option<String>,
431 /// The role granted by this permission. The role determines the entity’s ability to read, write, and share notes.
432 pub role: Option<String>,
433 /// Output only. The user to whom this role applies.
434 pub user: Option<User>,
435}
436
437impl common::Part for Permission {}
438
439/// The content of the note.
440///
441/// This type is not used in any activity, and only used as *part* of another schema.
442///
443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
444#[serde_with::serde_as]
445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
446pub struct Section {
447 /// Used if this section's content is a list.
448 pub list: Option<ListContent>,
449 /// Used if this section's content is a block of text. The length of the text content must be less than 20,000 characters.
450 pub text: Option<TextContent>,
451}
452
453impl common::Part for Section {}
454
455/// The block of text for a single text section or list item.
456///
457/// This type is not used in any activity, and only used as *part* of another schema.
458///
459#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
460#[serde_with::serde_as]
461#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
462pub struct TextContent {
463 /// The text of the note. The limits on this vary with the specific field using this type.
464 pub text: Option<String>,
465}
466
467impl common::Part for TextContent {}
468
469/// Describes a single user.
470///
471/// This type is not used in any activity, and only used as *part* of another schema.
472///
473#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
474#[serde_with::serde_as]
475#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
476pub struct User {
477 /// The user's email.
478 pub email: Option<String>,
479}
480
481impl common::Part for User {}
482
483// ###################
484// MethodBuilders ###
485// #################
486
487/// A builder providing access to all methods supported on *media* resources.
488/// It is not used directly, but through the [`Keep`] hub.
489///
490/// # Example
491///
492/// Instantiate a resource builder
493///
494/// ```test_harness,no_run
495/// extern crate hyper;
496/// extern crate hyper_rustls;
497/// extern crate google_keep1 as keep1;
498///
499/// # async fn dox() {
500/// use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
501///
502/// let secret: yup_oauth2::ApplicationSecret = Default::default();
503/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
504/// .with_native_roots()
505/// .unwrap()
506/// .https_only()
507/// .enable_http2()
508/// .build();
509///
510/// let executor = hyper_util::rt::TokioExecutor::new();
511/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
512/// secret,
513/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
514/// yup_oauth2::client::CustomHyperClientBuilder::from(
515/// hyper_util::client::legacy::Client::builder(executor).build(connector),
516/// ),
517/// ).build().await.unwrap();
518///
519/// let client = hyper_util::client::legacy::Client::builder(
520/// hyper_util::rt::TokioExecutor::new()
521/// )
522/// .build(
523/// hyper_rustls::HttpsConnectorBuilder::new()
524/// .with_native_roots()
525/// .unwrap()
526/// .https_or_http()
527/// .enable_http2()
528/// .build()
529/// );
530/// let mut hub = Keep::new(client, auth);
531/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
532/// // like `download(...)`
533/// // to build up your call.
534/// let rb = hub.media();
535/// # }
536/// ```
537pub struct MediaMethods<'a, C>
538where
539 C: 'a,
540{
541 hub: &'a Keep<C>,
542}
543
544impl<'a, C> common::MethodsBuilder for MediaMethods<'a, C> {}
545
546impl<'a, C> MediaMethods<'a, C> {
547 /// Create a builder to help you perform the following task:
548 ///
549 /// Gets an attachment. To download attachment media via REST requires the alt=media query parameter. Returns a 400 bad request error if attachment media is not available in the requested MIME type.
550 ///
551 /// # Arguments
552 ///
553 /// * `name` - Required. The name of the attachment.
554 pub fn download(&self, name: &str) -> MediaDownloadCall<'a, C> {
555 MediaDownloadCall {
556 hub: self.hub,
557 _name: name.to_string(),
558 _mime_type: Default::default(),
559 _delegate: Default::default(),
560 _additional_params: Default::default(),
561 _scopes: Default::default(),
562 }
563 }
564}
565
566/// A builder providing access to all methods supported on *note* resources.
567/// It is not used directly, but through the [`Keep`] hub.
568///
569/// # Example
570///
571/// Instantiate a resource builder
572///
573/// ```test_harness,no_run
574/// extern crate hyper;
575/// extern crate hyper_rustls;
576/// extern crate google_keep1 as keep1;
577///
578/// # async fn dox() {
579/// use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
580///
581/// let secret: yup_oauth2::ApplicationSecret = Default::default();
582/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
583/// .with_native_roots()
584/// .unwrap()
585/// .https_only()
586/// .enable_http2()
587/// .build();
588///
589/// let executor = hyper_util::rt::TokioExecutor::new();
590/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
591/// secret,
592/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
593/// yup_oauth2::client::CustomHyperClientBuilder::from(
594/// hyper_util::client::legacy::Client::builder(executor).build(connector),
595/// ),
596/// ).build().await.unwrap();
597///
598/// let client = hyper_util::client::legacy::Client::builder(
599/// hyper_util::rt::TokioExecutor::new()
600/// )
601/// .build(
602/// hyper_rustls::HttpsConnectorBuilder::new()
603/// .with_native_roots()
604/// .unwrap()
605/// .https_or_http()
606/// .enable_http2()
607/// .build()
608/// );
609/// let mut hub = Keep::new(client, auth);
610/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
611/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `permissions_batch_create(...)` and `permissions_batch_delete(...)`
612/// // to build up your call.
613/// let rb = hub.notes();
614/// # }
615/// ```
616pub struct NoteMethods<'a, C>
617where
618 C: 'a,
619{
620 hub: &'a Keep<C>,
621}
622
623impl<'a, C> common::MethodsBuilder for NoteMethods<'a, C> {}
624
625impl<'a, C> NoteMethods<'a, C> {
626 /// Create a builder to help you perform the following task:
627 ///
628 /// Creates one or more permissions on the note. Only permissions with the `WRITER` role may be created. If adding any permission fails, then the entire request fails and no changes are made.
629 ///
630 /// # Arguments
631 ///
632 /// * `request` - No description provided.
633 /// * `parent` - The parent resource shared by all Permissions being created. Format: `notes/{note}` If this is set, the parent field in the CreatePermission messages must either be empty or match this field.
634 pub fn permissions_batch_create(
635 &self,
636 request: BatchCreatePermissionsRequest,
637 parent: &str,
638 ) -> NotePermissionBatchCreateCall<'a, C> {
639 NotePermissionBatchCreateCall {
640 hub: self.hub,
641 _request: request,
642 _parent: parent.to_string(),
643 _delegate: Default::default(),
644 _additional_params: Default::default(),
645 _scopes: Default::default(),
646 }
647 }
648
649 /// Create a builder to help you perform the following task:
650 ///
651 /// Deletes one or more permissions on the note. The specified entities will immediately lose access. A permission with the `OWNER` role can't be removed. If removing a permission fails, then the entire request fails and no changes are made. Returns a 400 bad request error if a specified permission does not exist on the note.
652 ///
653 /// # Arguments
654 ///
655 /// * `request` - No description provided.
656 /// * `parent` - The parent resource shared by all permissions being deleted. Format: `notes/{note}` If this is set, the parent of all of the permissions specified in the DeletePermissionRequest messages must match this field.
657 pub fn permissions_batch_delete(
658 &self,
659 request: BatchDeletePermissionsRequest,
660 parent: &str,
661 ) -> NotePermissionBatchDeleteCall<'a, C> {
662 NotePermissionBatchDeleteCall {
663 hub: self.hub,
664 _request: request,
665 _parent: parent.to_string(),
666 _delegate: Default::default(),
667 _additional_params: Default::default(),
668 _scopes: Default::default(),
669 }
670 }
671
672 /// Create a builder to help you perform the following task:
673 ///
674 /// Creates a new note.
675 ///
676 /// # Arguments
677 ///
678 /// * `request` - No description provided.
679 pub fn create(&self, request: Note) -> NoteCreateCall<'a, C> {
680 NoteCreateCall {
681 hub: self.hub,
682 _request: request,
683 _delegate: Default::default(),
684 _additional_params: Default::default(),
685 _scopes: Default::default(),
686 }
687 }
688
689 /// Create a builder to help you perform the following task:
690 ///
691 /// Deletes a note. Caller must have the `OWNER` role on the note to delete. Deleting a note removes the resource immediately and cannot be undone. Any collaborators will lose access to the note.
692 ///
693 /// # Arguments
694 ///
695 /// * `name` - Required. Name of the note to delete.
696 pub fn delete(&self, name: &str) -> NoteDeleteCall<'a, C> {
697 NoteDeleteCall {
698 hub: self.hub,
699 _name: name.to_string(),
700 _delegate: Default::default(),
701 _additional_params: Default::default(),
702 _scopes: Default::default(),
703 }
704 }
705
706 /// Create a builder to help you perform the following task:
707 ///
708 /// Gets a note.
709 ///
710 /// # Arguments
711 ///
712 /// * `name` - Required. Name of the resource.
713 pub fn get(&self, name: &str) -> NoteGetCall<'a, C> {
714 NoteGetCall {
715 hub: self.hub,
716 _name: name.to_string(),
717 _delegate: Default::default(),
718 _additional_params: Default::default(),
719 _scopes: Default::default(),
720 }
721 }
722
723 /// Create a builder to help you perform the following task:
724 ///
725 /// Lists notes. Every list call returns a page of results with `page_size` as the upper bound of returned items. A `page_size` of zero allows the server to choose the upper bound. The ListNotesResponse contains at most `page_size` entries. If there are more things left to list, it provides a `next_page_token` value. (Page tokens are opaque values.) To get the next page of results, copy the result's `next_page_token` into the next request's `page_token`. Repeat until the `next_page_token` returned with a page of results is empty. ListNotes return consistent results in the face of concurrent changes, or signals that it cannot with an ABORTED error.
726 pub fn list(&self) -> NoteListCall<'a, C> {
727 NoteListCall {
728 hub: self.hub,
729 _page_token: Default::default(),
730 _page_size: Default::default(),
731 _filter: Default::default(),
732 _delegate: Default::default(),
733 _additional_params: Default::default(),
734 _scopes: Default::default(),
735 }
736 }
737}
738
739// ###################
740// CallBuilders ###
741// #################
742
743/// Gets an attachment. To download attachment media via REST requires the alt=media query parameter. Returns a 400 bad request error if attachment media is not available in the requested MIME type.
744///
745/// This method supports **media download**. To enable it, adjust the builder like this:
746/// `.param("alt", "media")`.
747/// Please note that due to missing multi-part support on the server side, you will only receive the media,
748/// but not the `Attachment` structure that you would usually get. The latter will be a default value.
749///
750/// A builder for the *download* method supported by a *media* resource.
751/// It is not used directly, but through a [`MediaMethods`] instance.
752///
753/// # Example
754///
755/// Instantiate a resource method builder
756///
757/// ```test_harness,no_run
758/// # extern crate hyper;
759/// # extern crate hyper_rustls;
760/// # extern crate google_keep1 as keep1;
761/// # async fn dox() {
762/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
763///
764/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
765/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
766/// # .with_native_roots()
767/// # .unwrap()
768/// # .https_only()
769/// # .enable_http2()
770/// # .build();
771///
772/// # let executor = hyper_util::rt::TokioExecutor::new();
773/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
774/// # secret,
775/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
776/// # yup_oauth2::client::CustomHyperClientBuilder::from(
777/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
778/// # ),
779/// # ).build().await.unwrap();
780///
781/// # let client = hyper_util::client::legacy::Client::builder(
782/// # hyper_util::rt::TokioExecutor::new()
783/// # )
784/// # .build(
785/// # hyper_rustls::HttpsConnectorBuilder::new()
786/// # .with_native_roots()
787/// # .unwrap()
788/// # .https_or_http()
789/// # .enable_http2()
790/// # .build()
791/// # );
792/// # let mut hub = Keep::new(client, auth);
793/// // You can configure optional parameters by calling the respective setters at will, and
794/// // execute the final call using `doit()`.
795/// // Values shown here are possibly random and not representative !
796/// let result = hub.media().download("name")
797/// .mime_type("amet.")
798/// .doit().await;
799/// # }
800/// ```
801pub struct MediaDownloadCall<'a, C>
802where
803 C: 'a,
804{
805 hub: &'a Keep<C>,
806 _name: String,
807 _mime_type: Option<String>,
808 _delegate: Option<&'a mut dyn common::Delegate>,
809 _additional_params: HashMap<String, String>,
810 _scopes: BTreeSet<String>,
811}
812
813impl<'a, C> common::CallBuilder for MediaDownloadCall<'a, C> {}
814
815impl<'a, C> MediaDownloadCall<'a, C>
816where
817 C: common::Connector,
818{
819 /// Perform the operation you have build so far.
820 pub async fn doit(mut self) -> common::Result<(common::Response, Attachment)> {
821 use std::borrow::Cow;
822 use std::io::{Read, Seek};
823
824 use common::{url::Params, ToParts};
825 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
826
827 let mut dd = common::DefaultDelegate;
828 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
829 dlg.begin(common::MethodInfo {
830 id: "keep.media.download",
831 http_method: hyper::Method::GET,
832 });
833
834 for &field in ["name", "mimeType"].iter() {
835 if self._additional_params.contains_key(field) {
836 dlg.finished(false);
837 return Err(common::Error::FieldClash(field));
838 }
839 }
840
841 let mut params = Params::with_capacity(3 + self._additional_params.len());
842 params.push("name", self._name);
843 if let Some(value) = self._mime_type.as_ref() {
844 params.push("mimeType", value);
845 }
846
847 params.extend(self._additional_params.iter());
848
849 let (alt_field_missing, enable_resource_parsing) = {
850 if let Some(value) = params.get("alt") {
851 (false, value == "json")
852 } else {
853 (true, true)
854 }
855 };
856 if alt_field_missing {
857 params.push("alt", "json");
858 }
859 let mut url = self.hub._base_url.clone() + "v1/{+name}";
860 if self._scopes.is_empty() {
861 self._scopes.insert(Scope::Readonly.as_ref().to_string());
862 }
863
864 #[allow(clippy::single_element_loop)]
865 for &(find_this, param_name) in [("{+name}", "name")].iter() {
866 url = params.uri_replacement(url, param_name, find_this, true);
867 }
868 {
869 let to_remove = ["name"];
870 params.remove_params(&to_remove);
871 }
872
873 let url = params.parse_with_url(&url);
874
875 loop {
876 let token = match self
877 .hub
878 .auth
879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
880 .await
881 {
882 Ok(token) => token,
883 Err(e) => match dlg.token(e) {
884 Ok(token) => token,
885 Err(e) => {
886 dlg.finished(false);
887 return Err(common::Error::MissingToken(e));
888 }
889 },
890 };
891 let mut req_result = {
892 let client = &self.hub.client;
893 dlg.pre_request();
894 let mut req_builder = hyper::Request::builder()
895 .method(hyper::Method::GET)
896 .uri(url.as_str())
897 .header(USER_AGENT, self.hub._user_agent.clone());
898
899 if let Some(token) = token.as_ref() {
900 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
901 }
902
903 let request = req_builder
904 .header(CONTENT_LENGTH, 0_u64)
905 .body(common::to_body::<String>(None));
906
907 client.request(request.unwrap()).await
908 };
909
910 match req_result {
911 Err(err) => {
912 if let common::Retry::After(d) = dlg.http_error(&err) {
913 sleep(d).await;
914 continue;
915 }
916 dlg.finished(false);
917 return Err(common::Error::HttpError(err));
918 }
919 Ok(res) => {
920 let (mut parts, body) = res.into_parts();
921 let mut body = common::Body::new(body);
922 if !parts.status.is_success() {
923 let bytes = common::to_bytes(body).await.unwrap_or_default();
924 let error = serde_json::from_str(&common::to_string(&bytes));
925 let response = common::to_response(parts, bytes.into());
926
927 if let common::Retry::After(d) =
928 dlg.http_failure(&response, error.as_ref().ok())
929 {
930 sleep(d).await;
931 continue;
932 }
933
934 dlg.finished(false);
935
936 return Err(match error {
937 Ok(value) => common::Error::BadRequest(value),
938 _ => common::Error::Failure(response),
939 });
940 }
941 let response = if enable_resource_parsing {
942 let bytes = common::to_bytes(body).await.unwrap_or_default();
943 let encoded = common::to_string(&bytes);
944 match serde_json::from_str(&encoded) {
945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
946 Err(error) => {
947 dlg.response_json_decode_error(&encoded, &error);
948 return Err(common::Error::JsonDecodeError(
949 encoded.to_string(),
950 error,
951 ));
952 }
953 }
954 } else {
955 (
956 common::Response::from_parts(parts, body),
957 Default::default(),
958 )
959 };
960
961 dlg.finished(true);
962 return Ok(response);
963 }
964 }
965 }
966 }
967
968 /// Required. The name of the attachment.
969 ///
970 /// Sets the *name* path property to the given value.
971 ///
972 /// Even though the property as already been set when instantiating this call,
973 /// we provide this method for API completeness.
974 pub fn name(mut self, new_value: &str) -> MediaDownloadCall<'a, C> {
975 self._name = new_value.to_string();
976 self
977 }
978 /// The IANA MIME type format requested. The requested MIME type must be one specified in the attachment.mime_type. Required when downloading attachment media and ignored otherwise.
979 ///
980 /// Sets the *mime type* query property to the given value.
981 pub fn mime_type(mut self, new_value: &str) -> MediaDownloadCall<'a, C> {
982 self._mime_type = Some(new_value.to_string());
983 self
984 }
985 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
986 /// while executing the actual API request.
987 ///
988 /// ````text
989 /// It should be used to handle progress information, and to implement a certain level of resilience.
990 /// ````
991 ///
992 /// Sets the *delegate* property to the given value.
993 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MediaDownloadCall<'a, C> {
994 self._delegate = Some(new_value);
995 self
996 }
997
998 /// Set any additional parameter of the query string used in the request.
999 /// It should be used to set parameters which are not yet available through their own
1000 /// setters.
1001 ///
1002 /// Please note that this method must not be used to set any of the known parameters
1003 /// which have their own setter method. If done anyway, the request will fail.
1004 ///
1005 /// # Additional Parameters
1006 ///
1007 /// * *$.xgafv* (query-string) - V1 error format.
1008 /// * *access_token* (query-string) - OAuth access token.
1009 /// * *alt* (query-string) - Data format for response.
1010 /// * *callback* (query-string) - JSONP
1011 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1012 /// * *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.
1013 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1014 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1015 /// * *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.
1016 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1017 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1018 pub fn param<T>(mut self, name: T, value: T) -> MediaDownloadCall<'a, C>
1019 where
1020 T: AsRef<str>,
1021 {
1022 self._additional_params
1023 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1024 self
1025 }
1026
1027 /// Identifies the authorization scope for the method you are building.
1028 ///
1029 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1030 /// [`Scope::Readonly`].
1031 ///
1032 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1033 /// tokens for more than one scope.
1034 ///
1035 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1036 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1037 /// sufficient, a read-write scope will do as well.
1038 pub fn add_scope<St>(mut self, scope: St) -> MediaDownloadCall<'a, C>
1039 where
1040 St: AsRef<str>,
1041 {
1042 self._scopes.insert(String::from(scope.as_ref()));
1043 self
1044 }
1045 /// Identifies the authorization scope(s) for the method you are building.
1046 ///
1047 /// See [`Self::add_scope()`] for details.
1048 pub fn add_scopes<I, St>(mut self, scopes: I) -> MediaDownloadCall<'a, C>
1049 where
1050 I: IntoIterator<Item = St>,
1051 St: AsRef<str>,
1052 {
1053 self._scopes
1054 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1055 self
1056 }
1057
1058 /// Removes all scopes, and no default scope will be used either.
1059 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1060 /// for details).
1061 pub fn clear_scopes(mut self) -> MediaDownloadCall<'a, C> {
1062 self._scopes.clear();
1063 self
1064 }
1065}
1066
1067/// Creates one or more permissions on the note. Only permissions with the `WRITER` role may be created. If adding any permission fails, then the entire request fails and no changes are made.
1068///
1069/// A builder for the *permissions.batchCreate* method supported by a *note* resource.
1070/// It is not used directly, but through a [`NoteMethods`] instance.
1071///
1072/// # Example
1073///
1074/// Instantiate a resource method builder
1075///
1076/// ```test_harness,no_run
1077/// # extern crate hyper;
1078/// # extern crate hyper_rustls;
1079/// # extern crate google_keep1 as keep1;
1080/// use keep1::api::BatchCreatePermissionsRequest;
1081/// # async fn dox() {
1082/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1083///
1084/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1085/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1086/// # .with_native_roots()
1087/// # .unwrap()
1088/// # .https_only()
1089/// # .enable_http2()
1090/// # .build();
1091///
1092/// # let executor = hyper_util::rt::TokioExecutor::new();
1093/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1094/// # secret,
1095/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1096/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1097/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1098/// # ),
1099/// # ).build().await.unwrap();
1100///
1101/// # let client = hyper_util::client::legacy::Client::builder(
1102/// # hyper_util::rt::TokioExecutor::new()
1103/// # )
1104/// # .build(
1105/// # hyper_rustls::HttpsConnectorBuilder::new()
1106/// # .with_native_roots()
1107/// # .unwrap()
1108/// # .https_or_http()
1109/// # .enable_http2()
1110/// # .build()
1111/// # );
1112/// # let mut hub = Keep::new(client, auth);
1113/// // As the method needs a request, you would usually fill it with the desired information
1114/// // into the respective structure. Some of the parts shown here might not be applicable !
1115/// // Values shown here are possibly random and not representative !
1116/// let mut req = BatchCreatePermissionsRequest::default();
1117///
1118/// // You can configure optional parameters by calling the respective setters at will, and
1119/// // execute the final call using `doit()`.
1120/// // Values shown here are possibly random and not representative !
1121/// let result = hub.notes().permissions_batch_create(req, "parent")
1122/// .doit().await;
1123/// # }
1124/// ```
1125pub struct NotePermissionBatchCreateCall<'a, C>
1126where
1127 C: 'a,
1128{
1129 hub: &'a Keep<C>,
1130 _request: BatchCreatePermissionsRequest,
1131 _parent: String,
1132 _delegate: Option<&'a mut dyn common::Delegate>,
1133 _additional_params: HashMap<String, String>,
1134 _scopes: BTreeSet<String>,
1135}
1136
1137impl<'a, C> common::CallBuilder for NotePermissionBatchCreateCall<'a, C> {}
1138
1139impl<'a, C> NotePermissionBatchCreateCall<'a, C>
1140where
1141 C: common::Connector,
1142{
1143 /// Perform the operation you have build so far.
1144 pub async fn doit(
1145 mut self,
1146 ) -> common::Result<(common::Response, BatchCreatePermissionsResponse)> {
1147 use std::borrow::Cow;
1148 use std::io::{Read, Seek};
1149
1150 use common::{url::Params, ToParts};
1151 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1152
1153 let mut dd = common::DefaultDelegate;
1154 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1155 dlg.begin(common::MethodInfo {
1156 id: "keep.notes.permissions.batchCreate",
1157 http_method: hyper::Method::POST,
1158 });
1159
1160 for &field in ["alt", "parent"].iter() {
1161 if self._additional_params.contains_key(field) {
1162 dlg.finished(false);
1163 return Err(common::Error::FieldClash(field));
1164 }
1165 }
1166
1167 let mut params = Params::with_capacity(4 + self._additional_params.len());
1168 params.push("parent", self._parent);
1169
1170 params.extend(self._additional_params.iter());
1171
1172 params.push("alt", "json");
1173 let mut url = self.hub._base_url.clone() + "v1/{+parent}/permissions:batchCreate";
1174 if self._scopes.is_empty() {
1175 self._scopes.insert(Scope::Full.as_ref().to_string());
1176 }
1177
1178 #[allow(clippy::single_element_loop)]
1179 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1180 url = params.uri_replacement(url, param_name, find_this, true);
1181 }
1182 {
1183 let to_remove = ["parent"];
1184 params.remove_params(&to_remove);
1185 }
1186
1187 let url = params.parse_with_url(&url);
1188
1189 let mut json_mime_type = mime::APPLICATION_JSON;
1190 let mut request_value_reader = {
1191 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1192 common::remove_json_null_values(&mut value);
1193 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1194 serde_json::to_writer(&mut dst, &value).unwrap();
1195 dst
1196 };
1197 let request_size = request_value_reader
1198 .seek(std::io::SeekFrom::End(0))
1199 .unwrap();
1200 request_value_reader
1201 .seek(std::io::SeekFrom::Start(0))
1202 .unwrap();
1203
1204 loop {
1205 let token = match self
1206 .hub
1207 .auth
1208 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1209 .await
1210 {
1211 Ok(token) => token,
1212 Err(e) => match dlg.token(e) {
1213 Ok(token) => token,
1214 Err(e) => {
1215 dlg.finished(false);
1216 return Err(common::Error::MissingToken(e));
1217 }
1218 },
1219 };
1220 request_value_reader
1221 .seek(std::io::SeekFrom::Start(0))
1222 .unwrap();
1223 let mut req_result = {
1224 let client = &self.hub.client;
1225 dlg.pre_request();
1226 let mut req_builder = hyper::Request::builder()
1227 .method(hyper::Method::POST)
1228 .uri(url.as_str())
1229 .header(USER_AGENT, self.hub._user_agent.clone());
1230
1231 if let Some(token) = token.as_ref() {
1232 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1233 }
1234
1235 let request = req_builder
1236 .header(CONTENT_TYPE, json_mime_type.to_string())
1237 .header(CONTENT_LENGTH, request_size as u64)
1238 .body(common::to_body(
1239 request_value_reader.get_ref().clone().into(),
1240 ));
1241
1242 client.request(request.unwrap()).await
1243 };
1244
1245 match req_result {
1246 Err(err) => {
1247 if let common::Retry::After(d) = dlg.http_error(&err) {
1248 sleep(d).await;
1249 continue;
1250 }
1251 dlg.finished(false);
1252 return Err(common::Error::HttpError(err));
1253 }
1254 Ok(res) => {
1255 let (mut parts, body) = res.into_parts();
1256 let mut body = common::Body::new(body);
1257 if !parts.status.is_success() {
1258 let bytes = common::to_bytes(body).await.unwrap_or_default();
1259 let error = serde_json::from_str(&common::to_string(&bytes));
1260 let response = common::to_response(parts, bytes.into());
1261
1262 if let common::Retry::After(d) =
1263 dlg.http_failure(&response, error.as_ref().ok())
1264 {
1265 sleep(d).await;
1266 continue;
1267 }
1268
1269 dlg.finished(false);
1270
1271 return Err(match error {
1272 Ok(value) => common::Error::BadRequest(value),
1273 _ => common::Error::Failure(response),
1274 });
1275 }
1276 let response = {
1277 let bytes = common::to_bytes(body).await.unwrap_or_default();
1278 let encoded = common::to_string(&bytes);
1279 match serde_json::from_str(&encoded) {
1280 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1281 Err(error) => {
1282 dlg.response_json_decode_error(&encoded, &error);
1283 return Err(common::Error::JsonDecodeError(
1284 encoded.to_string(),
1285 error,
1286 ));
1287 }
1288 }
1289 };
1290
1291 dlg.finished(true);
1292 return Ok(response);
1293 }
1294 }
1295 }
1296 }
1297
1298 ///
1299 /// Sets the *request* property to the given value.
1300 ///
1301 /// Even though the property as already been set when instantiating this call,
1302 /// we provide this method for API completeness.
1303 pub fn request(
1304 mut self,
1305 new_value: BatchCreatePermissionsRequest,
1306 ) -> NotePermissionBatchCreateCall<'a, C> {
1307 self._request = new_value;
1308 self
1309 }
1310 /// The parent resource shared by all Permissions being created. Format: `notes/{note}` If this is set, the parent field in the CreatePermission messages must either be empty or match this field.
1311 ///
1312 /// Sets the *parent* path property to the given value.
1313 ///
1314 /// Even though the property as already been set when instantiating this call,
1315 /// we provide this method for API completeness.
1316 pub fn parent(mut self, new_value: &str) -> NotePermissionBatchCreateCall<'a, C> {
1317 self._parent = new_value.to_string();
1318 self
1319 }
1320 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1321 /// while executing the actual API request.
1322 ///
1323 /// ````text
1324 /// It should be used to handle progress information, and to implement a certain level of resilience.
1325 /// ````
1326 ///
1327 /// Sets the *delegate* property to the given value.
1328 pub fn delegate(
1329 mut self,
1330 new_value: &'a mut dyn common::Delegate,
1331 ) -> NotePermissionBatchCreateCall<'a, C> {
1332 self._delegate = Some(new_value);
1333 self
1334 }
1335
1336 /// Set any additional parameter of the query string used in the request.
1337 /// It should be used to set parameters which are not yet available through their own
1338 /// setters.
1339 ///
1340 /// Please note that this method must not be used to set any of the known parameters
1341 /// which have their own setter method. If done anyway, the request will fail.
1342 ///
1343 /// # Additional Parameters
1344 ///
1345 /// * *$.xgafv* (query-string) - V1 error format.
1346 /// * *access_token* (query-string) - OAuth access token.
1347 /// * *alt* (query-string) - Data format for response.
1348 /// * *callback* (query-string) - JSONP
1349 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1350 /// * *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.
1351 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1352 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1353 /// * *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.
1354 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1355 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1356 pub fn param<T>(mut self, name: T, value: T) -> NotePermissionBatchCreateCall<'a, C>
1357 where
1358 T: AsRef<str>,
1359 {
1360 self._additional_params
1361 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1362 self
1363 }
1364
1365 /// Identifies the authorization scope for the method you are building.
1366 ///
1367 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1368 /// [`Scope::Full`].
1369 ///
1370 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1371 /// tokens for more than one scope.
1372 ///
1373 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1374 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1375 /// sufficient, a read-write scope will do as well.
1376 pub fn add_scope<St>(mut self, scope: St) -> NotePermissionBatchCreateCall<'a, C>
1377 where
1378 St: AsRef<str>,
1379 {
1380 self._scopes.insert(String::from(scope.as_ref()));
1381 self
1382 }
1383 /// Identifies the authorization scope(s) for the method you are building.
1384 ///
1385 /// See [`Self::add_scope()`] for details.
1386 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotePermissionBatchCreateCall<'a, C>
1387 where
1388 I: IntoIterator<Item = St>,
1389 St: AsRef<str>,
1390 {
1391 self._scopes
1392 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1393 self
1394 }
1395
1396 /// Removes all scopes, and no default scope will be used either.
1397 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1398 /// for details).
1399 pub fn clear_scopes(mut self) -> NotePermissionBatchCreateCall<'a, C> {
1400 self._scopes.clear();
1401 self
1402 }
1403}
1404
1405/// Deletes one or more permissions on the note. The specified entities will immediately lose access. A permission with the `OWNER` role can't be removed. If removing a permission fails, then the entire request fails and no changes are made. Returns a 400 bad request error if a specified permission does not exist on the note.
1406///
1407/// A builder for the *permissions.batchDelete* method supported by a *note* resource.
1408/// It is not used directly, but through a [`NoteMethods`] instance.
1409///
1410/// # Example
1411///
1412/// Instantiate a resource method builder
1413///
1414/// ```test_harness,no_run
1415/// # extern crate hyper;
1416/// # extern crate hyper_rustls;
1417/// # extern crate google_keep1 as keep1;
1418/// use keep1::api::BatchDeletePermissionsRequest;
1419/// # async fn dox() {
1420/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1421///
1422/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1423/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1424/// # .with_native_roots()
1425/// # .unwrap()
1426/// # .https_only()
1427/// # .enable_http2()
1428/// # .build();
1429///
1430/// # let executor = hyper_util::rt::TokioExecutor::new();
1431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1432/// # secret,
1433/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1434/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1435/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1436/// # ),
1437/// # ).build().await.unwrap();
1438///
1439/// # let client = hyper_util::client::legacy::Client::builder(
1440/// # hyper_util::rt::TokioExecutor::new()
1441/// # )
1442/// # .build(
1443/// # hyper_rustls::HttpsConnectorBuilder::new()
1444/// # .with_native_roots()
1445/// # .unwrap()
1446/// # .https_or_http()
1447/// # .enable_http2()
1448/// # .build()
1449/// # );
1450/// # let mut hub = Keep::new(client, auth);
1451/// // As the method needs a request, you would usually fill it with the desired information
1452/// // into the respective structure. Some of the parts shown here might not be applicable !
1453/// // Values shown here are possibly random and not representative !
1454/// let mut req = BatchDeletePermissionsRequest::default();
1455///
1456/// // You can configure optional parameters by calling the respective setters at will, and
1457/// // execute the final call using `doit()`.
1458/// // Values shown here are possibly random and not representative !
1459/// let result = hub.notes().permissions_batch_delete(req, "parent")
1460/// .doit().await;
1461/// # }
1462/// ```
1463pub struct NotePermissionBatchDeleteCall<'a, C>
1464where
1465 C: 'a,
1466{
1467 hub: &'a Keep<C>,
1468 _request: BatchDeletePermissionsRequest,
1469 _parent: String,
1470 _delegate: Option<&'a mut dyn common::Delegate>,
1471 _additional_params: HashMap<String, String>,
1472 _scopes: BTreeSet<String>,
1473}
1474
1475impl<'a, C> common::CallBuilder for NotePermissionBatchDeleteCall<'a, C> {}
1476
1477impl<'a, C> NotePermissionBatchDeleteCall<'a, C>
1478where
1479 C: common::Connector,
1480{
1481 /// Perform the operation you have build so far.
1482 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1483 use std::borrow::Cow;
1484 use std::io::{Read, Seek};
1485
1486 use common::{url::Params, ToParts};
1487 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1488
1489 let mut dd = common::DefaultDelegate;
1490 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1491 dlg.begin(common::MethodInfo {
1492 id: "keep.notes.permissions.batchDelete",
1493 http_method: hyper::Method::POST,
1494 });
1495
1496 for &field in ["alt", "parent"].iter() {
1497 if self._additional_params.contains_key(field) {
1498 dlg.finished(false);
1499 return Err(common::Error::FieldClash(field));
1500 }
1501 }
1502
1503 let mut params = Params::with_capacity(4 + self._additional_params.len());
1504 params.push("parent", self._parent);
1505
1506 params.extend(self._additional_params.iter());
1507
1508 params.push("alt", "json");
1509 let mut url = self.hub._base_url.clone() + "v1/{+parent}/permissions:batchDelete";
1510 if self._scopes.is_empty() {
1511 self._scopes.insert(Scope::Full.as_ref().to_string());
1512 }
1513
1514 #[allow(clippy::single_element_loop)]
1515 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1516 url = params.uri_replacement(url, param_name, find_this, true);
1517 }
1518 {
1519 let to_remove = ["parent"];
1520 params.remove_params(&to_remove);
1521 }
1522
1523 let url = params.parse_with_url(&url);
1524
1525 let mut json_mime_type = mime::APPLICATION_JSON;
1526 let mut request_value_reader = {
1527 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1528 common::remove_json_null_values(&mut value);
1529 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1530 serde_json::to_writer(&mut dst, &value).unwrap();
1531 dst
1532 };
1533 let request_size = request_value_reader
1534 .seek(std::io::SeekFrom::End(0))
1535 .unwrap();
1536 request_value_reader
1537 .seek(std::io::SeekFrom::Start(0))
1538 .unwrap();
1539
1540 loop {
1541 let token = match self
1542 .hub
1543 .auth
1544 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1545 .await
1546 {
1547 Ok(token) => token,
1548 Err(e) => match dlg.token(e) {
1549 Ok(token) => token,
1550 Err(e) => {
1551 dlg.finished(false);
1552 return Err(common::Error::MissingToken(e));
1553 }
1554 },
1555 };
1556 request_value_reader
1557 .seek(std::io::SeekFrom::Start(0))
1558 .unwrap();
1559 let mut req_result = {
1560 let client = &self.hub.client;
1561 dlg.pre_request();
1562 let mut req_builder = hyper::Request::builder()
1563 .method(hyper::Method::POST)
1564 .uri(url.as_str())
1565 .header(USER_AGENT, self.hub._user_agent.clone());
1566
1567 if let Some(token) = token.as_ref() {
1568 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1569 }
1570
1571 let request = req_builder
1572 .header(CONTENT_TYPE, json_mime_type.to_string())
1573 .header(CONTENT_LENGTH, request_size as u64)
1574 .body(common::to_body(
1575 request_value_reader.get_ref().clone().into(),
1576 ));
1577
1578 client.request(request.unwrap()).await
1579 };
1580
1581 match req_result {
1582 Err(err) => {
1583 if let common::Retry::After(d) = dlg.http_error(&err) {
1584 sleep(d).await;
1585 continue;
1586 }
1587 dlg.finished(false);
1588 return Err(common::Error::HttpError(err));
1589 }
1590 Ok(res) => {
1591 let (mut parts, body) = res.into_parts();
1592 let mut body = common::Body::new(body);
1593 if !parts.status.is_success() {
1594 let bytes = common::to_bytes(body).await.unwrap_or_default();
1595 let error = serde_json::from_str(&common::to_string(&bytes));
1596 let response = common::to_response(parts, bytes.into());
1597
1598 if let common::Retry::After(d) =
1599 dlg.http_failure(&response, error.as_ref().ok())
1600 {
1601 sleep(d).await;
1602 continue;
1603 }
1604
1605 dlg.finished(false);
1606
1607 return Err(match error {
1608 Ok(value) => common::Error::BadRequest(value),
1609 _ => common::Error::Failure(response),
1610 });
1611 }
1612 let response = {
1613 let bytes = common::to_bytes(body).await.unwrap_or_default();
1614 let encoded = common::to_string(&bytes);
1615 match serde_json::from_str(&encoded) {
1616 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1617 Err(error) => {
1618 dlg.response_json_decode_error(&encoded, &error);
1619 return Err(common::Error::JsonDecodeError(
1620 encoded.to_string(),
1621 error,
1622 ));
1623 }
1624 }
1625 };
1626
1627 dlg.finished(true);
1628 return Ok(response);
1629 }
1630 }
1631 }
1632 }
1633
1634 ///
1635 /// Sets the *request* property to the given value.
1636 ///
1637 /// Even though the property as already been set when instantiating this call,
1638 /// we provide this method for API completeness.
1639 pub fn request(
1640 mut self,
1641 new_value: BatchDeletePermissionsRequest,
1642 ) -> NotePermissionBatchDeleteCall<'a, C> {
1643 self._request = new_value;
1644 self
1645 }
1646 /// The parent resource shared by all permissions being deleted. Format: `notes/{note}` If this is set, the parent of all of the permissions specified in the DeletePermissionRequest messages must match this field.
1647 ///
1648 /// Sets the *parent* path property to the given value.
1649 ///
1650 /// Even though the property as already been set when instantiating this call,
1651 /// we provide this method for API completeness.
1652 pub fn parent(mut self, new_value: &str) -> NotePermissionBatchDeleteCall<'a, C> {
1653 self._parent = new_value.to_string();
1654 self
1655 }
1656 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1657 /// while executing the actual API request.
1658 ///
1659 /// ````text
1660 /// It should be used to handle progress information, and to implement a certain level of resilience.
1661 /// ````
1662 ///
1663 /// Sets the *delegate* property to the given value.
1664 pub fn delegate(
1665 mut self,
1666 new_value: &'a mut dyn common::Delegate,
1667 ) -> NotePermissionBatchDeleteCall<'a, C> {
1668 self._delegate = Some(new_value);
1669 self
1670 }
1671
1672 /// Set any additional parameter of the query string used in the request.
1673 /// It should be used to set parameters which are not yet available through their own
1674 /// setters.
1675 ///
1676 /// Please note that this method must not be used to set any of the known parameters
1677 /// which have their own setter method. If done anyway, the request will fail.
1678 ///
1679 /// # Additional Parameters
1680 ///
1681 /// * *$.xgafv* (query-string) - V1 error format.
1682 /// * *access_token* (query-string) - OAuth access token.
1683 /// * *alt* (query-string) - Data format for response.
1684 /// * *callback* (query-string) - JSONP
1685 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1686 /// * *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.
1687 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1688 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1689 /// * *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.
1690 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1691 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1692 pub fn param<T>(mut self, name: T, value: T) -> NotePermissionBatchDeleteCall<'a, C>
1693 where
1694 T: AsRef<str>,
1695 {
1696 self._additional_params
1697 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1698 self
1699 }
1700
1701 /// Identifies the authorization scope for the method you are building.
1702 ///
1703 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1704 /// [`Scope::Full`].
1705 ///
1706 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1707 /// tokens for more than one scope.
1708 ///
1709 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1710 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1711 /// sufficient, a read-write scope will do as well.
1712 pub fn add_scope<St>(mut self, scope: St) -> NotePermissionBatchDeleteCall<'a, C>
1713 where
1714 St: AsRef<str>,
1715 {
1716 self._scopes.insert(String::from(scope.as_ref()));
1717 self
1718 }
1719 /// Identifies the authorization scope(s) for the method you are building.
1720 ///
1721 /// See [`Self::add_scope()`] for details.
1722 pub fn add_scopes<I, St>(mut self, scopes: I) -> NotePermissionBatchDeleteCall<'a, C>
1723 where
1724 I: IntoIterator<Item = St>,
1725 St: AsRef<str>,
1726 {
1727 self._scopes
1728 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1729 self
1730 }
1731
1732 /// Removes all scopes, and no default scope will be used either.
1733 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1734 /// for details).
1735 pub fn clear_scopes(mut self) -> NotePermissionBatchDeleteCall<'a, C> {
1736 self._scopes.clear();
1737 self
1738 }
1739}
1740
1741/// Creates a new note.
1742///
1743/// A builder for the *create* method supported by a *note* resource.
1744/// It is not used directly, but through a [`NoteMethods`] instance.
1745///
1746/// # Example
1747///
1748/// Instantiate a resource method builder
1749///
1750/// ```test_harness,no_run
1751/// # extern crate hyper;
1752/// # extern crate hyper_rustls;
1753/// # extern crate google_keep1 as keep1;
1754/// use keep1::api::Note;
1755/// # async fn dox() {
1756/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1757///
1758/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1759/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1760/// # .with_native_roots()
1761/// # .unwrap()
1762/// # .https_only()
1763/// # .enable_http2()
1764/// # .build();
1765///
1766/// # let executor = hyper_util::rt::TokioExecutor::new();
1767/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1768/// # secret,
1769/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1770/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1771/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1772/// # ),
1773/// # ).build().await.unwrap();
1774///
1775/// # let client = hyper_util::client::legacy::Client::builder(
1776/// # hyper_util::rt::TokioExecutor::new()
1777/// # )
1778/// # .build(
1779/// # hyper_rustls::HttpsConnectorBuilder::new()
1780/// # .with_native_roots()
1781/// # .unwrap()
1782/// # .https_or_http()
1783/// # .enable_http2()
1784/// # .build()
1785/// # );
1786/// # let mut hub = Keep::new(client, auth);
1787/// // As the method needs a request, you would usually fill it with the desired information
1788/// // into the respective structure. Some of the parts shown here might not be applicable !
1789/// // Values shown here are possibly random and not representative !
1790/// let mut req = Note::default();
1791///
1792/// // You can configure optional parameters by calling the respective setters at will, and
1793/// // execute the final call using `doit()`.
1794/// // Values shown here are possibly random and not representative !
1795/// let result = hub.notes().create(req)
1796/// .doit().await;
1797/// # }
1798/// ```
1799pub struct NoteCreateCall<'a, C>
1800where
1801 C: 'a,
1802{
1803 hub: &'a Keep<C>,
1804 _request: Note,
1805 _delegate: Option<&'a mut dyn common::Delegate>,
1806 _additional_params: HashMap<String, String>,
1807 _scopes: BTreeSet<String>,
1808}
1809
1810impl<'a, C> common::CallBuilder for NoteCreateCall<'a, C> {}
1811
1812impl<'a, C> NoteCreateCall<'a, C>
1813where
1814 C: common::Connector,
1815{
1816 /// Perform the operation you have build so far.
1817 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
1818 use std::borrow::Cow;
1819 use std::io::{Read, Seek};
1820
1821 use common::{url::Params, ToParts};
1822 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1823
1824 let mut dd = common::DefaultDelegate;
1825 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1826 dlg.begin(common::MethodInfo {
1827 id: "keep.notes.create",
1828 http_method: hyper::Method::POST,
1829 });
1830
1831 for &field in ["alt"].iter() {
1832 if self._additional_params.contains_key(field) {
1833 dlg.finished(false);
1834 return Err(common::Error::FieldClash(field));
1835 }
1836 }
1837
1838 let mut params = Params::with_capacity(3 + self._additional_params.len());
1839
1840 params.extend(self._additional_params.iter());
1841
1842 params.push("alt", "json");
1843 let mut url = self.hub._base_url.clone() + "v1/notes";
1844 if self._scopes.is_empty() {
1845 self._scopes.insert(Scope::Full.as_ref().to_string());
1846 }
1847
1848 let url = params.parse_with_url(&url);
1849
1850 let mut json_mime_type = mime::APPLICATION_JSON;
1851 let mut request_value_reader = {
1852 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1853 common::remove_json_null_values(&mut value);
1854 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1855 serde_json::to_writer(&mut dst, &value).unwrap();
1856 dst
1857 };
1858 let request_size = request_value_reader
1859 .seek(std::io::SeekFrom::End(0))
1860 .unwrap();
1861 request_value_reader
1862 .seek(std::io::SeekFrom::Start(0))
1863 .unwrap();
1864
1865 loop {
1866 let token = match self
1867 .hub
1868 .auth
1869 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1870 .await
1871 {
1872 Ok(token) => token,
1873 Err(e) => match dlg.token(e) {
1874 Ok(token) => token,
1875 Err(e) => {
1876 dlg.finished(false);
1877 return Err(common::Error::MissingToken(e));
1878 }
1879 },
1880 };
1881 request_value_reader
1882 .seek(std::io::SeekFrom::Start(0))
1883 .unwrap();
1884 let mut req_result = {
1885 let client = &self.hub.client;
1886 dlg.pre_request();
1887 let mut req_builder = hyper::Request::builder()
1888 .method(hyper::Method::POST)
1889 .uri(url.as_str())
1890 .header(USER_AGENT, self.hub._user_agent.clone());
1891
1892 if let Some(token) = token.as_ref() {
1893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1894 }
1895
1896 let request = req_builder
1897 .header(CONTENT_TYPE, json_mime_type.to_string())
1898 .header(CONTENT_LENGTH, request_size as u64)
1899 .body(common::to_body(
1900 request_value_reader.get_ref().clone().into(),
1901 ));
1902
1903 client.request(request.unwrap()).await
1904 };
1905
1906 match req_result {
1907 Err(err) => {
1908 if let common::Retry::After(d) = dlg.http_error(&err) {
1909 sleep(d).await;
1910 continue;
1911 }
1912 dlg.finished(false);
1913 return Err(common::Error::HttpError(err));
1914 }
1915 Ok(res) => {
1916 let (mut parts, body) = res.into_parts();
1917 let mut body = common::Body::new(body);
1918 if !parts.status.is_success() {
1919 let bytes = common::to_bytes(body).await.unwrap_or_default();
1920 let error = serde_json::from_str(&common::to_string(&bytes));
1921 let response = common::to_response(parts, bytes.into());
1922
1923 if let common::Retry::After(d) =
1924 dlg.http_failure(&response, error.as_ref().ok())
1925 {
1926 sleep(d).await;
1927 continue;
1928 }
1929
1930 dlg.finished(false);
1931
1932 return Err(match error {
1933 Ok(value) => common::Error::BadRequest(value),
1934 _ => common::Error::Failure(response),
1935 });
1936 }
1937 let response = {
1938 let bytes = common::to_bytes(body).await.unwrap_or_default();
1939 let encoded = common::to_string(&bytes);
1940 match serde_json::from_str(&encoded) {
1941 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1942 Err(error) => {
1943 dlg.response_json_decode_error(&encoded, &error);
1944 return Err(common::Error::JsonDecodeError(
1945 encoded.to_string(),
1946 error,
1947 ));
1948 }
1949 }
1950 };
1951
1952 dlg.finished(true);
1953 return Ok(response);
1954 }
1955 }
1956 }
1957 }
1958
1959 ///
1960 /// Sets the *request* property to the given value.
1961 ///
1962 /// Even though the property as already been set when instantiating this call,
1963 /// we provide this method for API completeness.
1964 pub fn request(mut self, new_value: Note) -> NoteCreateCall<'a, C> {
1965 self._request = new_value;
1966 self
1967 }
1968 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1969 /// while executing the actual API request.
1970 ///
1971 /// ````text
1972 /// It should be used to handle progress information, and to implement a certain level of resilience.
1973 /// ````
1974 ///
1975 /// Sets the *delegate* property to the given value.
1976 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> NoteCreateCall<'a, C> {
1977 self._delegate = Some(new_value);
1978 self
1979 }
1980
1981 /// Set any additional parameter of the query string used in the request.
1982 /// It should be used to set parameters which are not yet available through their own
1983 /// setters.
1984 ///
1985 /// Please note that this method must not be used to set any of the known parameters
1986 /// which have their own setter method. If done anyway, the request will fail.
1987 ///
1988 /// # Additional Parameters
1989 ///
1990 /// * *$.xgafv* (query-string) - V1 error format.
1991 /// * *access_token* (query-string) - OAuth access token.
1992 /// * *alt* (query-string) - Data format for response.
1993 /// * *callback* (query-string) - JSONP
1994 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1995 /// * *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.
1996 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1997 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1998 /// * *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.
1999 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2000 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2001 pub fn param<T>(mut self, name: T, value: T) -> NoteCreateCall<'a, C>
2002 where
2003 T: AsRef<str>,
2004 {
2005 self._additional_params
2006 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2007 self
2008 }
2009
2010 /// Identifies the authorization scope for the method you are building.
2011 ///
2012 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2013 /// [`Scope::Full`].
2014 ///
2015 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2016 /// tokens for more than one scope.
2017 ///
2018 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2019 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2020 /// sufficient, a read-write scope will do as well.
2021 pub fn add_scope<St>(mut self, scope: St) -> NoteCreateCall<'a, C>
2022 where
2023 St: AsRef<str>,
2024 {
2025 self._scopes.insert(String::from(scope.as_ref()));
2026 self
2027 }
2028 /// Identifies the authorization scope(s) for the method you are building.
2029 ///
2030 /// See [`Self::add_scope()`] for details.
2031 pub fn add_scopes<I, St>(mut self, scopes: I) -> NoteCreateCall<'a, C>
2032 where
2033 I: IntoIterator<Item = St>,
2034 St: AsRef<str>,
2035 {
2036 self._scopes
2037 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2038 self
2039 }
2040
2041 /// Removes all scopes, and no default scope will be used either.
2042 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2043 /// for details).
2044 pub fn clear_scopes(mut self) -> NoteCreateCall<'a, C> {
2045 self._scopes.clear();
2046 self
2047 }
2048}
2049
2050/// Deletes a note. Caller must have the `OWNER` role on the note to delete. Deleting a note removes the resource immediately and cannot be undone. Any collaborators will lose access to the note.
2051///
2052/// A builder for the *delete* method supported by a *note* resource.
2053/// It is not used directly, but through a [`NoteMethods`] instance.
2054///
2055/// # Example
2056///
2057/// Instantiate a resource method builder
2058///
2059/// ```test_harness,no_run
2060/// # extern crate hyper;
2061/// # extern crate hyper_rustls;
2062/// # extern crate google_keep1 as keep1;
2063/// # async fn dox() {
2064/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2065///
2066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2068/// # .with_native_roots()
2069/// # .unwrap()
2070/// # .https_only()
2071/// # .enable_http2()
2072/// # .build();
2073///
2074/// # let executor = hyper_util::rt::TokioExecutor::new();
2075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2076/// # secret,
2077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2078/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2079/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2080/// # ),
2081/// # ).build().await.unwrap();
2082///
2083/// # let client = hyper_util::client::legacy::Client::builder(
2084/// # hyper_util::rt::TokioExecutor::new()
2085/// # )
2086/// # .build(
2087/// # hyper_rustls::HttpsConnectorBuilder::new()
2088/// # .with_native_roots()
2089/// # .unwrap()
2090/// # .https_or_http()
2091/// # .enable_http2()
2092/// # .build()
2093/// # );
2094/// # let mut hub = Keep::new(client, auth);
2095/// // You can configure optional parameters by calling the respective setters at will, and
2096/// // execute the final call using `doit()`.
2097/// // Values shown here are possibly random and not representative !
2098/// let result = hub.notes().delete("name")
2099/// .doit().await;
2100/// # }
2101/// ```
2102pub struct NoteDeleteCall<'a, C>
2103where
2104 C: 'a,
2105{
2106 hub: &'a Keep<C>,
2107 _name: String,
2108 _delegate: Option<&'a mut dyn common::Delegate>,
2109 _additional_params: HashMap<String, String>,
2110 _scopes: BTreeSet<String>,
2111}
2112
2113impl<'a, C> common::CallBuilder for NoteDeleteCall<'a, C> {}
2114
2115impl<'a, C> NoteDeleteCall<'a, C>
2116where
2117 C: common::Connector,
2118{
2119 /// Perform the operation you have build so far.
2120 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2121 use std::borrow::Cow;
2122 use std::io::{Read, Seek};
2123
2124 use common::{url::Params, ToParts};
2125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2126
2127 let mut dd = common::DefaultDelegate;
2128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2129 dlg.begin(common::MethodInfo {
2130 id: "keep.notes.delete",
2131 http_method: hyper::Method::DELETE,
2132 });
2133
2134 for &field in ["alt", "name"].iter() {
2135 if self._additional_params.contains_key(field) {
2136 dlg.finished(false);
2137 return Err(common::Error::FieldClash(field));
2138 }
2139 }
2140
2141 let mut params = Params::with_capacity(3 + self._additional_params.len());
2142 params.push("name", self._name);
2143
2144 params.extend(self._additional_params.iter());
2145
2146 params.push("alt", "json");
2147 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2148 if self._scopes.is_empty() {
2149 self._scopes.insert(Scope::Full.as_ref().to_string());
2150 }
2151
2152 #[allow(clippy::single_element_loop)]
2153 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2154 url = params.uri_replacement(url, param_name, find_this, true);
2155 }
2156 {
2157 let to_remove = ["name"];
2158 params.remove_params(&to_remove);
2159 }
2160
2161 let url = params.parse_with_url(&url);
2162
2163 loop {
2164 let token = match self
2165 .hub
2166 .auth
2167 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2168 .await
2169 {
2170 Ok(token) => token,
2171 Err(e) => match dlg.token(e) {
2172 Ok(token) => token,
2173 Err(e) => {
2174 dlg.finished(false);
2175 return Err(common::Error::MissingToken(e));
2176 }
2177 },
2178 };
2179 let mut req_result = {
2180 let client = &self.hub.client;
2181 dlg.pre_request();
2182 let mut req_builder = hyper::Request::builder()
2183 .method(hyper::Method::DELETE)
2184 .uri(url.as_str())
2185 .header(USER_AGENT, self.hub._user_agent.clone());
2186
2187 if let Some(token) = token.as_ref() {
2188 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2189 }
2190
2191 let request = req_builder
2192 .header(CONTENT_LENGTH, 0_u64)
2193 .body(common::to_body::<String>(None));
2194
2195 client.request(request.unwrap()).await
2196 };
2197
2198 match req_result {
2199 Err(err) => {
2200 if let common::Retry::After(d) = dlg.http_error(&err) {
2201 sleep(d).await;
2202 continue;
2203 }
2204 dlg.finished(false);
2205 return Err(common::Error::HttpError(err));
2206 }
2207 Ok(res) => {
2208 let (mut parts, body) = res.into_parts();
2209 let mut body = common::Body::new(body);
2210 if !parts.status.is_success() {
2211 let bytes = common::to_bytes(body).await.unwrap_or_default();
2212 let error = serde_json::from_str(&common::to_string(&bytes));
2213 let response = common::to_response(parts, bytes.into());
2214
2215 if let common::Retry::After(d) =
2216 dlg.http_failure(&response, error.as_ref().ok())
2217 {
2218 sleep(d).await;
2219 continue;
2220 }
2221
2222 dlg.finished(false);
2223
2224 return Err(match error {
2225 Ok(value) => common::Error::BadRequest(value),
2226 _ => common::Error::Failure(response),
2227 });
2228 }
2229 let response = {
2230 let bytes = common::to_bytes(body).await.unwrap_or_default();
2231 let encoded = common::to_string(&bytes);
2232 match serde_json::from_str(&encoded) {
2233 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2234 Err(error) => {
2235 dlg.response_json_decode_error(&encoded, &error);
2236 return Err(common::Error::JsonDecodeError(
2237 encoded.to_string(),
2238 error,
2239 ));
2240 }
2241 }
2242 };
2243
2244 dlg.finished(true);
2245 return Ok(response);
2246 }
2247 }
2248 }
2249 }
2250
2251 /// Required. Name of the note to delete.
2252 ///
2253 /// Sets the *name* path property to the given value.
2254 ///
2255 /// Even though the property as already been set when instantiating this call,
2256 /// we provide this method for API completeness.
2257 pub fn name(mut self, new_value: &str) -> NoteDeleteCall<'a, C> {
2258 self._name = new_value.to_string();
2259 self
2260 }
2261 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2262 /// while executing the actual API request.
2263 ///
2264 /// ````text
2265 /// It should be used to handle progress information, and to implement a certain level of resilience.
2266 /// ````
2267 ///
2268 /// Sets the *delegate* property to the given value.
2269 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> NoteDeleteCall<'a, C> {
2270 self._delegate = Some(new_value);
2271 self
2272 }
2273
2274 /// Set any additional parameter of the query string used in the request.
2275 /// It should be used to set parameters which are not yet available through their own
2276 /// setters.
2277 ///
2278 /// Please note that this method must not be used to set any of the known parameters
2279 /// which have their own setter method. If done anyway, the request will fail.
2280 ///
2281 /// # Additional Parameters
2282 ///
2283 /// * *$.xgafv* (query-string) - V1 error format.
2284 /// * *access_token* (query-string) - OAuth access token.
2285 /// * *alt* (query-string) - Data format for response.
2286 /// * *callback* (query-string) - JSONP
2287 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2288 /// * *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.
2289 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2290 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2291 /// * *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.
2292 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2293 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2294 pub fn param<T>(mut self, name: T, value: T) -> NoteDeleteCall<'a, C>
2295 where
2296 T: AsRef<str>,
2297 {
2298 self._additional_params
2299 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2300 self
2301 }
2302
2303 /// Identifies the authorization scope for the method you are building.
2304 ///
2305 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2306 /// [`Scope::Full`].
2307 ///
2308 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2309 /// tokens for more than one scope.
2310 ///
2311 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2312 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2313 /// sufficient, a read-write scope will do as well.
2314 pub fn add_scope<St>(mut self, scope: St) -> NoteDeleteCall<'a, C>
2315 where
2316 St: AsRef<str>,
2317 {
2318 self._scopes.insert(String::from(scope.as_ref()));
2319 self
2320 }
2321 /// Identifies the authorization scope(s) for the method you are building.
2322 ///
2323 /// See [`Self::add_scope()`] for details.
2324 pub fn add_scopes<I, St>(mut self, scopes: I) -> NoteDeleteCall<'a, C>
2325 where
2326 I: IntoIterator<Item = St>,
2327 St: AsRef<str>,
2328 {
2329 self._scopes
2330 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2331 self
2332 }
2333
2334 /// Removes all scopes, and no default scope will be used either.
2335 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2336 /// for details).
2337 pub fn clear_scopes(mut self) -> NoteDeleteCall<'a, C> {
2338 self._scopes.clear();
2339 self
2340 }
2341}
2342
2343/// Gets a note.
2344///
2345/// A builder for the *get* method supported by a *note* resource.
2346/// It is not used directly, but through a [`NoteMethods`] instance.
2347///
2348/// # Example
2349///
2350/// Instantiate a resource method builder
2351///
2352/// ```test_harness,no_run
2353/// # extern crate hyper;
2354/// # extern crate hyper_rustls;
2355/// # extern crate google_keep1 as keep1;
2356/// # async fn dox() {
2357/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2358///
2359/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2360/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2361/// # .with_native_roots()
2362/// # .unwrap()
2363/// # .https_only()
2364/// # .enable_http2()
2365/// # .build();
2366///
2367/// # let executor = hyper_util::rt::TokioExecutor::new();
2368/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2369/// # secret,
2370/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2371/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2372/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2373/// # ),
2374/// # ).build().await.unwrap();
2375///
2376/// # let client = hyper_util::client::legacy::Client::builder(
2377/// # hyper_util::rt::TokioExecutor::new()
2378/// # )
2379/// # .build(
2380/// # hyper_rustls::HttpsConnectorBuilder::new()
2381/// # .with_native_roots()
2382/// # .unwrap()
2383/// # .https_or_http()
2384/// # .enable_http2()
2385/// # .build()
2386/// # );
2387/// # let mut hub = Keep::new(client, auth);
2388/// // You can configure optional parameters by calling the respective setters at will, and
2389/// // execute the final call using `doit()`.
2390/// // Values shown here are possibly random and not representative !
2391/// let result = hub.notes().get("name")
2392/// .doit().await;
2393/// # }
2394/// ```
2395pub struct NoteGetCall<'a, C>
2396where
2397 C: 'a,
2398{
2399 hub: &'a Keep<C>,
2400 _name: String,
2401 _delegate: Option<&'a mut dyn common::Delegate>,
2402 _additional_params: HashMap<String, String>,
2403 _scopes: BTreeSet<String>,
2404}
2405
2406impl<'a, C> common::CallBuilder for NoteGetCall<'a, C> {}
2407
2408impl<'a, C> NoteGetCall<'a, C>
2409where
2410 C: common::Connector,
2411{
2412 /// Perform the operation you have build so far.
2413 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
2414 use std::borrow::Cow;
2415 use std::io::{Read, Seek};
2416
2417 use common::{url::Params, ToParts};
2418 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2419
2420 let mut dd = common::DefaultDelegate;
2421 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2422 dlg.begin(common::MethodInfo {
2423 id: "keep.notes.get",
2424 http_method: hyper::Method::GET,
2425 });
2426
2427 for &field in ["alt", "name"].iter() {
2428 if self._additional_params.contains_key(field) {
2429 dlg.finished(false);
2430 return Err(common::Error::FieldClash(field));
2431 }
2432 }
2433
2434 let mut params = Params::with_capacity(3 + self._additional_params.len());
2435 params.push("name", self._name);
2436
2437 params.extend(self._additional_params.iter());
2438
2439 params.push("alt", "json");
2440 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2441 if self._scopes.is_empty() {
2442 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2443 }
2444
2445 #[allow(clippy::single_element_loop)]
2446 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2447 url = params.uri_replacement(url, param_name, find_this, true);
2448 }
2449 {
2450 let to_remove = ["name"];
2451 params.remove_params(&to_remove);
2452 }
2453
2454 let url = params.parse_with_url(&url);
2455
2456 loop {
2457 let token = match self
2458 .hub
2459 .auth
2460 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2461 .await
2462 {
2463 Ok(token) => token,
2464 Err(e) => match dlg.token(e) {
2465 Ok(token) => token,
2466 Err(e) => {
2467 dlg.finished(false);
2468 return Err(common::Error::MissingToken(e));
2469 }
2470 },
2471 };
2472 let mut req_result = {
2473 let client = &self.hub.client;
2474 dlg.pre_request();
2475 let mut req_builder = hyper::Request::builder()
2476 .method(hyper::Method::GET)
2477 .uri(url.as_str())
2478 .header(USER_AGENT, self.hub._user_agent.clone());
2479
2480 if let Some(token) = token.as_ref() {
2481 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2482 }
2483
2484 let request = req_builder
2485 .header(CONTENT_LENGTH, 0_u64)
2486 .body(common::to_body::<String>(None));
2487
2488 client.request(request.unwrap()).await
2489 };
2490
2491 match req_result {
2492 Err(err) => {
2493 if let common::Retry::After(d) = dlg.http_error(&err) {
2494 sleep(d).await;
2495 continue;
2496 }
2497 dlg.finished(false);
2498 return Err(common::Error::HttpError(err));
2499 }
2500 Ok(res) => {
2501 let (mut parts, body) = res.into_parts();
2502 let mut body = common::Body::new(body);
2503 if !parts.status.is_success() {
2504 let bytes = common::to_bytes(body).await.unwrap_or_default();
2505 let error = serde_json::from_str(&common::to_string(&bytes));
2506 let response = common::to_response(parts, bytes.into());
2507
2508 if let common::Retry::After(d) =
2509 dlg.http_failure(&response, error.as_ref().ok())
2510 {
2511 sleep(d).await;
2512 continue;
2513 }
2514
2515 dlg.finished(false);
2516
2517 return Err(match error {
2518 Ok(value) => common::Error::BadRequest(value),
2519 _ => common::Error::Failure(response),
2520 });
2521 }
2522 let response = {
2523 let bytes = common::to_bytes(body).await.unwrap_or_default();
2524 let encoded = common::to_string(&bytes);
2525 match serde_json::from_str(&encoded) {
2526 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2527 Err(error) => {
2528 dlg.response_json_decode_error(&encoded, &error);
2529 return Err(common::Error::JsonDecodeError(
2530 encoded.to_string(),
2531 error,
2532 ));
2533 }
2534 }
2535 };
2536
2537 dlg.finished(true);
2538 return Ok(response);
2539 }
2540 }
2541 }
2542 }
2543
2544 /// Required. Name of the resource.
2545 ///
2546 /// Sets the *name* path property to the given value.
2547 ///
2548 /// Even though the property as already been set when instantiating this call,
2549 /// we provide this method for API completeness.
2550 pub fn name(mut self, new_value: &str) -> NoteGetCall<'a, C> {
2551 self._name = new_value.to_string();
2552 self
2553 }
2554 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2555 /// while executing the actual API request.
2556 ///
2557 /// ````text
2558 /// It should be used to handle progress information, and to implement a certain level of resilience.
2559 /// ````
2560 ///
2561 /// Sets the *delegate* property to the given value.
2562 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> NoteGetCall<'a, C> {
2563 self._delegate = Some(new_value);
2564 self
2565 }
2566
2567 /// Set any additional parameter of the query string used in the request.
2568 /// It should be used to set parameters which are not yet available through their own
2569 /// setters.
2570 ///
2571 /// Please note that this method must not be used to set any of the known parameters
2572 /// which have their own setter method. If done anyway, the request will fail.
2573 ///
2574 /// # Additional Parameters
2575 ///
2576 /// * *$.xgafv* (query-string) - V1 error format.
2577 /// * *access_token* (query-string) - OAuth access token.
2578 /// * *alt* (query-string) - Data format for response.
2579 /// * *callback* (query-string) - JSONP
2580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2581 /// * *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.
2582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2584 /// * *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.
2585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2587 pub fn param<T>(mut self, name: T, value: T) -> NoteGetCall<'a, C>
2588 where
2589 T: AsRef<str>,
2590 {
2591 self._additional_params
2592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2593 self
2594 }
2595
2596 /// Identifies the authorization scope for the method you are building.
2597 ///
2598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2599 /// [`Scope::Readonly`].
2600 ///
2601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2602 /// tokens for more than one scope.
2603 ///
2604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2606 /// sufficient, a read-write scope will do as well.
2607 pub fn add_scope<St>(mut self, scope: St) -> NoteGetCall<'a, C>
2608 where
2609 St: AsRef<str>,
2610 {
2611 self._scopes.insert(String::from(scope.as_ref()));
2612 self
2613 }
2614 /// Identifies the authorization scope(s) for the method you are building.
2615 ///
2616 /// See [`Self::add_scope()`] for details.
2617 pub fn add_scopes<I, St>(mut self, scopes: I) -> NoteGetCall<'a, C>
2618 where
2619 I: IntoIterator<Item = St>,
2620 St: AsRef<str>,
2621 {
2622 self._scopes
2623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2624 self
2625 }
2626
2627 /// Removes all scopes, and no default scope will be used either.
2628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2629 /// for details).
2630 pub fn clear_scopes(mut self) -> NoteGetCall<'a, C> {
2631 self._scopes.clear();
2632 self
2633 }
2634}
2635
2636/// Lists notes. Every list call returns a page of results with `page_size` as the upper bound of returned items. A `page_size` of zero allows the server to choose the upper bound. The ListNotesResponse contains at most `page_size` entries. If there are more things left to list, it provides a `next_page_token` value. (Page tokens are opaque values.) To get the next page of results, copy the result's `next_page_token` into the next request's `page_token`. Repeat until the `next_page_token` returned with a page of results is empty. ListNotes return consistent results in the face of concurrent changes, or signals that it cannot with an ABORTED error.
2637///
2638/// A builder for the *list* method supported by a *note* resource.
2639/// It is not used directly, but through a [`NoteMethods`] instance.
2640///
2641/// # Example
2642///
2643/// Instantiate a resource method builder
2644///
2645/// ```test_harness,no_run
2646/// # extern crate hyper;
2647/// # extern crate hyper_rustls;
2648/// # extern crate google_keep1 as keep1;
2649/// # async fn dox() {
2650/// # use keep1::{Keep, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2651///
2652/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2653/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2654/// # .with_native_roots()
2655/// # .unwrap()
2656/// # .https_only()
2657/// # .enable_http2()
2658/// # .build();
2659///
2660/// # let executor = hyper_util::rt::TokioExecutor::new();
2661/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2662/// # secret,
2663/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2664/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2665/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2666/// # ),
2667/// # ).build().await.unwrap();
2668///
2669/// # let client = hyper_util::client::legacy::Client::builder(
2670/// # hyper_util::rt::TokioExecutor::new()
2671/// # )
2672/// # .build(
2673/// # hyper_rustls::HttpsConnectorBuilder::new()
2674/// # .with_native_roots()
2675/// # .unwrap()
2676/// # .https_or_http()
2677/// # .enable_http2()
2678/// # .build()
2679/// # );
2680/// # let mut hub = Keep::new(client, auth);
2681/// // You can configure optional parameters by calling the respective setters at will, and
2682/// // execute the final call using `doit()`.
2683/// // Values shown here are possibly random and not representative !
2684/// let result = hub.notes().list()
2685/// .page_token("gubergren")
2686/// .page_size(-75)
2687/// .filter("dolor")
2688/// .doit().await;
2689/// # }
2690/// ```
2691pub struct NoteListCall<'a, C>
2692where
2693 C: 'a,
2694{
2695 hub: &'a Keep<C>,
2696 _page_token: Option<String>,
2697 _page_size: Option<i32>,
2698 _filter: Option<String>,
2699 _delegate: Option<&'a mut dyn common::Delegate>,
2700 _additional_params: HashMap<String, String>,
2701 _scopes: BTreeSet<String>,
2702}
2703
2704impl<'a, C> common::CallBuilder for NoteListCall<'a, C> {}
2705
2706impl<'a, C> NoteListCall<'a, C>
2707where
2708 C: common::Connector,
2709{
2710 /// Perform the operation you have build so far.
2711 pub async fn doit(mut self) -> common::Result<(common::Response, ListNotesResponse)> {
2712 use std::borrow::Cow;
2713 use std::io::{Read, Seek};
2714
2715 use common::{url::Params, ToParts};
2716 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2717
2718 let mut dd = common::DefaultDelegate;
2719 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2720 dlg.begin(common::MethodInfo {
2721 id: "keep.notes.list",
2722 http_method: hyper::Method::GET,
2723 });
2724
2725 for &field in ["alt", "pageToken", "pageSize", "filter"].iter() {
2726 if self._additional_params.contains_key(field) {
2727 dlg.finished(false);
2728 return Err(common::Error::FieldClash(field));
2729 }
2730 }
2731
2732 let mut params = Params::with_capacity(5 + self._additional_params.len());
2733 if let Some(value) = self._page_token.as_ref() {
2734 params.push("pageToken", value);
2735 }
2736 if let Some(value) = self._page_size.as_ref() {
2737 params.push("pageSize", value.to_string());
2738 }
2739 if let Some(value) = self._filter.as_ref() {
2740 params.push("filter", value);
2741 }
2742
2743 params.extend(self._additional_params.iter());
2744
2745 params.push("alt", "json");
2746 let mut url = self.hub._base_url.clone() + "v1/notes";
2747 if self._scopes.is_empty() {
2748 self._scopes.insert(Scope::Readonly.as_ref().to_string());
2749 }
2750
2751 let url = params.parse_with_url(&url);
2752
2753 loop {
2754 let token = match self
2755 .hub
2756 .auth
2757 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2758 .await
2759 {
2760 Ok(token) => token,
2761 Err(e) => match dlg.token(e) {
2762 Ok(token) => token,
2763 Err(e) => {
2764 dlg.finished(false);
2765 return Err(common::Error::MissingToken(e));
2766 }
2767 },
2768 };
2769 let mut req_result = {
2770 let client = &self.hub.client;
2771 dlg.pre_request();
2772 let mut req_builder = hyper::Request::builder()
2773 .method(hyper::Method::GET)
2774 .uri(url.as_str())
2775 .header(USER_AGENT, self.hub._user_agent.clone());
2776
2777 if let Some(token) = token.as_ref() {
2778 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2779 }
2780
2781 let request = req_builder
2782 .header(CONTENT_LENGTH, 0_u64)
2783 .body(common::to_body::<String>(None));
2784
2785 client.request(request.unwrap()).await
2786 };
2787
2788 match req_result {
2789 Err(err) => {
2790 if let common::Retry::After(d) = dlg.http_error(&err) {
2791 sleep(d).await;
2792 continue;
2793 }
2794 dlg.finished(false);
2795 return Err(common::Error::HttpError(err));
2796 }
2797 Ok(res) => {
2798 let (mut parts, body) = res.into_parts();
2799 let mut body = common::Body::new(body);
2800 if !parts.status.is_success() {
2801 let bytes = common::to_bytes(body).await.unwrap_or_default();
2802 let error = serde_json::from_str(&common::to_string(&bytes));
2803 let response = common::to_response(parts, bytes.into());
2804
2805 if let common::Retry::After(d) =
2806 dlg.http_failure(&response, error.as_ref().ok())
2807 {
2808 sleep(d).await;
2809 continue;
2810 }
2811
2812 dlg.finished(false);
2813
2814 return Err(match error {
2815 Ok(value) => common::Error::BadRequest(value),
2816 _ => common::Error::Failure(response),
2817 });
2818 }
2819 let response = {
2820 let bytes = common::to_bytes(body).await.unwrap_or_default();
2821 let encoded = common::to_string(&bytes);
2822 match serde_json::from_str(&encoded) {
2823 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2824 Err(error) => {
2825 dlg.response_json_decode_error(&encoded, &error);
2826 return Err(common::Error::JsonDecodeError(
2827 encoded.to_string(),
2828 error,
2829 ));
2830 }
2831 }
2832 };
2833
2834 dlg.finished(true);
2835 return Ok(response);
2836 }
2837 }
2838 }
2839 }
2840
2841 /// The previous page's `next_page_token` field.
2842 ///
2843 /// Sets the *page token* query property to the given value.
2844 pub fn page_token(mut self, new_value: &str) -> NoteListCall<'a, C> {
2845 self._page_token = Some(new_value.to_string());
2846 self
2847 }
2848 /// The maximum number of results to return.
2849 ///
2850 /// Sets the *page size* query property to the given value.
2851 pub fn page_size(mut self, new_value: i32) -> NoteListCall<'a, C> {
2852 self._page_size = Some(new_value);
2853 self
2854 }
2855 /// Filter for list results. If no filter is supplied, the `trashed` filter is applied by default. Valid fields to filter by are: `create_time`, `update_time`, `trash_time`, and `trashed`. Filter syntax follows the [Google AIP filtering spec](https://aip.dev/160).
2856 ///
2857 /// Sets the *filter* query property to the given value.
2858 pub fn filter(mut self, new_value: &str) -> NoteListCall<'a, C> {
2859 self._filter = Some(new_value.to_string());
2860 self
2861 }
2862 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2863 /// while executing the actual API request.
2864 ///
2865 /// ````text
2866 /// It should be used to handle progress information, and to implement a certain level of resilience.
2867 /// ````
2868 ///
2869 /// Sets the *delegate* property to the given value.
2870 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> NoteListCall<'a, C> {
2871 self._delegate = Some(new_value);
2872 self
2873 }
2874
2875 /// Set any additional parameter of the query string used in the request.
2876 /// It should be used to set parameters which are not yet available through their own
2877 /// setters.
2878 ///
2879 /// Please note that this method must not be used to set any of the known parameters
2880 /// which have their own setter method. If done anyway, the request will fail.
2881 ///
2882 /// # Additional Parameters
2883 ///
2884 /// * *$.xgafv* (query-string) - V1 error format.
2885 /// * *access_token* (query-string) - OAuth access token.
2886 /// * *alt* (query-string) - Data format for response.
2887 /// * *callback* (query-string) - JSONP
2888 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2889 /// * *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.
2890 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2891 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2892 /// * *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.
2893 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2894 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2895 pub fn param<T>(mut self, name: T, value: T) -> NoteListCall<'a, C>
2896 where
2897 T: AsRef<str>,
2898 {
2899 self._additional_params
2900 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2901 self
2902 }
2903
2904 /// Identifies the authorization scope for the method you are building.
2905 ///
2906 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2907 /// [`Scope::Readonly`].
2908 ///
2909 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2910 /// tokens for more than one scope.
2911 ///
2912 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2913 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2914 /// sufficient, a read-write scope will do as well.
2915 pub fn add_scope<St>(mut self, scope: St) -> NoteListCall<'a, C>
2916 where
2917 St: AsRef<str>,
2918 {
2919 self._scopes.insert(String::from(scope.as_ref()));
2920 self
2921 }
2922 /// Identifies the authorization scope(s) for the method you are building.
2923 ///
2924 /// See [`Self::add_scope()`] for details.
2925 pub fn add_scopes<I, St>(mut self, scopes: I) -> NoteListCall<'a, C>
2926 where
2927 I: IntoIterator<Item = St>,
2928 St: AsRef<str>,
2929 {
2930 self._scopes
2931 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2932 self
2933 }
2934
2935 /// Removes all scopes, and no default scope will be used either.
2936 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2937 /// for details).
2938 pub fn clear_scopes(mut self) -> NoteListCall<'a, C> {
2939 self._scopes.clear();
2940 self
2941 }
2942}