google_gmail1/
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    /// Read, compose, send, and permanently delete all your email from Gmail
17    Gmai,
18
19    /// Manage drafts and send emails when you interact with the add-on
20    AddonCurrentActionCompose,
21
22    /// View your email messages when you interact with the add-on
23    AddonCurrentMessageAction,
24
25    /// View your email message metadata when the add-on is running
26    AddonCurrentMessageMetadata,
27
28    /// View your email messages when the add-on is running
29    AddonCurrentMessageReadonly,
30
31    /// Manage drafts and send emails
32    Compose,
33
34    /// Add emails into your Gmail mailbox
35    Insert,
36
37    /// See and edit your email labels
38    Label,
39
40    /// View your email message metadata such as labels and headers, but not the email body
41    Metadata,
42
43    /// Read, compose, and send emails from your Gmail account
44    Modify,
45
46    /// View your email messages and settings
47    Readonly,
48
49    /// Send email on your behalf
50    Send,
51
52    /// See, edit, create, or change your email settings and filters in Gmail
53    SettingBasic,
54
55    /// Manage your sensitive mail settings, including who can manage your mail
56    SettingSharing,
57}
58
59impl AsRef<str> for Scope {
60    fn as_ref(&self) -> &str {
61        match *self {
62            Scope::Gmai => "https://mail.google.com/",
63            Scope::AddonCurrentActionCompose => {
64                "https://www.googleapis.com/auth/gmail.addons.current.action.compose"
65            }
66            Scope::AddonCurrentMessageAction => {
67                "https://www.googleapis.com/auth/gmail.addons.current.message.action"
68            }
69            Scope::AddonCurrentMessageMetadata => {
70                "https://www.googleapis.com/auth/gmail.addons.current.message.metadata"
71            }
72            Scope::AddonCurrentMessageReadonly => {
73                "https://www.googleapis.com/auth/gmail.addons.current.message.readonly"
74            }
75            Scope::Compose => "https://www.googleapis.com/auth/gmail.compose",
76            Scope::Insert => "https://www.googleapis.com/auth/gmail.insert",
77            Scope::Label => "https://www.googleapis.com/auth/gmail.labels",
78            Scope::Metadata => "https://www.googleapis.com/auth/gmail.metadata",
79            Scope::Modify => "https://www.googleapis.com/auth/gmail.modify",
80            Scope::Readonly => "https://www.googleapis.com/auth/gmail.readonly",
81            Scope::Send => "https://www.googleapis.com/auth/gmail.send",
82            Scope::SettingBasic => "https://www.googleapis.com/auth/gmail.settings.basic",
83            Scope::SettingSharing => "https://www.googleapis.com/auth/gmail.settings.sharing",
84        }
85    }
86}
87
88#[allow(clippy::derivable_impls)]
89impl Default for Scope {
90    fn default() -> Scope {
91        Scope::AddonCurrentMessageReadonly
92    }
93}
94
95// ########
96// HUB ###
97// ######
98
99/// Central instance to access all Gmail related resource activities
100///
101/// # Examples
102///
103/// Instantiate a new hub
104///
105/// ```test_harness,no_run
106/// extern crate hyper;
107/// extern crate hyper_rustls;
108/// extern crate google_gmail1 as gmail1;
109/// use gmail1::api::Message;
110/// use gmail1::{Result, Error};
111/// use std::fs;
112/// # async fn dox() {
113/// use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
114///
115/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
116/// // `client_secret`, among other things.
117/// let secret: yup_oauth2::ApplicationSecret = Default::default();
118/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
119/// // unless you replace  `None` with the desired Flow.
120/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
121/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
122/// // retrieve them from storage.
123/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
124///     .with_native_roots()
125///     .unwrap()
126///     .https_only()
127///     .enable_http2()
128///     .build();
129///
130/// let executor = hyper_util::rt::TokioExecutor::new();
131/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
132///     secret,
133///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
134///     yup_oauth2::client::CustomHyperClientBuilder::from(
135///         hyper_util::client::legacy::Client::builder(executor).build(connector),
136///     ),
137/// ).build().await.unwrap();
138///
139/// let client = hyper_util::client::legacy::Client::builder(
140///     hyper_util::rt::TokioExecutor::new()
141/// )
142/// .build(
143///     hyper_rustls::HttpsConnectorBuilder::new()
144///         .with_native_roots()
145///         .unwrap()
146///         .https_or_http()
147///         .enable_http2()
148///         .build()
149/// );
150/// let mut hub = Gmail::new(client, auth);
151/// // As the method needs a request, you would usually fill it with the desired information
152/// // into the respective structure. Some of the parts shown here might not be applicable !
153/// // Values shown here are possibly random and not representative !
154/// let mut req = Message::default();
155///
156/// // You can configure optional parameters by calling the respective setters at will, and
157/// // execute the final call using `upload_resumable(...)`.
158/// // Values shown here are possibly random and not representative !
159/// let result = hub.users().messages_import(req, "userId")
160///              .process_for_calendar(true)
161///              .never_mark_spam(false)
162///              .internal_date_source("amet")
163///              .deleted(true)
164///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
165///
166/// match result {
167///     Err(e) => match e {
168///         // The Error enum provides details about what exactly happened.
169///         // You can also just use its `Debug`, `Display` or `Error` traits
170///          Error::HttpError(_)
171///         |Error::Io(_)
172///         |Error::MissingAPIKey
173///         |Error::MissingToken(_)
174///         |Error::Cancelled
175///         |Error::UploadSizeLimitExceeded(_, _)
176///         |Error::Failure(_)
177///         |Error::BadRequest(_)
178///         |Error::FieldClash(_)
179///         |Error::JsonDecodeError(_, _) => println!("{}", e),
180///     },
181///     Ok(res) => println!("Success: {:?}", res),
182/// }
183/// # }
184/// ```
185#[derive(Clone)]
186pub struct Gmail<C> {
187    pub client: common::Client<C>,
188    pub auth: Box<dyn common::GetToken>,
189    _user_agent: String,
190    _base_url: String,
191    _root_url: String,
192}
193
194impl<C> common::Hub for Gmail<C> {}
195
196impl<'a, C> Gmail<C> {
197    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Gmail<C> {
198        Gmail {
199            client,
200            auth: Box::new(auth),
201            _user_agent: "google-api-rust-client/7.0.0".to_string(),
202            _base_url: "https://gmail.googleapis.com/".to_string(),
203            _root_url: "https://gmail.googleapis.com/".to_string(),
204        }
205    }
206
207    pub fn users(&'a self) -> UserMethods<'a, C> {
208        UserMethods { hub: self }
209    }
210
211    /// Set the user-agent header field to use in all requests to the server.
212    /// It defaults to `google-api-rust-client/7.0.0`.
213    ///
214    /// Returns the previously set user-agent.
215    pub fn user_agent(&mut self, agent_name: String) -> String {
216        std::mem::replace(&mut self._user_agent, agent_name)
217    }
218
219    /// Set the base url to use in all requests to the server.
220    /// It defaults to `https://gmail.googleapis.com/`.
221    ///
222    /// Returns the previously set base url.
223    pub fn base_url(&mut self, new_base_url: String) -> String {
224        std::mem::replace(&mut self._base_url, new_base_url)
225    }
226
227    /// Set the root url to use in all requests to the server.
228    /// It defaults to `https://gmail.googleapis.com/`.
229    ///
230    /// Returns the previously set root url.
231    pub fn root_url(&mut self, new_root_url: String) -> String {
232        std::mem::replace(&mut self._root_url, new_root_url)
233    }
234}
235
236// ############
237// SCHEMAS ###
238// ##########
239/// Auto-forwarding settings for an account.
240///
241/// # Activities
242///
243/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
244/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
245///
246/// * [settings get auto forwarding users](UserSettingGetAutoForwardingCall) (response)
247/// * [settings update auto forwarding users](UserSettingUpdateAutoForwardingCall) (request|response)
248#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
249#[serde_with::serde_as]
250#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
251pub struct AutoForwarding {
252    /// The state that a message should be left in after it has been forwarded.
253    pub disposition: Option<String>,
254    /// Email address to which all incoming messages are forwarded. This email address must be a verified member of the forwarding addresses.
255    #[serde(rename = "emailAddress")]
256    pub email_address: Option<String>,
257    /// Whether all incoming mail is automatically forwarded to another address.
258    pub enabled: Option<bool>,
259}
260
261impl common::RequestValue for AutoForwarding {}
262impl common::ResponseResult for AutoForwarding {}
263
264/// There is no detailed description.
265///
266/// # Activities
267///
268/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
269/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
270///
271/// * [messages batch delete users](UserMessageBatchDeleteCall) (request)
272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
273#[serde_with::serde_as]
274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
275pub struct BatchDeleteMessagesRequest {
276    /// The IDs of the messages to delete.
277    pub ids: Option<Vec<String>>,
278}
279
280impl common::RequestValue for BatchDeleteMessagesRequest {}
281
282/// There is no detailed description.
283///
284/// # Activities
285///
286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
288///
289/// * [messages batch modify users](UserMessageBatchModifyCall) (request)
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct BatchModifyMessagesRequest {
294    /// A list of label IDs to add to messages.
295    #[serde(rename = "addLabelIds")]
296    pub add_label_ids: Option<Vec<String>>,
297    /// The IDs of the messages to modify. There is a limit of 1000 ids per request.
298    pub ids: Option<Vec<String>>,
299    /// A list of label IDs to remove from messages.
300    #[serde(rename = "removeLabelIds")]
301    pub remove_label_ids: Option<Vec<String>>,
302}
303
304impl common::RequestValue for BatchModifyMessagesRequest {}
305
306/// Field values for a classification label.
307///
308/// This type is not used in any activity, and only used as *part* of another schema.
309///
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct ClassificationLabelFieldValue {
314    /// Required. The field ID for the Classification Label Value. Maps to the ID field of the Google Drive `Label.Field` object.
315    #[serde(rename = "fieldId")]
316    pub field_id: Option<String>,
317    /// Selection choice ID for the selection option. Should only be set if the field type is `SELECTION` in the Google Drive `Label.Field` object. Maps to the id field of the Google Drive `Label.Field.SelectionOptions` resource.
318    pub selection: Option<String>,
319}
320
321impl common::Part for ClassificationLabelFieldValue {}
322
323/// Classification Labels applied to the email message. Classification Labels are different from Gmail inbox labels. Only used for Google Workspace accounts. [Learn more about classification labels](https://support.google.com/a/answer/9292382).
324///
325/// This type is not used in any activity, and only used as *part* of another schema.
326///
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct ClassificationLabelValue {
331    /// Field values for the given classification label ID.
332    pub fields: Option<Vec<ClassificationLabelFieldValue>>,
333    /// Required. The canonical or raw alphanumeric classification label ID. Maps to the ID field of the Google Drive Label resource.
334    #[serde(rename = "labelId")]
335    pub label_id: Option<String>,
336}
337
338impl common::Part for ClassificationLabelValue {}
339
340/// The client-side encryption (CSE) configuration for the email address of an authenticated user. Gmail uses CSE configurations to save drafts of client-side encrypted email messages, and to sign and send encrypted email messages. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
341///
342/// # Activities
343///
344/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
345/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
346///
347/// * [settings cse identities create users](UserSettingCseIdentityCreateCall) (request|response)
348/// * [settings cse identities get users](UserSettingCseIdentityGetCall) (response)
349/// * [settings cse identities patch users](UserSettingCseIdentityPatchCall) (request|response)
350#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
351#[serde_with::serde_as]
352#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
353pub struct CseIdentity {
354    /// The email address for the sending identity. The email address must be the primary email address of the authenticated user.
355    #[serde(rename = "emailAddress")]
356    pub email_address: Option<String>,
357    /// If a key pair is associated, the ID of the key pair, CseKeyPair.
358    #[serde(rename = "primaryKeyPairId")]
359    pub primary_key_pair_id: Option<String>,
360    /// The configuration of a CSE identity that uses different key pairs for signing and encryption.
361    #[serde(rename = "signAndEncryptKeyPairs")]
362    pub sign_and_encrypt_key_pairs: Option<SignAndEncryptKeyPairs>,
363}
364
365impl common::RequestValue for CseIdentity {}
366impl common::ResponseResult for CseIdentity {}
367
368/// A client-side encryption S/MIME key pair, which is comprised of a public key, its certificate chain, and metadata for its paired private key. Gmail uses the key pair to complete the following tasks: - Sign outgoing client-side encrypted messages. - Save and reopen drafts of client-side encrypted messages. - Save and reopen sent messages. - Decrypt incoming or archived S/MIME messages. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [settings cse keypairs create users](UserSettingCseKeypairCreateCall) (request|response)
376/// * [settings cse keypairs disable users](UserSettingCseKeypairDisableCall) (response)
377/// * [settings cse keypairs enable users](UserSettingCseKeypairEnableCall) (response)
378/// * [settings cse keypairs get users](UserSettingCseKeypairGetCall) (response)
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct CseKeyPair {
383    /// Output only. If a key pair is set to `DISABLED`, the time that the key pair's state changed from `ENABLED` to `DISABLED`. This field is present only when the key pair is in state `DISABLED`.
384    #[serde(rename = "disableTime")]
385    pub disable_time: Option<chrono::DateTime<chrono::offset::Utc>>,
386    /// Output only. The current state of the key pair.
387    #[serde(rename = "enablementState")]
388    pub enablement_state: Option<String>,
389    /// Output only. The immutable ID for the client-side encryption S/MIME key pair.
390    #[serde(rename = "keyPairId")]
391    pub key_pair_id: Option<String>,
392    /// Output only. The public key and its certificate chain, in [PEM](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail) format.
393    pub pem: Option<String>,
394    /// Input only. The public key and its certificate chain. The chain must be in [PKCS#7](https://en.wikipedia.org/wiki/PKCS_7) format and use PEM encoding and ASCII armor.
395    pub pkcs7: Option<String>,
396    /// Metadata for instances of this key pair's private key.
397    #[serde(rename = "privateKeyMetadata")]
398    pub private_key_metadata: Option<Vec<CsePrivateKeyMetadata>>,
399    /// Output only. The email address identities that are specified on the leaf certificate.
400    #[serde(rename = "subjectEmailAddresses")]
401    pub subject_email_addresses: Option<Vec<String>>,
402}
403
404impl common::RequestValue for CseKeyPair {}
405impl common::ResponseResult for CseKeyPair {}
406
407/// Metadata for a private key instance.
408///
409/// This type is not used in any activity, and only used as *part* of another schema.
410///
411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
412#[serde_with::serde_as]
413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
414pub struct CsePrivateKeyMetadata {
415    /// Metadata for hardware keys.
416    #[serde(rename = "hardwareKeyMetadata")]
417    pub hardware_key_metadata: Option<HardwareKeyMetadata>,
418    /// Metadata for a private key instance managed by an external key access control list service.
419    #[serde(rename = "kaclsKeyMetadata")]
420    pub kacls_key_metadata: Option<KaclsKeyMetadata>,
421    /// Output only. The immutable ID for the private key metadata instance.
422    #[serde(rename = "privateKeyMetadataId")]
423    pub private_key_metadata_id: Option<String>,
424}
425
426impl common::Part for CsePrivateKeyMetadata {}
427
428/// Settings for a delegate. Delegates can read, send, and delete messages, as well as view and add contacts, for the delegator’s account. See “Set up mail delegation” for more information about delegates.
429///
430/// # Activities
431///
432/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
433/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
434///
435/// * [settings delegates create users](UserSettingDelegateCreateCall) (request|response)
436/// * [settings delegates get users](UserSettingDelegateGetCall) (response)
437#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
438#[serde_with::serde_as]
439#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
440pub struct Delegate {
441    /// The email address of the delegate.
442    #[serde(rename = "delegateEmail")]
443    pub delegate_email: Option<String>,
444    /// Indicates whether this address has been verified and can act as a delegate for the account. Read-only.
445    #[serde(rename = "verificationStatus")]
446    pub verification_status: Option<String>,
447}
448
449impl common::RequestValue for Delegate {}
450impl common::ResponseResult for Delegate {}
451
452/// Requests to turn off a client-side encryption key pair.
453///
454/// # Activities
455///
456/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
457/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
458///
459/// * [settings cse keypairs disable users](UserSettingCseKeypairDisableCall) (request)
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct DisableCseKeyPairRequest {
464    _never_set: Option<bool>,
465}
466
467impl common::RequestValue for DisableCseKeyPairRequest {}
468
469/// A draft email in the user’s mailbox.
470///
471/// # Activities
472///
473/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
474/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
475///
476/// * [drafts create users](UserDraftCreateCall) (request|response)
477/// * [drafts get users](UserDraftGetCall) (response)
478/// * [drafts send users](UserDraftSendCall) (request)
479/// * [drafts update users](UserDraftUpdateCall) (request|response)
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct Draft {
484    /// The immutable ID of the draft.
485    pub id: Option<String>,
486    /// The message content of the draft.
487    pub message: Option<Message>,
488}
489
490impl common::RequestValue for Draft {}
491impl common::ResponseResult for Draft {}
492
493/// Requests to turn on a client-side encryption key pair.
494///
495/// # Activities
496///
497/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
498/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
499///
500/// * [settings cse keypairs enable users](UserSettingCseKeypairEnableCall) (request)
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct EnableCseKeyPairRequest {
505    _never_set: Option<bool>,
506}
507
508impl common::RequestValue for EnableCseKeyPairRequest {}
509
510/// Resource definition for Gmail filters. Filters apply to specific messages instead of an entire email thread.
511///
512/// # Activities
513///
514/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
515/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
516///
517/// * [settings filters create users](UserSettingFilterCreateCall) (request|response)
518/// * [settings filters get users](UserSettingFilterGetCall) (response)
519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
520#[serde_with::serde_as]
521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
522pub struct Filter {
523    /// Action that the filter performs.
524    pub action: Option<FilterAction>,
525    /// Matching criteria for the filter.
526    pub criteria: Option<FilterCriteria>,
527    /// The server assigned ID of the filter.
528    pub id: Option<String>,
529}
530
531impl common::RequestValue for Filter {}
532impl common::ResponseResult for Filter {}
533
534/// A set of actions to perform on a message.
535///
536/// This type is not used in any activity, and only used as *part* of another schema.
537///
538#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
539#[serde_with::serde_as]
540#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
541pub struct FilterAction {
542    /// List of labels to add to the message.
543    #[serde(rename = "addLabelIds")]
544    pub add_label_ids: Option<Vec<String>>,
545    /// Email address that the message should be forwarded to.
546    pub forward: Option<String>,
547    /// List of labels to remove from the message.
548    #[serde(rename = "removeLabelIds")]
549    pub remove_label_ids: Option<Vec<String>>,
550}
551
552impl common::Part for FilterAction {}
553
554/// Message matching criteria.
555///
556/// This type is not used in any activity, and only used as *part* of another schema.
557///
558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
559#[serde_with::serde_as]
560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
561pub struct FilterCriteria {
562    /// Whether the response should exclude chats.
563    #[serde(rename = "excludeChats")]
564    pub exclude_chats: Option<bool>,
565    /// The sender's display name or email address.
566    pub from: Option<String>,
567    /// Whether the message has any attachment.
568    #[serde(rename = "hasAttachment")]
569    pub has_attachment: Option<bool>,
570    /// Only return messages not matching the specified query. Supports the same query format as the Gmail search box. For example, `"from:someuser@example.com rfc822msgid: is:unread"`.
571    #[serde(rename = "negatedQuery")]
572    pub negated_query: Option<String>,
573    /// Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, `"from:someuser@example.com rfc822msgid: is:unread"`.
574    pub query: Option<String>,
575    /// The size of the entire RFC822 message in bytes, including all headers and attachments.
576    pub size: Option<i32>,
577    /// How the message size in bytes should be in relation to the size field.
578    #[serde(rename = "sizeComparison")]
579    pub size_comparison: Option<String>,
580    /// Case-insensitive phrase found in the message's subject. Trailing and leading whitespace are be trimmed and adjacent spaces are collapsed.
581    pub subject: Option<String>,
582    /// The recipient's display name or email address. Includes recipients in the "to", "cc", and "bcc" header fields. You can use simply the local part of the email address. For example, "example" and "example@" both match "example@gmail.com". This field is case-insensitive.
583    pub to: Option<String>,
584}
585
586impl common::Part for FilterCriteria {}
587
588/// Settings for a forwarding address.
589///
590/// # Activities
591///
592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
594///
595/// * [settings forwarding addresses create users](UserSettingForwardingAddressCreateCall) (request|response)
596/// * [settings forwarding addresses get users](UserSettingForwardingAddressGetCall) (response)
597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
598#[serde_with::serde_as]
599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
600pub struct ForwardingAddress {
601    /// An email address to which messages can be forwarded.
602    #[serde(rename = "forwardingEmail")]
603    pub forwarding_email: Option<String>,
604    /// Indicates whether this address has been verified and is usable for forwarding. Read-only.
605    #[serde(rename = "verificationStatus")]
606    pub verification_status: Option<String>,
607}
608
609impl common::RequestValue for ForwardingAddress {}
610impl common::ResponseResult for ForwardingAddress {}
611
612/// Metadata for hardware keys. If [hardware key encryption](https://support.google.com/a/answer/14153163) is set up for the Google Workspace organization, users can optionally store their private key on their smart card and use it to sign and decrypt email messages in Gmail by inserting their smart card into a reader attached to their Windows device.
613///
614/// This type is not used in any activity, and only used as *part* of another schema.
615///
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct HardwareKeyMetadata {
620    /// Description about the hardware key.
621    pub description: Option<String>,
622}
623
624impl common::Part for HardwareKeyMetadata {}
625
626/// A record of a change to the user's mailbox. Each history change may affect multiple messages in multiple ways.
627///
628/// This type is not used in any activity, and only used as *part* of another schema.
629///
630#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
631#[serde_with::serde_as]
632#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
633pub struct History {
634    /// The mailbox sequence ID.
635    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
636    pub id: Option<u64>,
637    /// Labels added to messages in this history record.
638    #[serde(rename = "labelsAdded")]
639    pub labels_added: Option<Vec<HistoryLabelAdded>>,
640    /// Labels removed from messages in this history record.
641    #[serde(rename = "labelsRemoved")]
642    pub labels_removed: Option<Vec<HistoryLabelRemoved>>,
643    /// List of messages changed in this history record. The fields for specific change types, such as `messagesAdded` may duplicate messages in this field. We recommend using the specific change-type fields instead of this.
644    pub messages: Option<Vec<Message>>,
645    /// Messages added to the mailbox in this history record.
646    #[serde(rename = "messagesAdded")]
647    pub messages_added: Option<Vec<HistoryMessageAdded>>,
648    /// Messages deleted (not Trashed) from the mailbox in this history record.
649    #[serde(rename = "messagesDeleted")]
650    pub messages_deleted: Option<Vec<HistoryMessageDeleted>>,
651}
652
653impl common::Part for History {}
654
655/// There is no detailed description.
656///
657/// This type is not used in any activity, and only used as *part* of another schema.
658///
659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
660#[serde_with::serde_as]
661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
662pub struct HistoryLabelAdded {
663    /// Label IDs added to the message.
664    #[serde(rename = "labelIds")]
665    pub label_ids: Option<Vec<String>>,
666    /// no description provided
667    pub message: Option<Message>,
668}
669
670impl common::Part for HistoryLabelAdded {}
671
672/// There is no detailed description.
673///
674/// This type is not used in any activity, and only used as *part* of another schema.
675///
676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
677#[serde_with::serde_as]
678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
679pub struct HistoryLabelRemoved {
680    /// Label IDs removed from the message.
681    #[serde(rename = "labelIds")]
682    pub label_ids: Option<Vec<String>>,
683    /// no description provided
684    pub message: Option<Message>,
685}
686
687impl common::Part for HistoryLabelRemoved {}
688
689/// There is no detailed description.
690///
691/// This type is not used in any activity, and only used as *part* of another schema.
692///
693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
694#[serde_with::serde_as]
695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
696pub struct HistoryMessageAdded {
697    /// no description provided
698    pub message: Option<Message>,
699}
700
701impl common::Part for HistoryMessageAdded {}
702
703/// There is no detailed description.
704///
705/// This type is not used in any activity, and only used as *part* of another schema.
706///
707#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
708#[serde_with::serde_as]
709#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
710pub struct HistoryMessageDeleted {
711    /// no description provided
712    pub message: Option<Message>,
713}
714
715impl common::Part for HistoryMessageDeleted {}
716
717/// IMAP settings for an account.
718///
719/// # Activities
720///
721/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
722/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
723///
724/// * [settings get imap users](UserSettingGetImapCall) (response)
725/// * [settings update imap users](UserSettingUpdateImapCall) (request|response)
726#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
727#[serde_with::serde_as]
728#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
729pub struct ImapSettings {
730    /// If this value is true, Gmail will immediately expunge a message when it is marked as deleted in IMAP. Otherwise, Gmail will wait for an update from the client before expunging messages marked as deleted.
731    #[serde(rename = "autoExpunge")]
732    pub auto_expunge: Option<bool>,
733    /// Whether IMAP is enabled for the account.
734    pub enabled: Option<bool>,
735    /// The action that will be executed on a message when it is marked as deleted and expunged from the last visible IMAP folder.
736    #[serde(rename = "expungeBehavior")]
737    pub expunge_behavior: Option<String>,
738    /// An optional limit on the number of messages that an IMAP folder may contain. Legal values are 0, 1000, 2000, 5000 or 10000. A value of zero is interpreted to mean that there is no limit.
739    #[serde(rename = "maxFolderSize")]
740    pub max_folder_size: Option<i32>,
741}
742
743impl common::RequestValue for ImapSettings {}
744impl common::ResponseResult for ImapSettings {}
745
746/// Metadata for private keys managed by an external key access control list service. For details about managing key access, see [Google Workspace CSE API Reference](https://developers.google.com/workspace/cse/reference).
747///
748/// This type is not used in any activity, and only used as *part* of another schema.
749///
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct KaclsKeyMetadata {
754    /// Opaque data generated and used by the key access control list service. Maximum size: 8 KiB.
755    #[serde(rename = "kaclsData")]
756    pub kacls_data: Option<String>,
757    /// The URI of the key access control list service that manages the private key.
758    #[serde(rename = "kaclsUri")]
759    pub kacls_uri: Option<String>,
760}
761
762impl common::Part for KaclsKeyMetadata {}
763
764/// Labels are used to categorize messages and threads within the user’s mailbox. The maximum number of labels supported for a user’s mailbox is 10,000.
765///
766/// # Activities
767///
768/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
769/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
770///
771/// * [labels create users](UserLabelCreateCall) (request|response)
772/// * [labels get users](UserLabelGetCall) (response)
773/// * [labels patch users](UserLabelPatchCall) (request|response)
774/// * [labels update users](UserLabelUpdateCall) (request|response)
775#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
776#[serde_with::serde_as]
777#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
778pub struct Label {
779    /// The color to assign to the label. Color is only available for labels that have their `type` set to `user`.
780    pub color: Option<LabelColor>,
781    /// The immutable ID of the label.
782    pub id: Option<String>,
783    /// The visibility of the label in the label list in the Gmail web interface.
784    #[serde(rename = "labelListVisibility")]
785    pub label_list_visibility: Option<String>,
786    /// The visibility of messages with this label in the message list in the Gmail web interface.
787    #[serde(rename = "messageListVisibility")]
788    pub message_list_visibility: Option<String>,
789    /// The total number of messages with the label.
790    #[serde(rename = "messagesTotal")]
791    pub messages_total: Option<i32>,
792    /// The number of unread messages with the label.
793    #[serde(rename = "messagesUnread")]
794    pub messages_unread: Option<i32>,
795    /// The display name of the label.
796    pub name: Option<String>,
797    /// The total number of threads with the label.
798    #[serde(rename = "threadsTotal")]
799    pub threads_total: Option<i32>,
800    /// The number of unread threads with the label.
801    #[serde(rename = "threadsUnread")]
802    pub threads_unread: Option<i32>,
803    /// The owner type for the label. User labels are created by the user and can be modified and deleted by the user and can be applied to any message or thread. System labels are internally created and cannot be added, modified, or deleted. System labels may be able to be applied to or removed from messages and threads under some circumstances but this is not guaranteed. For example, users can apply and remove the `INBOX` and `UNREAD` labels from messages and threads, but cannot apply or remove the `DRAFTS` or `SENT` labels from messages or threads.
804    #[serde(rename = "type")]
805    pub type_: Option<String>,
806}
807
808impl common::RequestValue for Label {}
809impl common::ResponseResult for Label {}
810
811/// There is no detailed description.
812///
813/// This type is not used in any activity, and only used as *part* of another schema.
814///
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct LabelColor {
819    /// The background color represented as hex string #RRGGBB (ex #000000). This field is required in order to set the color of a label. Only the following predefined set of color values are allowed: \#000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3, #ffffff, \#fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8, #a479e2, #f691b3, \#f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de, #c9daf8, #e4d7f5, #fcdee8, \#efa093, #ffd6a2, #fce8b3, #89d3b2, #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, \#e66550, #ffbc6b, #fcda83, #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, \#cc3a21, #eaa041, #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, \#ac2b16, #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775, \#822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d, #83334c \#464646, #e7e7e7, #0d3472, #b6cff5, #0d3b44, #98d7e4, #3d188e, #e3d7ff, \#711a36, #fbd3e0, #8a1c0a, #f2b2a8, #7a2e0b, #ffc8af, #7a4706, #ffdeb5, \#594c05, #fbe983, #684e07, #fdedc1, #0b4f30, #b3efd3, #04502e, #a2dcc1, \#c2c2c2, #4986e7, #2da2bb, #b99aff, #994a64, #f691b2, #ff7537, #ffad46, \#662e37, #ebdbde, #cca6ac, #094228, #42d692, #16a765
820    #[serde(rename = "backgroundColor")]
821    pub background_color: Option<String>,
822    /// The text color of the label, represented as hex string. This field is required in order to set the color of a label. Only the following predefined set of color values are allowed: \#000000, #434343, #666666, #999999, #cccccc, #efefef, #f3f3f3, #ffffff, \#fb4c2f, #ffad47, #fad165, #16a766, #43d692, #4a86e8, #a479e2, #f691b3, \#f6c5be, #ffe6c7, #fef1d1, #b9e4d0, #c6f3de, #c9daf8, #e4d7f5, #fcdee8, \#efa093, #ffd6a2, #fce8b3, #89d3b2, #a0eac9, #a4c2f4, #d0bcf1, #fbc8d9, \#e66550, #ffbc6b, #fcda83, #44b984, #68dfa9, #6d9eeb, #b694e8, #f7a7c0, \#cc3a21, #eaa041, #f2c960, #149e60, #3dc789, #3c78d8, #8e63ce, #e07798, \#ac2b16, #cf8933, #d5ae49, #0b804b, #2a9c68, #285bac, #653e9b, #b65775, \#822111, #a46a21, #aa8831, #076239, #1a764d, #1c4587, #41236d, #83334c \#464646, #e7e7e7, #0d3472, #b6cff5, #0d3b44, #98d7e4, #3d188e, #e3d7ff, \#711a36, #fbd3e0, #8a1c0a, #f2b2a8, #7a2e0b, #ffc8af, #7a4706, #ffdeb5, \#594c05, #fbe983, #684e07, #fdedc1, #0b4f30, #b3efd3, #04502e, #a2dcc1, \#c2c2c2, #4986e7, #2da2bb, #b99aff, #994a64, #f691b2, #ff7537, #ffad46, \#662e37, #ebdbde, #cca6ac, #094228, #42d692, #16a765
823    #[serde(rename = "textColor")]
824    pub text_color: Option<String>,
825}
826
827impl common::Part for LabelColor {}
828
829/// Language settings for an account. These settings correspond to the “Language settings” feature in the web interface.
830///
831/// # Activities
832///
833/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
834/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
835///
836/// * [settings get language users](UserSettingGetLanguageCall) (response)
837/// * [settings update language users](UserSettingUpdateLanguageCall) (request|response)
838#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
839#[serde_with::serde_as]
840#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
841pub struct LanguageSettings {
842    /// The language to display Gmail in, formatted as an RFC 3066 Language Tag (for example `en-GB`, `fr` or `ja` for British English, French, or Japanese respectively). The set of languages supported by Gmail evolves over time, so please refer to the "Language" dropdown in the Gmail settings for all available options, as described in the language settings help article. For a table of sample values, see [Manage language settings](https://developers.google.com/workspace/gmail/api/guides/language-settings). Not all Gmail clients can display the same set of languages. In the case that a user's display language is not available for use on a particular client, said client automatically chooses to display in the closest supported variant (or a reasonable default).
843    #[serde(rename = "displayLanguage")]
844    pub display_language: Option<String>,
845}
846
847impl common::RequestValue for LanguageSettings {}
848impl common::ResponseResult for LanguageSettings {}
849
850/// There is no detailed description.
851///
852/// # Activities
853///
854/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
855/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
856///
857/// * [settings cse identities list users](UserSettingCseIdentityListCall) (response)
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct ListCseIdentitiesResponse {
862    /// One page of the list of CSE identities configured for the user.
863    #[serde(rename = "cseIdentities")]
864    pub cse_identities: Option<Vec<CseIdentity>>,
865    /// Pagination token to be passed to a subsequent ListCseIdentities call in order to retrieve the next page of identities. If this value is not returned or is the empty string, then no further pages remain.
866    #[serde(rename = "nextPageToken")]
867    pub next_page_token: Option<String>,
868}
869
870impl common::ResponseResult for ListCseIdentitiesResponse {}
871
872/// There is no detailed description.
873///
874/// # Activities
875///
876/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
877/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
878///
879/// * [settings cse keypairs list users](UserSettingCseKeypairListCall) (response)
880#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
881#[serde_with::serde_as]
882#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
883pub struct ListCseKeyPairsResponse {
884    /// One page of the list of CSE key pairs installed for the user.
885    #[serde(rename = "cseKeyPairs")]
886    pub cse_key_pairs: Option<Vec<CseKeyPair>>,
887    /// Pagination token to be passed to a subsequent ListCseKeyPairs call in order to retrieve the next page of key pairs. If this value is not returned, then no further pages remain.
888    #[serde(rename = "nextPageToken")]
889    pub next_page_token: Option<String>,
890}
891
892impl common::ResponseResult for ListCseKeyPairsResponse {}
893
894/// Response for the ListDelegates method.
895///
896/// # Activities
897///
898/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
899/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
900///
901/// * [settings delegates list users](UserSettingDelegateListCall) (response)
902#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
903#[serde_with::serde_as]
904#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
905pub struct ListDelegatesResponse {
906    /// List of the user's delegates (with any verification status). If an account doesn't have delegates, this field doesn't appear.
907    pub delegates: Option<Vec<Delegate>>,
908}
909
910impl common::ResponseResult for ListDelegatesResponse {}
911
912/// There is no detailed description.
913///
914/// # Activities
915///
916/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
917/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
918///
919/// * [drafts list users](UserDraftListCall) (response)
920#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
921#[serde_with::serde_as]
922#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
923pub struct ListDraftsResponse {
924    /// List of drafts. Note that the `Message` property in each `Draft` resource only contains an `id` and a `threadId`. The [`messages.get`](https://developers.google.com/workspace/gmail/api/v1/reference/users/messages/get) method can fetch additional message details.
925    pub drafts: Option<Vec<Draft>>,
926    /// Token to retrieve the next page of results in the list.
927    #[serde(rename = "nextPageToken")]
928    pub next_page_token: Option<String>,
929    /// Estimated total number of results.
930    #[serde(rename = "resultSizeEstimate")]
931    pub result_size_estimate: Option<u32>,
932}
933
934impl common::ResponseResult for ListDraftsResponse {}
935
936/// Response for the ListFilters method.
937///
938/// # Activities
939///
940/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
941/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
942///
943/// * [settings filters list users](UserSettingFilterListCall) (response)
944#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
945#[serde_with::serde_as]
946#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
947pub struct ListFiltersResponse {
948    /// List of a user's filters.
949    pub filter: Option<Vec<Filter>>,
950}
951
952impl common::ResponseResult for ListFiltersResponse {}
953
954/// Response for the ListForwardingAddresses method.
955///
956/// # Activities
957///
958/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
959/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
960///
961/// * [settings forwarding addresses list users](UserSettingForwardingAddressListCall) (response)
962#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
963#[serde_with::serde_as]
964#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
965pub struct ListForwardingAddressesResponse {
966    /// List of addresses that may be used for forwarding.
967    #[serde(rename = "forwardingAddresses")]
968    pub forwarding_addresses: Option<Vec<ForwardingAddress>>,
969}
970
971impl common::ResponseResult for ListForwardingAddressesResponse {}
972
973/// There is no detailed description.
974///
975/// # Activities
976///
977/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
978/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
979///
980/// * [history list users](UserHistoryListCall) (response)
981#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
982#[serde_with::serde_as]
983#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
984pub struct ListHistoryResponse {
985    /// List of history records. Any `messages` contained in the response will typically only have `id` and `threadId` fields populated.
986    pub history: Option<Vec<History>>,
987    /// The ID of the mailbox's current history record.
988    #[serde(rename = "historyId")]
989    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
990    pub history_id: Option<u64>,
991    /// Page token to retrieve the next page of results in the list.
992    #[serde(rename = "nextPageToken")]
993    pub next_page_token: Option<String>,
994}
995
996impl common::ResponseResult for ListHistoryResponse {}
997
998/// There is no detailed description.
999///
1000/// # Activities
1001///
1002/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1003/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1004///
1005/// * [labels list users](UserLabelListCall) (response)
1006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1007#[serde_with::serde_as]
1008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1009pub struct ListLabelsResponse {
1010    /// List of labels. Note that each label resource only contains an `id`, `name`, `messageListVisibility`, `labelListVisibility`, and `type`. The [`labels.get`](https://developers.google.com/workspace/gmail/api/v1/reference/users/labels/get) method can fetch additional label details.
1011    pub labels: Option<Vec<Label>>,
1012}
1013
1014impl common::ResponseResult for ListLabelsResponse {}
1015
1016/// There is no detailed description.
1017///
1018/// # Activities
1019///
1020/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1021/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1022///
1023/// * [messages list users](UserMessageListCall) (response)
1024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1025#[serde_with::serde_as]
1026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1027pub struct ListMessagesResponse {
1028    /// List of messages. Note that each message resource contains only an `id` and a `threadId`. Additional message details can be fetched using the messages.get method.
1029    pub messages: Option<Vec<Message>>,
1030    /// Token to retrieve the next page of results in the list.
1031    #[serde(rename = "nextPageToken")]
1032    pub next_page_token: Option<String>,
1033    /// Estimated total number of results.
1034    #[serde(rename = "resultSizeEstimate")]
1035    pub result_size_estimate: Option<u32>,
1036}
1037
1038impl common::ResponseResult for ListMessagesResponse {}
1039
1040/// Response for the ListSendAs method.
1041///
1042/// # Activities
1043///
1044/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1045/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1046///
1047/// * [settings send as list users](UserSettingSendAListCall) (response)
1048#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1049#[serde_with::serde_as]
1050#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1051pub struct ListSendAsResponse {
1052    /// List of send-as aliases.
1053    #[serde(rename = "sendAs")]
1054    pub send_as: Option<Vec<SendAs>>,
1055}
1056
1057impl common::ResponseResult for ListSendAsResponse {}
1058
1059/// There is no detailed description.
1060///
1061/// # Activities
1062///
1063/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1064/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1065///
1066/// * [settings send as smime info list users](UserSettingSendASmimeInfoListCall) (response)
1067#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1068#[serde_with::serde_as]
1069#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1070pub struct ListSmimeInfoResponse {
1071    /// List of SmimeInfo.
1072    #[serde(rename = "smimeInfo")]
1073    pub smime_info: Option<Vec<SmimeInfo>>,
1074}
1075
1076impl common::ResponseResult for ListSmimeInfoResponse {}
1077
1078/// There is no detailed description.
1079///
1080/// # Activities
1081///
1082/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1083/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1084///
1085/// * [threads list users](UserThreadListCall) (response)
1086#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1087#[serde_with::serde_as]
1088#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1089pub struct ListThreadsResponse {
1090    /// Page token to retrieve the next page of results in the list.
1091    #[serde(rename = "nextPageToken")]
1092    pub next_page_token: Option<String>,
1093    /// Estimated total number of results.
1094    #[serde(rename = "resultSizeEstimate")]
1095    pub result_size_estimate: Option<u32>,
1096    /// List of threads. Note that each thread resource does not contain a list of `messages`. The list of `messages` for a given thread can be fetched using the [`threads.get`](https://developers.google.com/workspace/gmail/api/v1/reference/users/threads/get) method.
1097    pub threads: Option<Vec<Thread>>,
1098}
1099
1100impl common::ResponseResult for ListThreadsResponse {}
1101
1102/// An email message.
1103///
1104/// # Activities
1105///
1106/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1107/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1108///
1109/// * [drafts send users](UserDraftSendCall) (response)
1110/// * [messages get users](UserMessageGetCall) (response)
1111/// * [messages import users](UserMessageImportCall) (request|response)
1112/// * [messages insert users](UserMessageInsertCall) (request|response)
1113/// * [messages modify users](UserMessageModifyCall) (response)
1114/// * [messages send users](UserMessageSendCall) (request|response)
1115/// * [messages trash users](UserMessageTrashCall) (response)
1116/// * [messages untrash users](UserMessageUntrashCall) (response)
1117#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1118#[serde_with::serde_as]
1119#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1120pub struct Message {
1121    /// Classification Label values on the message. Available Classification Label schemas can be queried using the Google Drive Labels API. Each classification label ID must be unique. If duplicate IDs are provided, only one will be retained, and the selection is arbitrary. Only used for Google Workspace accounts.
1122    #[serde(rename = "classificationLabelValues")]
1123    pub classification_label_values: Option<Vec<ClassificationLabelValue>>,
1124    /// The ID of the last history record that modified this message.
1125    #[serde(rename = "historyId")]
1126    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1127    pub history_id: Option<u64>,
1128    /// The immutable ID of the message.
1129    pub id: Option<String>,
1130    /// The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
1131    #[serde(rename = "internalDate")]
1132    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1133    pub internal_date: Option<i64>,
1134    /// List of IDs of labels applied to this message.
1135    #[serde(rename = "labelIds")]
1136    pub label_ids: Option<Vec<String>>,
1137    /// The parsed email structure in the message parts.
1138    pub payload: Option<MessagePart>,
1139    /// The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied.
1140    #[serde_as(as = "Option<common::serde::urlsafe_base64::Wrapper>")]
1141    pub raw: Option<Vec<u8>>,
1142    /// Estimated size in bytes of the message.
1143    #[serde(rename = "sizeEstimate")]
1144    pub size_estimate: Option<i32>,
1145    /// A short part of the message text.
1146    pub snippet: Option<String>,
1147    /// The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
1148    #[serde(rename = "threadId")]
1149    pub thread_id: Option<String>,
1150}
1151
1152impl common::RequestValue for Message {}
1153impl common::ResponseResult for Message {}
1154
1155/// A single MIME message part.
1156///
1157/// This type is not used in any activity, and only used as *part* of another schema.
1158///
1159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1160#[serde_with::serde_as]
1161#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1162pub struct MessagePart {
1163    /// The message part body for this part, which may be empty for container MIME message parts.
1164    pub body: Option<MessagePartBody>,
1165    /// The filename of the attachment. Only present if this message part represents an attachment.
1166    pub filename: Option<String>,
1167    /// List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as `To`, `From`, and `Subject`.
1168    pub headers: Option<Vec<MessagePartHeader>>,
1169    /// The MIME type of the message part.
1170    #[serde(rename = "mimeType")]
1171    pub mime_type: Option<String>,
1172    /// The immutable ID of the message part.
1173    #[serde(rename = "partId")]
1174    pub part_id: Option<String>,
1175    /// The child MIME message parts of this part. This only applies to container MIME message parts, for example `multipart/*`. For non- container MIME message part types, such as `text/plain`, this field is empty. For more information, see RFC 1521.
1176    pub parts: Option<Vec<MessagePart>>,
1177}
1178
1179impl common::Part for MessagePart {}
1180
1181/// The body of a single MIME message part.
1182///
1183/// # Activities
1184///
1185/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1186/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1187///
1188/// * [messages attachments get users](UserMessageAttachmentGetCall) (response)
1189#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1190#[serde_with::serde_as]
1191#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1192pub struct MessagePartBody {
1193    /// When present, contains the ID of an external attachment that can be retrieved in a separate `messages.attachments.get` request. When not present, the entire content of the message part body is contained in the data field.
1194    #[serde(rename = "attachmentId")]
1195    pub attachment_id: Option<String>,
1196    /// The body data of a MIME message part as a base64url encoded string. May be empty for MIME container types that have no message body or when the body data is sent as a separate attachment. An attachment ID is present if the body data is contained in a separate attachment.
1197    #[serde_as(as = "Option<common::serde::urlsafe_base64::Wrapper>")]
1198    pub data: Option<Vec<u8>>,
1199    /// Number of bytes for the message part data (encoding notwithstanding).
1200    pub size: Option<i32>,
1201}
1202
1203impl common::ResponseResult for MessagePartBody {}
1204
1205/// There is no detailed description.
1206///
1207/// This type is not used in any activity, and only used as *part* of another schema.
1208///
1209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1210#[serde_with::serde_as]
1211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1212pub struct MessagePartHeader {
1213    /// The name of the header before the `:` separator. For example, `To`.
1214    pub name: Option<String>,
1215    /// The value of the header after the `:` separator. For example, `someuser@example.com`.
1216    pub value: Option<String>,
1217}
1218
1219impl common::Part for MessagePartHeader {}
1220
1221/// There is no detailed description.
1222///
1223/// # Activities
1224///
1225/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1226/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1227///
1228/// * [messages modify users](UserMessageModifyCall) (request)
1229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1230#[serde_with::serde_as]
1231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1232pub struct ModifyMessageRequest {
1233    /// A list of IDs of labels to add to this message. You can add up to 100 labels with each update.
1234    #[serde(rename = "addLabelIds")]
1235    pub add_label_ids: Option<Vec<String>>,
1236    /// A list IDs of labels to remove from this message. You can remove up to 100 labels with each update.
1237    #[serde(rename = "removeLabelIds")]
1238    pub remove_label_ids: Option<Vec<String>>,
1239}
1240
1241impl common::RequestValue for ModifyMessageRequest {}
1242
1243/// There is no detailed description.
1244///
1245/// # Activities
1246///
1247/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1248/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1249///
1250/// * [threads modify users](UserThreadModifyCall) (request)
1251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1252#[serde_with::serde_as]
1253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1254pub struct ModifyThreadRequest {
1255    /// A list of IDs of labels to add to this thread. You can add up to 100 labels with each update.
1256    #[serde(rename = "addLabelIds")]
1257    pub add_label_ids: Option<Vec<String>>,
1258    /// A list of IDs of labels to remove from this thread. You can remove up to 100 labels with each update.
1259    #[serde(rename = "removeLabelIds")]
1260    pub remove_label_ids: Option<Vec<String>>,
1261}
1262
1263impl common::RequestValue for ModifyThreadRequest {}
1264
1265/// Request to obliterate a CSE key pair.
1266///
1267/// # Activities
1268///
1269/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1270/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1271///
1272/// * [settings cse keypairs obliterate users](UserSettingCseKeypairObliterateCall) (request)
1273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1274#[serde_with::serde_as]
1275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1276pub struct ObliterateCseKeyPairRequest {
1277    _never_set: Option<bool>,
1278}
1279
1280impl common::RequestValue for ObliterateCseKeyPairRequest {}
1281
1282/// POP settings for an account.
1283///
1284/// # Activities
1285///
1286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1288///
1289/// * [settings get pop users](UserSettingGetPopCall) (response)
1290/// * [settings update pop users](UserSettingUpdatePopCall) (request|response)
1291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1292#[serde_with::serde_as]
1293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1294pub struct PopSettings {
1295    /// The range of messages which are accessible via POP.
1296    #[serde(rename = "accessWindow")]
1297    pub access_window: Option<String>,
1298    /// The action that will be executed on a message after it has been fetched via POP.
1299    pub disposition: Option<String>,
1300}
1301
1302impl common::RequestValue for PopSettings {}
1303impl common::ResponseResult for PopSettings {}
1304
1305/// Profile for a Gmail user.
1306///
1307/// # Activities
1308///
1309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1311///
1312/// * [get profile users](UserGetProfileCall) (response)
1313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1314#[serde_with::serde_as]
1315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1316pub struct Profile {
1317    /// The user's email address.
1318    #[serde(rename = "emailAddress")]
1319    pub email_address: Option<String>,
1320    /// The ID of the mailbox's current history record.
1321    #[serde(rename = "historyId")]
1322    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1323    pub history_id: Option<u64>,
1324    /// The total number of messages in the mailbox.
1325    #[serde(rename = "messagesTotal")]
1326    pub messages_total: Option<i32>,
1327    /// The total number of threads in the mailbox.
1328    #[serde(rename = "threadsTotal")]
1329    pub threads_total: Option<i32>,
1330}
1331
1332impl common::ResponseResult for Profile {}
1333
1334/// Settings associated with a send-as alias, which can be either the primary login address associated with the account or a custom “from” address. Send-as aliases correspond to the “Send Mail As” feature in the web interface.
1335///
1336/// # Activities
1337///
1338/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1339/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1340///
1341/// * [settings send as create users](UserSettingSendACreateCall) (request|response)
1342/// * [settings send as get users](UserSettingSendAGetCall) (response)
1343/// * [settings send as patch users](UserSettingSendAPatchCall) (request|response)
1344/// * [settings send as update users](UserSettingSendAUpdateCall) (request|response)
1345#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1346#[serde_with::serde_as]
1347#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1348pub struct SendAs {
1349    /// A name that appears in the "From:" header for mail sent using this alias. For custom "from" addresses, when this is empty, Gmail will populate the "From:" header with the name that is used for the primary address associated with the account. If the admin has disabled the ability for users to update their name format, requests to update this field for the primary login will silently fail.
1350    #[serde(rename = "displayName")]
1351    pub display_name: Option<String>,
1352    /// Whether this address is selected as the default "From:" address in situations such as composing a new message or sending a vacation auto-reply. Every Gmail account has exactly one default send-as address, so the only legal value that clients may write to this field is `true`. Changing this from `false` to `true` for an address will result in this field becoming `false` for the other previous default address.
1353    #[serde(rename = "isDefault")]
1354    pub is_default: Option<bool>,
1355    /// Whether this address is the primary address used to login to the account. Every Gmail account has exactly one primary address, and it cannot be deleted from the collection of send-as aliases. This field is read-only.
1356    #[serde(rename = "isPrimary")]
1357    pub is_primary: Option<bool>,
1358    /// An optional email address that is included in a "Reply-To:" header for mail sent using this alias. If this is empty, Gmail will not generate a "Reply-To:" header.
1359    #[serde(rename = "replyToAddress")]
1360    pub reply_to_address: Option<String>,
1361    /// The email address that appears in the "From:" header for mail sent using this alias. This is read-only for all operations except create.
1362    #[serde(rename = "sendAsEmail")]
1363    pub send_as_email: Option<String>,
1364    /// An optional HTML signature that is included in messages composed with this alias in the Gmail web UI. This signature is added to new emails only.
1365    pub signature: Option<String>,
1366    /// An optional SMTP service that will be used as an outbound relay for mail sent using this alias. If this is empty, outbound mail will be sent directly from Gmail's servers to the destination SMTP service. This setting only applies to custom "from" aliases.
1367    #[serde(rename = "smtpMsa")]
1368    pub smtp_msa: Option<SmtpMsa>,
1369    /// Whether Gmail should treat this address as an alias for the user's primary email address. This setting only applies to custom "from" aliases.
1370    #[serde(rename = "treatAsAlias")]
1371    pub treat_as_alias: Option<bool>,
1372    /// Indicates whether this address has been verified for use as a send-as alias. Read-only. This setting only applies to custom "from" aliases.
1373    #[serde(rename = "verificationStatus")]
1374    pub verification_status: Option<String>,
1375}
1376
1377impl common::RequestValue for SendAs {}
1378impl common::ResponseResult for SendAs {}
1379
1380/// The configuration of a CSE identity that uses different key pairs for signing and encryption.
1381///
1382/// This type is not used in any activity, and only used as *part* of another schema.
1383///
1384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1385#[serde_with::serde_as]
1386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1387pub struct SignAndEncryptKeyPairs {
1388    /// The ID of the CseKeyPair that encrypts signed outgoing mail.
1389    #[serde(rename = "encryptionKeyPairId")]
1390    pub encryption_key_pair_id: Option<String>,
1391    /// The ID of the CseKeyPair that signs outgoing mail.
1392    #[serde(rename = "signingKeyPairId")]
1393    pub signing_key_pair_id: Option<String>,
1394}
1395
1396impl common::Part for SignAndEncryptKeyPairs {}
1397
1398/// An S/MIME email config.
1399///
1400/// # Activities
1401///
1402/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1403/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1404///
1405/// * [settings send as smime info get users](UserSettingSendASmimeInfoGetCall) (response)
1406/// * [settings send as smime info insert users](UserSettingSendASmimeInfoInsertCall) (request|response)
1407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1408#[serde_with::serde_as]
1409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1410pub struct SmimeInfo {
1411    /// Encrypted key password, when key is encrypted.
1412    #[serde(rename = "encryptedKeyPassword")]
1413    pub encrypted_key_password: Option<String>,
1414    /// When the certificate expires (in milliseconds since epoch).
1415    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1416    pub expiration: Option<i64>,
1417    /// The immutable ID for the SmimeInfo.
1418    pub id: Option<String>,
1419    /// Whether this SmimeInfo is the default one for this user's send-as address.
1420    #[serde(rename = "isDefault")]
1421    pub is_default: Option<bool>,
1422    /// The S/MIME certificate issuer's common name.
1423    #[serde(rename = "issuerCn")]
1424    pub issuer_cn: Option<String>,
1425    /// PEM formatted X509 concatenated certificate string (standard base64 encoding). Format used for returning key, which includes public key as well as certificate chain (not private key).
1426    pub pem: Option<String>,
1427    /// PKCS#12 format containing a single private/public key pair and certificate chain. This format is only accepted from client for creating a new SmimeInfo and is never returned, because the private key is not intended to be exported. PKCS#12 may be encrypted, in which case encryptedKeyPassword should be set appropriately.
1428    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1429    pub pkcs12: Option<Vec<u8>>,
1430}
1431
1432impl common::RequestValue for SmimeInfo {}
1433impl common::ResponseResult for SmimeInfo {}
1434
1435/// Configuration for communication with an SMTP service.
1436///
1437/// This type is not used in any activity, and only used as *part* of another schema.
1438///
1439#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1440#[serde_with::serde_as]
1441#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1442pub struct SmtpMsa {
1443    /// The hostname of the SMTP service. Required.
1444    pub host: Option<String>,
1445    /// The password that will be used for authentication with the SMTP service. This is a write-only field that can be specified in requests to create or update SendAs settings; it is never populated in responses.
1446    pub password: Option<String>,
1447    /// The port of the SMTP service. Required.
1448    pub port: Option<i32>,
1449    /// The protocol that will be used to secure communication with the SMTP service. Required.
1450    #[serde(rename = "securityMode")]
1451    pub security_mode: Option<String>,
1452    /// The username that will be used for authentication with the SMTP service. This is a write-only field that can be specified in requests to create or update SendAs settings; it is never populated in responses.
1453    pub username: Option<String>,
1454}
1455
1456impl common::Part for SmtpMsa {}
1457
1458/// A collection of messages representing a conversation.
1459///
1460/// # Activities
1461///
1462/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1463/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1464///
1465/// * [threads get users](UserThreadGetCall) (response)
1466/// * [threads modify users](UserThreadModifyCall) (response)
1467/// * [threads trash users](UserThreadTrashCall) (response)
1468/// * [threads untrash users](UserThreadUntrashCall) (response)
1469#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1470#[serde_with::serde_as]
1471#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1472pub struct Thread {
1473    /// The ID of the last history record that modified this thread.
1474    #[serde(rename = "historyId")]
1475    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1476    pub history_id: Option<u64>,
1477    /// The unique ID of the thread.
1478    pub id: Option<String>,
1479    /// The list of messages in the thread.
1480    pub messages: Option<Vec<Message>>,
1481    /// A short part of the message text.
1482    pub snippet: Option<String>,
1483}
1484
1485impl common::ResponseResult for Thread {}
1486
1487/// Vacation auto-reply settings for an account. These settings correspond to the “Vacation responder” feature in the web interface.
1488///
1489/// # Activities
1490///
1491/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1492/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1493///
1494/// * [settings get vacation users](UserSettingGetVacationCall) (response)
1495/// * [settings update vacation users](UserSettingUpdateVacationCall) (request|response)
1496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1497#[serde_with::serde_as]
1498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1499pub struct VacationSettings {
1500    /// Flag that controls whether Gmail automatically replies to messages.
1501    #[serde(rename = "enableAutoReply")]
1502    pub enable_auto_reply: Option<bool>,
1503    /// An optional end time for sending auto-replies (epoch ms). When this is specified, Gmail will automatically reply only to messages that it receives before the end time. If both `startTime` and `endTime` are specified, `startTime` must precede `endTime`.
1504    #[serde(rename = "endTime")]
1505    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1506    pub end_time: Option<i64>,
1507    /// Response body in HTML format. Gmail will sanitize the HTML before storing it. If both `response_body_plain_text` and `response_body_html` are specified, `response_body_html` will be used.
1508    #[serde(rename = "responseBodyHtml")]
1509    pub response_body_html: Option<String>,
1510    /// Response body in plain text format. If both `response_body_plain_text` and `response_body_html` are specified, `response_body_html` will be used.
1511    #[serde(rename = "responseBodyPlainText")]
1512    pub response_body_plain_text: Option<String>,
1513    /// Optional text to prepend to the subject line in vacation responses. In order to enable auto-replies, either the response subject or the response body must be nonempty.
1514    #[serde(rename = "responseSubject")]
1515    pub response_subject: Option<String>,
1516    /// Flag that determines whether responses are sent to recipients who are not in the user's list of contacts.
1517    #[serde(rename = "restrictToContacts")]
1518    pub restrict_to_contacts: Option<bool>,
1519    /// Flag that determines whether responses are sent to recipients who are outside of the user's domain. This feature is only available for Google Workspace users.
1520    #[serde(rename = "restrictToDomain")]
1521    pub restrict_to_domain: Option<bool>,
1522    /// An optional start time for sending auto-replies (epoch ms). When this is specified, Gmail will automatically reply only to messages that it receives after the start time. If both `startTime` and `endTime` are specified, `startTime` must precede `endTime`.
1523    #[serde(rename = "startTime")]
1524    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1525    pub start_time: Option<i64>,
1526}
1527
1528impl common::RequestValue for VacationSettings {}
1529impl common::ResponseResult for VacationSettings {}
1530
1531/// Set up or update a new push notification watch on this user’s mailbox.
1532///
1533/// # Activities
1534///
1535/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1536/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1537///
1538/// * [watch users](UserWatchCall) (request)
1539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1540#[serde_with::serde_as]
1541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1542pub struct WatchRequest {
1543    /// Filtering behavior of `labelIds list` specified. This field is deprecated because it caused incorrect behavior in some cases; use `label_filter_behavior` instead.
1544    #[serde(rename = "labelFilterAction")]
1545    pub label_filter_action: Option<String>,
1546    /// Filtering behavior of `labelIds list` specified. This field replaces `label_filter_action`; if set, `label_filter_action` is ignored.
1547    #[serde(rename = "labelFilterBehavior")]
1548    pub label_filter_behavior: Option<String>,
1549    /// List of label_ids to restrict notifications about. By default, if unspecified, all changes are pushed out. If specified then dictates which labels are required for a push notification to be generated.
1550    #[serde(rename = "labelIds")]
1551    pub label_ids: Option<Vec<String>>,
1552    /// A fully qualified Google Cloud Pub/Sub API topic name to publish the events to. This topic name **must** already exist in Cloud Pub/Sub and you **must** have already granted gmail "publish" permission on it. For example, "projects/my-project-identifier/topics/my-topic-name" (using the Cloud Pub/Sub "v1" topic naming format). Note that the "my-project-identifier" portion must exactly match your Google developer project id (the one executing this watch request).
1553    #[serde(rename = "topicName")]
1554    pub topic_name: Option<String>,
1555}
1556
1557impl common::RequestValue for WatchRequest {}
1558
1559/// Push notification watch response.
1560///
1561/// # Activities
1562///
1563/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1564/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1565///
1566/// * [watch users](UserWatchCall) (response)
1567#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1568#[serde_with::serde_as]
1569#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1570pub struct WatchResponse {
1571    /// When Gmail will stop sending notifications for mailbox updates (epoch millis). Call `watch` again before this time to renew the watch.
1572    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1573    pub expiration: Option<i64>,
1574    /// The ID of the mailbox's current history record.
1575    #[serde(rename = "historyId")]
1576    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1577    pub history_id: Option<u64>,
1578}
1579
1580impl common::ResponseResult for WatchResponse {}
1581
1582// ###################
1583// MethodBuilders ###
1584// #################
1585
1586/// A builder providing access to all methods supported on *user* resources.
1587/// It is not used directly, but through the [`Gmail`] hub.
1588///
1589/// # Example
1590///
1591/// Instantiate a resource builder
1592///
1593/// ```test_harness,no_run
1594/// extern crate hyper;
1595/// extern crate hyper_rustls;
1596/// extern crate google_gmail1 as gmail1;
1597///
1598/// # async fn dox() {
1599/// use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1600///
1601/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1602/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1603///     .with_native_roots()
1604///     .unwrap()
1605///     .https_only()
1606///     .enable_http2()
1607///     .build();
1608///
1609/// let executor = hyper_util::rt::TokioExecutor::new();
1610/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1611///     secret,
1612///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1613///     yup_oauth2::client::CustomHyperClientBuilder::from(
1614///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1615///     ),
1616/// ).build().await.unwrap();
1617///
1618/// let client = hyper_util::client::legacy::Client::builder(
1619///     hyper_util::rt::TokioExecutor::new()
1620/// )
1621/// .build(
1622///     hyper_rustls::HttpsConnectorBuilder::new()
1623///         .with_native_roots()
1624///         .unwrap()
1625///         .https_or_http()
1626///         .enable_http2()
1627///         .build()
1628/// );
1629/// let mut hub = Gmail::new(client, auth);
1630/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1631/// // like `drafts_create(...)`, `drafts_delete(...)`, `drafts_get(...)`, `drafts_list(...)`, `drafts_send(...)`, `drafts_update(...)`, `get_profile(...)`, `history_list(...)`, `labels_create(...)`, `labels_delete(...)`, `labels_get(...)`, `labels_list(...)`, `labels_patch(...)`, `labels_update(...)`, `messages_attachments_get(...)`, `messages_batch_delete(...)`, `messages_batch_modify(...)`, `messages_delete(...)`, `messages_get(...)`, `messages_import(...)`, `messages_insert(...)`, `messages_list(...)`, `messages_modify(...)`, `messages_send(...)`, `messages_trash(...)`, `messages_untrash(...)`, `settings_cse_identities_create(...)`, `settings_cse_identities_delete(...)`, `settings_cse_identities_get(...)`, `settings_cse_identities_list(...)`, `settings_cse_identities_patch(...)`, `settings_cse_keypairs_create(...)`, `settings_cse_keypairs_disable(...)`, `settings_cse_keypairs_enable(...)`, `settings_cse_keypairs_get(...)`, `settings_cse_keypairs_list(...)`, `settings_cse_keypairs_obliterate(...)`, `settings_delegates_create(...)`, `settings_delegates_delete(...)`, `settings_delegates_get(...)`, `settings_delegates_list(...)`, `settings_filters_create(...)`, `settings_filters_delete(...)`, `settings_filters_get(...)`, `settings_filters_list(...)`, `settings_forwarding_addresses_create(...)`, `settings_forwarding_addresses_delete(...)`, `settings_forwarding_addresses_get(...)`, `settings_forwarding_addresses_list(...)`, `settings_get_auto_forwarding(...)`, `settings_get_imap(...)`, `settings_get_language(...)`, `settings_get_pop(...)`, `settings_get_vacation(...)`, `settings_send_as_create(...)`, `settings_send_as_delete(...)`, `settings_send_as_get(...)`, `settings_send_as_list(...)`, `settings_send_as_patch(...)`, `settings_send_as_smime_info_delete(...)`, `settings_send_as_smime_info_get(...)`, `settings_send_as_smime_info_insert(...)`, `settings_send_as_smime_info_list(...)`, `settings_send_as_smime_info_set_default(...)`, `settings_send_as_update(...)`, `settings_send_as_verify(...)`, `settings_update_auto_forwarding(...)`, `settings_update_imap(...)`, `settings_update_language(...)`, `settings_update_pop(...)`, `settings_update_vacation(...)`, `stop(...)`, `threads_delete(...)`, `threads_get(...)`, `threads_list(...)`, `threads_modify(...)`, `threads_trash(...)`, `threads_untrash(...)` and `watch(...)`
1632/// // to build up your call.
1633/// let rb = hub.users();
1634/// # }
1635/// ```
1636pub struct UserMethods<'a, C>
1637where
1638    C: 'a,
1639{
1640    hub: &'a Gmail<C>,
1641}
1642
1643impl<'a, C> common::MethodsBuilder for UserMethods<'a, C> {}
1644
1645impl<'a, C> UserMethods<'a, C> {
1646    /// Create a builder to help you perform the following task:
1647    ///
1648    /// Creates a new draft with the `DRAFT` label.
1649    ///
1650    /// # Arguments
1651    ///
1652    /// * `request` - No description provided.
1653    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1654    pub fn drafts_create(&self, request: Draft, user_id: &str) -> UserDraftCreateCall<'a, C> {
1655        UserDraftCreateCall {
1656            hub: self.hub,
1657            _request: request,
1658            _user_id: user_id.to_string(),
1659            _delegate: Default::default(),
1660            _additional_params: Default::default(),
1661            _scopes: Default::default(),
1662        }
1663    }
1664
1665    /// Create a builder to help you perform the following task:
1666    ///
1667    /// Immediately and permanently deletes the specified draft. Does not simply trash it.
1668    ///
1669    /// # Arguments
1670    ///
1671    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1672    /// * `id` - The ID of the draft to delete.
1673    pub fn drafts_delete(&self, user_id: &str, id: &str) -> UserDraftDeleteCall<'a, C> {
1674        UserDraftDeleteCall {
1675            hub: self.hub,
1676            _user_id: user_id.to_string(),
1677            _id: id.to_string(),
1678            _delegate: Default::default(),
1679            _additional_params: Default::default(),
1680            _scopes: Default::default(),
1681        }
1682    }
1683
1684    /// Create a builder to help you perform the following task:
1685    ///
1686    /// Gets the specified draft.
1687    ///
1688    /// # Arguments
1689    ///
1690    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1691    /// * `id` - The ID of the draft to retrieve.
1692    pub fn drafts_get(&self, user_id: &str, id: &str) -> UserDraftGetCall<'a, C> {
1693        UserDraftGetCall {
1694            hub: self.hub,
1695            _user_id: user_id.to_string(),
1696            _id: id.to_string(),
1697            _format: Default::default(),
1698            _delegate: Default::default(),
1699            _additional_params: Default::default(),
1700            _scopes: Default::default(),
1701        }
1702    }
1703
1704    /// Create a builder to help you perform the following task:
1705    ///
1706    /// Lists the drafts in the user's mailbox.
1707    ///
1708    /// # Arguments
1709    ///
1710    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1711    pub fn drafts_list(&self, user_id: &str) -> UserDraftListCall<'a, C> {
1712        UserDraftListCall {
1713            hub: self.hub,
1714            _user_id: user_id.to_string(),
1715            _q: Default::default(),
1716            _page_token: Default::default(),
1717            _max_results: Default::default(),
1718            _include_spam_trash: Default::default(),
1719            _delegate: Default::default(),
1720            _additional_params: Default::default(),
1721            _scopes: Default::default(),
1722        }
1723    }
1724
1725    /// Create a builder to help you perform the following task:
1726    ///
1727    /// Sends the specified, existing draft to the recipients in the `To`, `Cc`, and `Bcc` headers.
1728    ///
1729    /// # Arguments
1730    ///
1731    /// * `request` - No description provided.
1732    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1733    pub fn drafts_send(&self, request: Draft, user_id: &str) -> UserDraftSendCall<'a, C> {
1734        UserDraftSendCall {
1735            hub: self.hub,
1736            _request: request,
1737            _user_id: user_id.to_string(),
1738            _delegate: Default::default(),
1739            _additional_params: Default::default(),
1740            _scopes: Default::default(),
1741        }
1742    }
1743
1744    /// Create a builder to help you perform the following task:
1745    ///
1746    /// Replaces a draft's content.
1747    ///
1748    /// # Arguments
1749    ///
1750    /// * `request` - No description provided.
1751    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1752    /// * `id` - The ID of the draft to update.
1753    pub fn drafts_update(
1754        &self,
1755        request: Draft,
1756        user_id: &str,
1757        id: &str,
1758    ) -> UserDraftUpdateCall<'a, C> {
1759        UserDraftUpdateCall {
1760            hub: self.hub,
1761            _request: request,
1762            _user_id: user_id.to_string(),
1763            _id: id.to_string(),
1764            _delegate: Default::default(),
1765            _additional_params: Default::default(),
1766            _scopes: Default::default(),
1767        }
1768    }
1769
1770    /// Create a builder to help you perform the following task:
1771    ///
1772    /// Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing `historyId`).
1773    ///
1774    /// # Arguments
1775    ///
1776    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1777    pub fn history_list(&self, user_id: &str) -> UserHistoryListCall<'a, C> {
1778        UserHistoryListCall {
1779            hub: self.hub,
1780            _user_id: user_id.to_string(),
1781            _start_history_id: Default::default(),
1782            _page_token: Default::default(),
1783            _max_results: Default::default(),
1784            _label_id: Default::default(),
1785            _history_types: Default::default(),
1786            _delegate: Default::default(),
1787            _additional_params: Default::default(),
1788            _scopes: Default::default(),
1789        }
1790    }
1791
1792    /// Create a builder to help you perform the following task:
1793    ///
1794    /// Creates a new label.
1795    ///
1796    /// # Arguments
1797    ///
1798    /// * `request` - No description provided.
1799    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1800    pub fn labels_create(&self, request: Label, user_id: &str) -> UserLabelCreateCall<'a, C> {
1801        UserLabelCreateCall {
1802            hub: self.hub,
1803            _request: request,
1804            _user_id: user_id.to_string(),
1805            _delegate: Default::default(),
1806            _additional_params: Default::default(),
1807            _scopes: Default::default(),
1808        }
1809    }
1810
1811    /// Create a builder to help you perform the following task:
1812    ///
1813    /// Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.
1814    ///
1815    /// # Arguments
1816    ///
1817    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1818    /// * `id` - The ID of the label to delete.
1819    pub fn labels_delete(&self, user_id: &str, id: &str) -> UserLabelDeleteCall<'a, C> {
1820        UserLabelDeleteCall {
1821            hub: self.hub,
1822            _user_id: user_id.to_string(),
1823            _id: id.to_string(),
1824            _delegate: Default::default(),
1825            _additional_params: Default::default(),
1826            _scopes: Default::default(),
1827        }
1828    }
1829
1830    /// Create a builder to help you perform the following task:
1831    ///
1832    /// Gets the specified label.
1833    ///
1834    /// # Arguments
1835    ///
1836    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1837    /// * `id` - The ID of the label to retrieve.
1838    pub fn labels_get(&self, user_id: &str, id: &str) -> UserLabelGetCall<'a, C> {
1839        UserLabelGetCall {
1840            hub: self.hub,
1841            _user_id: user_id.to_string(),
1842            _id: id.to_string(),
1843            _delegate: Default::default(),
1844            _additional_params: Default::default(),
1845            _scopes: Default::default(),
1846        }
1847    }
1848
1849    /// Create a builder to help you perform the following task:
1850    ///
1851    /// Lists all labels in the user's mailbox.
1852    ///
1853    /// # Arguments
1854    ///
1855    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1856    pub fn labels_list(&self, user_id: &str) -> UserLabelListCall<'a, C> {
1857        UserLabelListCall {
1858            hub: self.hub,
1859            _user_id: user_id.to_string(),
1860            _delegate: Default::default(),
1861            _additional_params: Default::default(),
1862            _scopes: Default::default(),
1863        }
1864    }
1865
1866    /// Create a builder to help you perform the following task:
1867    ///
1868    /// Patch the specified label.
1869    ///
1870    /// # Arguments
1871    ///
1872    /// * `request` - No description provided.
1873    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1874    /// * `id` - The ID of the label to update.
1875    pub fn labels_patch(
1876        &self,
1877        request: Label,
1878        user_id: &str,
1879        id: &str,
1880    ) -> UserLabelPatchCall<'a, C> {
1881        UserLabelPatchCall {
1882            hub: self.hub,
1883            _request: request,
1884            _user_id: user_id.to_string(),
1885            _id: id.to_string(),
1886            _delegate: Default::default(),
1887            _additional_params: Default::default(),
1888            _scopes: Default::default(),
1889        }
1890    }
1891
1892    /// Create a builder to help you perform the following task:
1893    ///
1894    /// Updates the specified label.
1895    ///
1896    /// # Arguments
1897    ///
1898    /// * `request` - No description provided.
1899    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1900    /// * `id` - The ID of the label to update.
1901    pub fn labels_update(
1902        &self,
1903        request: Label,
1904        user_id: &str,
1905        id: &str,
1906    ) -> UserLabelUpdateCall<'a, C> {
1907        UserLabelUpdateCall {
1908            hub: self.hub,
1909            _request: request,
1910            _user_id: user_id.to_string(),
1911            _id: id.to_string(),
1912            _delegate: Default::default(),
1913            _additional_params: Default::default(),
1914            _scopes: Default::default(),
1915        }
1916    }
1917
1918    /// Create a builder to help you perform the following task:
1919    ///
1920    /// Gets the specified message attachment.
1921    ///
1922    /// # Arguments
1923    ///
1924    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1925    /// * `messageId` - The ID of the message containing the attachment.
1926    /// * `id` - The ID of the attachment.
1927    pub fn messages_attachments_get(
1928        &self,
1929        user_id: &str,
1930        message_id: &str,
1931        id: &str,
1932    ) -> UserMessageAttachmentGetCall<'a, C> {
1933        UserMessageAttachmentGetCall {
1934            hub: self.hub,
1935            _user_id: user_id.to_string(),
1936            _message_id: message_id.to_string(),
1937            _id: id.to_string(),
1938            _delegate: Default::default(),
1939            _additional_params: Default::default(),
1940            _scopes: Default::default(),
1941        }
1942    }
1943
1944    /// Create a builder to help you perform the following task:
1945    ///
1946    /// Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.
1947    ///
1948    /// # Arguments
1949    ///
1950    /// * `request` - No description provided.
1951    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1952    pub fn messages_batch_delete(
1953        &self,
1954        request: BatchDeleteMessagesRequest,
1955        user_id: &str,
1956    ) -> UserMessageBatchDeleteCall<'a, C> {
1957        UserMessageBatchDeleteCall {
1958            hub: self.hub,
1959            _request: request,
1960            _user_id: user_id.to_string(),
1961            _delegate: Default::default(),
1962            _additional_params: Default::default(),
1963            _scopes: Default::default(),
1964        }
1965    }
1966
1967    /// Create a builder to help you perform the following task:
1968    ///
1969    /// Modifies the labels on the specified messages.
1970    ///
1971    /// # Arguments
1972    ///
1973    /// * `request` - No description provided.
1974    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1975    pub fn messages_batch_modify(
1976        &self,
1977        request: BatchModifyMessagesRequest,
1978        user_id: &str,
1979    ) -> UserMessageBatchModifyCall<'a, C> {
1980        UserMessageBatchModifyCall {
1981            hub: self.hub,
1982            _request: request,
1983            _user_id: user_id.to_string(),
1984            _delegate: Default::default(),
1985            _additional_params: Default::default(),
1986            _scopes: Default::default(),
1987        }
1988    }
1989
1990    /// Create a builder to help you perform the following task:
1991    ///
1992    /// Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer `messages.trash` instead.
1993    ///
1994    /// # Arguments
1995    ///
1996    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
1997    /// * `id` - The ID of the message to delete.
1998    pub fn messages_delete(&self, user_id: &str, id: &str) -> UserMessageDeleteCall<'a, C> {
1999        UserMessageDeleteCall {
2000            hub: self.hub,
2001            _user_id: user_id.to_string(),
2002            _id: id.to_string(),
2003            _delegate: Default::default(),
2004            _additional_params: Default::default(),
2005            _scopes: Default::default(),
2006        }
2007    }
2008
2009    /// Create a builder to help you perform the following task:
2010    ///
2011    /// Gets the specified message.
2012    ///
2013    /// # Arguments
2014    ///
2015    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2016    /// * `id` - The ID of the message to retrieve. This ID is usually retrieved using `messages.list`. The ID is also contained in the result when a message is inserted (`messages.insert`) or imported (`messages.import`).
2017    pub fn messages_get(&self, user_id: &str, id: &str) -> UserMessageGetCall<'a, C> {
2018        UserMessageGetCall {
2019            hub: self.hub,
2020            _user_id: user_id.to_string(),
2021            _id: id.to_string(),
2022            _metadata_headers: Default::default(),
2023            _format: Default::default(),
2024            _delegate: Default::default(),
2025            _additional_params: Default::default(),
2026            _scopes: Default::default(),
2027        }
2028    }
2029
2030    /// Create a builder to help you perform the following task:
2031    ///
2032    /// Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note that the maximum size of the message is 150MB.
2033    ///
2034    /// # Arguments
2035    ///
2036    /// * `request` - No description provided.
2037    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2038    pub fn messages_import(&self, request: Message, user_id: &str) -> UserMessageImportCall<'a, C> {
2039        UserMessageImportCall {
2040            hub: self.hub,
2041            _request: request,
2042            _user_id: user_id.to_string(),
2043            _process_for_calendar: Default::default(),
2044            _never_mark_spam: Default::default(),
2045            _internal_date_source: Default::default(),
2046            _deleted: Default::default(),
2047            _delegate: Default::default(),
2048            _additional_params: Default::default(),
2049            _scopes: Default::default(),
2050        }
2051    }
2052
2053    /// Create a builder to help you perform the following task:
2054    ///
2055    /// Directly inserts a message into only this user's mailbox similar to `IMAP APPEND`, bypassing most scanning and classification. Does not send a message.
2056    ///
2057    /// # Arguments
2058    ///
2059    /// * `request` - No description provided.
2060    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2061    pub fn messages_insert(&self, request: Message, user_id: &str) -> UserMessageInsertCall<'a, C> {
2062        UserMessageInsertCall {
2063            hub: self.hub,
2064            _request: request,
2065            _user_id: user_id.to_string(),
2066            _internal_date_source: Default::default(),
2067            _deleted: Default::default(),
2068            _delegate: Default::default(),
2069            _additional_params: Default::default(),
2070            _scopes: Default::default(),
2071        }
2072    }
2073
2074    /// Create a builder to help you perform the following task:
2075    ///
2076    /// Lists the messages in the user's mailbox. For example usage, see [List Gmail messages](https://developers.google.com/workspace/gmail/api/guides/list-messages).
2077    ///
2078    /// # Arguments
2079    ///
2080    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2081    pub fn messages_list(&self, user_id: &str) -> UserMessageListCall<'a, C> {
2082        UserMessageListCall {
2083            hub: self.hub,
2084            _user_id: user_id.to_string(),
2085            _q: Default::default(),
2086            _page_token: Default::default(),
2087            _max_results: Default::default(),
2088            _label_ids: Default::default(),
2089            _include_spam_trash: Default::default(),
2090            _delegate: Default::default(),
2091            _additional_params: Default::default(),
2092            _scopes: Default::default(),
2093        }
2094    }
2095
2096    /// Create a builder to help you perform the following task:
2097    ///
2098    /// Modifies the labels on the specified message.
2099    ///
2100    /// # Arguments
2101    ///
2102    /// * `request` - No description provided.
2103    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2104    /// * `id` - The ID of the message to modify.
2105    pub fn messages_modify(
2106        &self,
2107        request: ModifyMessageRequest,
2108        user_id: &str,
2109        id: &str,
2110    ) -> UserMessageModifyCall<'a, C> {
2111        UserMessageModifyCall {
2112            hub: self.hub,
2113            _request: request,
2114            _user_id: user_id.to_string(),
2115            _id: id.to_string(),
2116            _delegate: Default::default(),
2117            _additional_params: Default::default(),
2118            _scopes: Default::default(),
2119        }
2120    }
2121
2122    /// Create a builder to help you perform the following task:
2123    ///
2124    /// Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc` headers. For example usage, see [Sending email](https://developers.google.com/workspace/gmail/api/guides/sending).
2125    ///
2126    /// # Arguments
2127    ///
2128    /// * `request` - No description provided.
2129    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2130    pub fn messages_send(&self, request: Message, user_id: &str) -> UserMessageSendCall<'a, C> {
2131        UserMessageSendCall {
2132            hub: self.hub,
2133            _request: request,
2134            _user_id: user_id.to_string(),
2135            _delegate: Default::default(),
2136            _additional_params: Default::default(),
2137            _scopes: Default::default(),
2138        }
2139    }
2140
2141    /// Create a builder to help you perform the following task:
2142    ///
2143    /// Moves the specified message to the trash.
2144    ///
2145    /// # Arguments
2146    ///
2147    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2148    /// * `id` - The ID of the message to Trash.
2149    pub fn messages_trash(&self, user_id: &str, id: &str) -> UserMessageTrashCall<'a, C> {
2150        UserMessageTrashCall {
2151            hub: self.hub,
2152            _user_id: user_id.to_string(),
2153            _id: id.to_string(),
2154            _delegate: Default::default(),
2155            _additional_params: Default::default(),
2156            _scopes: Default::default(),
2157        }
2158    }
2159
2160    /// Create a builder to help you perform the following task:
2161    ///
2162    /// Removes the specified message from the trash.
2163    ///
2164    /// # Arguments
2165    ///
2166    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2167    /// * `id` - The ID of the message to remove from Trash.
2168    pub fn messages_untrash(&self, user_id: &str, id: &str) -> UserMessageUntrashCall<'a, C> {
2169        UserMessageUntrashCall {
2170            hub: self.hub,
2171            _user_id: user_id.to_string(),
2172            _id: id.to_string(),
2173            _delegate: Default::default(),
2174            _additional_params: Default::default(),
2175            _scopes: Default::default(),
2176        }
2177    }
2178
2179    /// Create a builder to help you perform the following task:
2180    ///
2181    /// Creates and configures a client-side encryption identity that's authorized to send mail from the user account. Google publishes the S/MIME certificate to a shared domain-wide directory so that people within a Google Workspace organization can encrypt and send mail to the identity. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2182    ///
2183    /// # Arguments
2184    ///
2185    /// * `request` - No description provided.
2186    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2187    pub fn settings_cse_identities_create(
2188        &self,
2189        request: CseIdentity,
2190        user_id: &str,
2191    ) -> UserSettingCseIdentityCreateCall<'a, C> {
2192        UserSettingCseIdentityCreateCall {
2193            hub: self.hub,
2194            _request: request,
2195            _user_id: user_id.to_string(),
2196            _delegate: Default::default(),
2197            _additional_params: Default::default(),
2198            _scopes: Default::default(),
2199        }
2200    }
2201
2202    /// Create a builder to help you perform the following task:
2203    ///
2204    /// Deletes a client-side encryption identity. The authenticated user can no longer use the identity to send encrypted messages. You cannot restore the identity after you delete it. Instead, use the CreateCseIdentity method to create another identity with the same configuration. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2205    ///
2206    /// # Arguments
2207    ///
2208    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2209    /// * `cseEmailAddress` - The primary email address associated with the client-side encryption identity configuration that's removed.
2210    pub fn settings_cse_identities_delete(
2211        &self,
2212        user_id: &str,
2213        cse_email_address: &str,
2214    ) -> UserSettingCseIdentityDeleteCall<'a, C> {
2215        UserSettingCseIdentityDeleteCall {
2216            hub: self.hub,
2217            _user_id: user_id.to_string(),
2218            _cse_email_address: cse_email_address.to_string(),
2219            _delegate: Default::default(),
2220            _additional_params: Default::default(),
2221            _scopes: Default::default(),
2222        }
2223    }
2224
2225    /// Create a builder to help you perform the following task:
2226    ///
2227    /// Retrieves a client-side encryption identity configuration. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2228    ///
2229    /// # Arguments
2230    ///
2231    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2232    /// * `cseEmailAddress` - The primary email address associated with the client-side encryption identity configuration that's retrieved.
2233    pub fn settings_cse_identities_get(
2234        &self,
2235        user_id: &str,
2236        cse_email_address: &str,
2237    ) -> UserSettingCseIdentityGetCall<'a, C> {
2238        UserSettingCseIdentityGetCall {
2239            hub: self.hub,
2240            _user_id: user_id.to_string(),
2241            _cse_email_address: cse_email_address.to_string(),
2242            _delegate: Default::default(),
2243            _additional_params: Default::default(),
2244            _scopes: Default::default(),
2245        }
2246    }
2247
2248    /// Create a builder to help you perform the following task:
2249    ///
2250    /// Lists the client-side encrypted identities for an authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2251    ///
2252    /// # Arguments
2253    ///
2254    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2255    pub fn settings_cse_identities_list(
2256        &self,
2257        user_id: &str,
2258    ) -> UserSettingCseIdentityListCall<'a, C> {
2259        UserSettingCseIdentityListCall {
2260            hub: self.hub,
2261            _user_id: user_id.to_string(),
2262            _page_token: Default::default(),
2263            _page_size: Default::default(),
2264            _delegate: Default::default(),
2265            _additional_params: Default::default(),
2266            _scopes: Default::default(),
2267        }
2268    }
2269
2270    /// Create a builder to help you perform the following task:
2271    ///
2272    /// Associates a different key pair with an existing client-side encryption identity. The updated key pair must validate against Google's [S/MIME certificate profiles](https://support.google.com/a/answer/7300887). For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2273    ///
2274    /// # Arguments
2275    ///
2276    /// * `request` - No description provided.
2277    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2278    /// * `emailAddress` - The email address of the client-side encryption identity to update.
2279    pub fn settings_cse_identities_patch(
2280        &self,
2281        request: CseIdentity,
2282        user_id: &str,
2283        email_address: &str,
2284    ) -> UserSettingCseIdentityPatchCall<'a, C> {
2285        UserSettingCseIdentityPatchCall {
2286            hub: self.hub,
2287            _request: request,
2288            _user_id: user_id.to_string(),
2289            _email_address: email_address.to_string(),
2290            _delegate: Default::default(),
2291            _additional_params: Default::default(),
2292            _scopes: Default::default(),
2293        }
2294    }
2295
2296    /// Create a builder to help you perform the following task:
2297    ///
2298    /// Creates and uploads a client-side encryption S/MIME public key certificate chain and private key metadata for the authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2299    ///
2300    /// # Arguments
2301    ///
2302    /// * `request` - No description provided.
2303    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2304    pub fn settings_cse_keypairs_create(
2305        &self,
2306        request: CseKeyPair,
2307        user_id: &str,
2308    ) -> UserSettingCseKeypairCreateCall<'a, C> {
2309        UserSettingCseKeypairCreateCall {
2310            hub: self.hub,
2311            _request: request,
2312            _user_id: user_id.to_string(),
2313            _delegate: Default::default(),
2314            _additional_params: Default::default(),
2315            _scopes: Default::default(),
2316        }
2317    }
2318
2319    /// Create a builder to help you perform the following task:
2320    ///
2321    /// Turns off a client-side encryption key pair. The authenticated user can no longer use the key pair to decrypt incoming CSE message texts or sign outgoing CSE mail. To regain access, use the EnableCseKeyPair to turn on the key pair. After 30 days, you can permanently delete the key pair by using the ObliterateCseKeyPair method. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2322    ///
2323    /// # Arguments
2324    ///
2325    /// * `request` - No description provided.
2326    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2327    /// * `keyPairId` - The identifier of the key pair to turn off.
2328    pub fn settings_cse_keypairs_disable(
2329        &self,
2330        request: DisableCseKeyPairRequest,
2331        user_id: &str,
2332        key_pair_id: &str,
2333    ) -> UserSettingCseKeypairDisableCall<'a, C> {
2334        UserSettingCseKeypairDisableCall {
2335            hub: self.hub,
2336            _request: request,
2337            _user_id: user_id.to_string(),
2338            _key_pair_id: key_pair_id.to_string(),
2339            _delegate: Default::default(),
2340            _additional_params: Default::default(),
2341            _scopes: Default::default(),
2342        }
2343    }
2344
2345    /// Create a builder to help you perform the following task:
2346    ///
2347    /// Turns on a client-side encryption key pair that was turned off. The key pair becomes active again for any associated client-side encryption identities. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2348    ///
2349    /// # Arguments
2350    ///
2351    /// * `request` - No description provided.
2352    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2353    /// * `keyPairId` - The identifier of the key pair to turn on.
2354    pub fn settings_cse_keypairs_enable(
2355        &self,
2356        request: EnableCseKeyPairRequest,
2357        user_id: &str,
2358        key_pair_id: &str,
2359    ) -> UserSettingCseKeypairEnableCall<'a, C> {
2360        UserSettingCseKeypairEnableCall {
2361            hub: self.hub,
2362            _request: request,
2363            _user_id: user_id.to_string(),
2364            _key_pair_id: key_pair_id.to_string(),
2365            _delegate: Default::default(),
2366            _additional_params: Default::default(),
2367            _scopes: Default::default(),
2368        }
2369    }
2370
2371    /// Create a builder to help you perform the following task:
2372    ///
2373    /// Retrieves an existing client-side encryption key pair. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2374    ///
2375    /// # Arguments
2376    ///
2377    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2378    /// * `keyPairId` - The identifier of the key pair to retrieve.
2379    pub fn settings_cse_keypairs_get(
2380        &self,
2381        user_id: &str,
2382        key_pair_id: &str,
2383    ) -> UserSettingCseKeypairGetCall<'a, C> {
2384        UserSettingCseKeypairGetCall {
2385            hub: self.hub,
2386            _user_id: user_id.to_string(),
2387            _key_pair_id: key_pair_id.to_string(),
2388            _delegate: Default::default(),
2389            _additional_params: Default::default(),
2390            _scopes: Default::default(),
2391        }
2392    }
2393
2394    /// Create a builder to help you perform the following task:
2395    ///
2396    /// Lists client-side encryption key pairs for an authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2397    ///
2398    /// # Arguments
2399    ///
2400    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2401    pub fn settings_cse_keypairs_list(
2402        &self,
2403        user_id: &str,
2404    ) -> UserSettingCseKeypairListCall<'a, C> {
2405        UserSettingCseKeypairListCall {
2406            hub: self.hub,
2407            _user_id: user_id.to_string(),
2408            _page_token: Default::default(),
2409            _page_size: Default::default(),
2410            _delegate: Default::default(),
2411            _additional_params: Default::default(),
2412            _scopes: Default::default(),
2413        }
2414    }
2415
2416    /// Create a builder to help you perform the following task:
2417    ///
2418    /// Deletes a client-side encryption key pair permanently and immediately. You can only permanently delete key pairs that have been turned off for more than 30 days. To turn off a key pair, use the DisableCseKeyPair method. Gmail can't restore or decrypt any messages that were encrypted by an obliterated key. Authenticated users and Google Workspace administrators lose access to reading the encrypted messages. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
2419    ///
2420    /// # Arguments
2421    ///
2422    /// * `request` - No description provided.
2423    /// * `userId` - The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
2424    /// * `keyPairId` - The identifier of the key pair to obliterate.
2425    pub fn settings_cse_keypairs_obliterate(
2426        &self,
2427        request: ObliterateCseKeyPairRequest,
2428        user_id: &str,
2429        key_pair_id: &str,
2430    ) -> UserSettingCseKeypairObliterateCall<'a, C> {
2431        UserSettingCseKeypairObliterateCall {
2432            hub: self.hub,
2433            _request: request,
2434            _user_id: user_id.to_string(),
2435            _key_pair_id: key_pair_id.to_string(),
2436            _delegate: Default::default(),
2437            _additional_params: Default::default(),
2438            _scopes: Default::default(),
2439        }
2440    }
2441
2442    /// Create a builder to help you perform the following task:
2443    ///
2444    /// Adds a delegate with its verification status set directly to `accepted`, without sending any verification email. The delegate user must be a member of the same Google Workspace organization as the delegator user. Gmail imposes limitations on the number of delegates and delegators each user in a Google Workspace organization can have. These limits depend on your organization, but in general each user can have up to 25 delegates and up to 10 delegators. Note that a delegate user must be referred to by their primary email address, and not an email alias. Also note that when a new delegate is created, there may be up to a one minute delay before the new delegate is available for use. This method is only available to service account clients that have been delegated domain-wide authority.
2445    ///
2446    /// # Arguments
2447    ///
2448    /// * `request` - No description provided.
2449    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2450    pub fn settings_delegates_create(
2451        &self,
2452        request: Delegate,
2453        user_id: &str,
2454    ) -> UserSettingDelegateCreateCall<'a, C> {
2455        UserSettingDelegateCreateCall {
2456            hub: self.hub,
2457            _request: request,
2458            _user_id: user_id.to_string(),
2459            _delegate: Default::default(),
2460            _additional_params: Default::default(),
2461            _scopes: Default::default(),
2462        }
2463    }
2464
2465    /// Create a builder to help you perform the following task:
2466    ///
2467    /// Removes the specified delegate (which can be of any verification status), and revokes any verification that may have been required for using it. Note that a delegate user must be referred to by their primary email address, and not an email alias. This method is only available to service account clients that have been delegated domain-wide authority.
2468    ///
2469    /// # Arguments
2470    ///
2471    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2472    /// * `delegateEmail` - The email address of the user to be removed as a delegate.
2473    pub fn settings_delegates_delete(
2474        &self,
2475        user_id: &str,
2476        delegate_email: &str,
2477    ) -> UserSettingDelegateDeleteCall<'a, C> {
2478        UserSettingDelegateDeleteCall {
2479            hub: self.hub,
2480            _user_id: user_id.to_string(),
2481            _delegate_email: delegate_email.to_string(),
2482            _delegate: Default::default(),
2483            _additional_params: Default::default(),
2484            _scopes: Default::default(),
2485        }
2486    }
2487
2488    /// Create a builder to help you perform the following task:
2489    ///
2490    /// Gets the specified delegate. Note that a delegate user must be referred to by their primary email address, and not an email alias. This method is only available to service account clients that have been delegated domain-wide authority.
2491    ///
2492    /// # Arguments
2493    ///
2494    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2495    /// * `delegateEmail` - The email address of the user whose delegate relationship is to be retrieved.
2496    pub fn settings_delegates_get(
2497        &self,
2498        user_id: &str,
2499        delegate_email: &str,
2500    ) -> UserSettingDelegateGetCall<'a, C> {
2501        UserSettingDelegateGetCall {
2502            hub: self.hub,
2503            _user_id: user_id.to_string(),
2504            _delegate_email: delegate_email.to_string(),
2505            _delegate: Default::default(),
2506            _additional_params: Default::default(),
2507            _scopes: Default::default(),
2508        }
2509    }
2510
2511    /// Create a builder to help you perform the following task:
2512    ///
2513    /// Lists the delegates for the specified account. This method is only available to service account clients that have been delegated domain-wide authority.
2514    ///
2515    /// # Arguments
2516    ///
2517    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2518    pub fn settings_delegates_list(&self, user_id: &str) -> UserSettingDelegateListCall<'a, C> {
2519        UserSettingDelegateListCall {
2520            hub: self.hub,
2521            _user_id: user_id.to_string(),
2522            _delegate: Default::default(),
2523            _additional_params: Default::default(),
2524            _scopes: Default::default(),
2525        }
2526    }
2527
2528    /// Create a builder to help you perform the following task:
2529    ///
2530    /// Creates a filter. Note: you can only create a maximum of 1,000 filters.
2531    ///
2532    /// # Arguments
2533    ///
2534    /// * `request` - No description provided.
2535    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2536    pub fn settings_filters_create(
2537        &self,
2538        request: Filter,
2539        user_id: &str,
2540    ) -> UserSettingFilterCreateCall<'a, C> {
2541        UserSettingFilterCreateCall {
2542            hub: self.hub,
2543            _request: request,
2544            _user_id: user_id.to_string(),
2545            _delegate: Default::default(),
2546            _additional_params: Default::default(),
2547            _scopes: Default::default(),
2548        }
2549    }
2550
2551    /// Create a builder to help you perform the following task:
2552    ///
2553    /// Immediately and permanently deletes the specified filter.
2554    ///
2555    /// # Arguments
2556    ///
2557    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2558    /// * `id` - The ID of the filter to be deleted.
2559    pub fn settings_filters_delete(
2560        &self,
2561        user_id: &str,
2562        id: &str,
2563    ) -> UserSettingFilterDeleteCall<'a, C> {
2564        UserSettingFilterDeleteCall {
2565            hub: self.hub,
2566            _user_id: user_id.to_string(),
2567            _id: id.to_string(),
2568            _delegate: Default::default(),
2569            _additional_params: Default::default(),
2570            _scopes: Default::default(),
2571        }
2572    }
2573
2574    /// Create a builder to help you perform the following task:
2575    ///
2576    /// Gets a filter.
2577    ///
2578    /// # Arguments
2579    ///
2580    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2581    /// * `id` - The ID of the filter to be fetched.
2582    pub fn settings_filters_get(&self, user_id: &str, id: &str) -> UserSettingFilterGetCall<'a, C> {
2583        UserSettingFilterGetCall {
2584            hub: self.hub,
2585            _user_id: user_id.to_string(),
2586            _id: id.to_string(),
2587            _delegate: Default::default(),
2588            _additional_params: Default::default(),
2589            _scopes: Default::default(),
2590        }
2591    }
2592
2593    /// Create a builder to help you perform the following task:
2594    ///
2595    /// Lists the message filters of a Gmail user.
2596    ///
2597    /// # Arguments
2598    ///
2599    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2600    pub fn settings_filters_list(&self, user_id: &str) -> UserSettingFilterListCall<'a, C> {
2601        UserSettingFilterListCall {
2602            hub: self.hub,
2603            _user_id: user_id.to_string(),
2604            _delegate: Default::default(),
2605            _additional_params: Default::default(),
2606            _scopes: Default::default(),
2607        }
2608    }
2609
2610    /// Create a builder to help you perform the following task:
2611    ///
2612    /// Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. This method is only available to service account clients that have been delegated domain-wide authority.
2613    ///
2614    /// # Arguments
2615    ///
2616    /// * `request` - No description provided.
2617    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2618    pub fn settings_forwarding_addresses_create(
2619        &self,
2620        request: ForwardingAddress,
2621        user_id: &str,
2622    ) -> UserSettingForwardingAddressCreateCall<'a, C> {
2623        UserSettingForwardingAddressCreateCall {
2624            hub: self.hub,
2625            _request: request,
2626            _user_id: user_id.to_string(),
2627            _delegate: Default::default(),
2628            _additional_params: Default::default(),
2629            _scopes: Default::default(),
2630        }
2631    }
2632
2633    /// Create a builder to help you perform the following task:
2634    ///
2635    /// Deletes the specified forwarding address and revokes any verification that may have been required. This method is only available to service account clients that have been delegated domain-wide authority.
2636    ///
2637    /// # Arguments
2638    ///
2639    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2640    /// * `forwardingEmail` - The forwarding address to be deleted.
2641    pub fn settings_forwarding_addresses_delete(
2642        &self,
2643        user_id: &str,
2644        forwarding_email: &str,
2645    ) -> UserSettingForwardingAddressDeleteCall<'a, C> {
2646        UserSettingForwardingAddressDeleteCall {
2647            hub: self.hub,
2648            _user_id: user_id.to_string(),
2649            _forwarding_email: forwarding_email.to_string(),
2650            _delegate: Default::default(),
2651            _additional_params: Default::default(),
2652            _scopes: Default::default(),
2653        }
2654    }
2655
2656    /// Create a builder to help you perform the following task:
2657    ///
2658    /// Gets the specified forwarding address.
2659    ///
2660    /// # Arguments
2661    ///
2662    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2663    /// * `forwardingEmail` - The forwarding address to be retrieved.
2664    pub fn settings_forwarding_addresses_get(
2665        &self,
2666        user_id: &str,
2667        forwarding_email: &str,
2668    ) -> UserSettingForwardingAddressGetCall<'a, C> {
2669        UserSettingForwardingAddressGetCall {
2670            hub: self.hub,
2671            _user_id: user_id.to_string(),
2672            _forwarding_email: forwarding_email.to_string(),
2673            _delegate: Default::default(),
2674            _additional_params: Default::default(),
2675            _scopes: Default::default(),
2676        }
2677    }
2678
2679    /// Create a builder to help you perform the following task:
2680    ///
2681    /// Lists the forwarding addresses for the specified account.
2682    ///
2683    /// # Arguments
2684    ///
2685    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2686    pub fn settings_forwarding_addresses_list(
2687        &self,
2688        user_id: &str,
2689    ) -> UserSettingForwardingAddressListCall<'a, C> {
2690        UserSettingForwardingAddressListCall {
2691            hub: self.hub,
2692            _user_id: user_id.to_string(),
2693            _delegate: Default::default(),
2694            _additional_params: Default::default(),
2695            _scopes: Default::default(),
2696        }
2697    }
2698
2699    /// Create a builder to help you perform the following task:
2700    ///
2701    /// Deletes the specified S/MIME config for the specified send-as alias.
2702    ///
2703    /// # Arguments
2704    ///
2705    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2706    /// * `sendAsEmail` - The email address that appears in the "From:" header for mail sent using this alias.
2707    /// * `id` - The immutable ID for the SmimeInfo.
2708    pub fn settings_send_as_smime_info_delete(
2709        &self,
2710        user_id: &str,
2711        send_as_email: &str,
2712        id: &str,
2713    ) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
2714        UserSettingSendASmimeInfoDeleteCall {
2715            hub: self.hub,
2716            _user_id: user_id.to_string(),
2717            _send_as_email: send_as_email.to_string(),
2718            _id: id.to_string(),
2719            _delegate: Default::default(),
2720            _additional_params: Default::default(),
2721            _scopes: Default::default(),
2722        }
2723    }
2724
2725    /// Create a builder to help you perform the following task:
2726    ///
2727    /// Gets the specified S/MIME config for the specified send-as alias.
2728    ///
2729    /// # Arguments
2730    ///
2731    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2732    /// * `sendAsEmail` - The email address that appears in the "From:" header for mail sent using this alias.
2733    /// * `id` - The immutable ID for the SmimeInfo.
2734    pub fn settings_send_as_smime_info_get(
2735        &self,
2736        user_id: &str,
2737        send_as_email: &str,
2738        id: &str,
2739    ) -> UserSettingSendASmimeInfoGetCall<'a, C> {
2740        UserSettingSendASmimeInfoGetCall {
2741            hub: self.hub,
2742            _user_id: user_id.to_string(),
2743            _send_as_email: send_as_email.to_string(),
2744            _id: id.to_string(),
2745            _delegate: Default::default(),
2746            _additional_params: Default::default(),
2747            _scopes: Default::default(),
2748        }
2749    }
2750
2751    /// Create a builder to help you perform the following task:
2752    ///
2753    /// Insert (upload) the given S/MIME config for the specified send-as alias. Note that pkcs12 format is required for the key.
2754    ///
2755    /// # Arguments
2756    ///
2757    /// * `request` - No description provided.
2758    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2759    /// * `sendAsEmail` - The email address that appears in the "From:" header for mail sent using this alias.
2760    pub fn settings_send_as_smime_info_insert(
2761        &self,
2762        request: SmimeInfo,
2763        user_id: &str,
2764        send_as_email: &str,
2765    ) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
2766        UserSettingSendASmimeInfoInsertCall {
2767            hub: self.hub,
2768            _request: request,
2769            _user_id: user_id.to_string(),
2770            _send_as_email: send_as_email.to_string(),
2771            _delegate: Default::default(),
2772            _additional_params: Default::default(),
2773            _scopes: Default::default(),
2774        }
2775    }
2776
2777    /// Create a builder to help you perform the following task:
2778    ///
2779    /// Lists S/MIME configs for the specified send-as alias.
2780    ///
2781    /// # Arguments
2782    ///
2783    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2784    /// * `sendAsEmail` - The email address that appears in the "From:" header for mail sent using this alias.
2785    pub fn settings_send_as_smime_info_list(
2786        &self,
2787        user_id: &str,
2788        send_as_email: &str,
2789    ) -> UserSettingSendASmimeInfoListCall<'a, C> {
2790        UserSettingSendASmimeInfoListCall {
2791            hub: self.hub,
2792            _user_id: user_id.to_string(),
2793            _send_as_email: send_as_email.to_string(),
2794            _delegate: Default::default(),
2795            _additional_params: Default::default(),
2796            _scopes: Default::default(),
2797        }
2798    }
2799
2800    /// Create a builder to help you perform the following task:
2801    ///
2802    /// Sets the default S/MIME config for the specified send-as alias.
2803    ///
2804    /// # Arguments
2805    ///
2806    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
2807    /// * `sendAsEmail` - The email address that appears in the "From:" header for mail sent using this alias.
2808    /// * `id` - The immutable ID for the SmimeInfo.
2809    pub fn settings_send_as_smime_info_set_default(
2810        &self,
2811        user_id: &str,
2812        send_as_email: &str,
2813        id: &str,
2814    ) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
2815        UserSettingSendASmimeInfoSetDefaultCall {
2816            hub: self.hub,
2817            _user_id: user_id.to_string(),
2818            _send_as_email: send_as_email.to_string(),
2819            _id: id.to_string(),
2820            _delegate: Default::default(),
2821            _additional_params: Default::default(),
2822            _scopes: Default::default(),
2823        }
2824    }
2825
2826    /// Create a builder to help you perform the following task:
2827    ///
2828    /// Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. This method is only available to service account clients that have been delegated domain-wide authority.
2829    ///
2830    /// # Arguments
2831    ///
2832    /// * `request` - No description provided.
2833    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2834    pub fn settings_send_as_create(
2835        &self,
2836        request: SendAs,
2837        user_id: &str,
2838    ) -> UserSettingSendACreateCall<'a, C> {
2839        UserSettingSendACreateCall {
2840            hub: self.hub,
2841            _request: request,
2842            _user_id: user_id.to_string(),
2843            _delegate: Default::default(),
2844            _additional_params: Default::default(),
2845            _scopes: Default::default(),
2846        }
2847    }
2848
2849    /// Create a builder to help you perform the following task:
2850    ///
2851    /// Deletes the specified send-as alias. Revokes any verification that may have been required for using it. This method is only available to service account clients that have been delegated domain-wide authority.
2852    ///
2853    /// # Arguments
2854    ///
2855    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2856    /// * `sendAsEmail` - The send-as alias to be deleted.
2857    pub fn settings_send_as_delete(
2858        &self,
2859        user_id: &str,
2860        send_as_email: &str,
2861    ) -> UserSettingSendADeleteCall<'a, C> {
2862        UserSettingSendADeleteCall {
2863            hub: self.hub,
2864            _user_id: user_id.to_string(),
2865            _send_as_email: send_as_email.to_string(),
2866            _delegate: Default::default(),
2867            _additional_params: Default::default(),
2868            _scopes: Default::default(),
2869        }
2870    }
2871
2872    /// Create a builder to help you perform the following task:
2873    ///
2874    /// Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection.
2875    ///
2876    /// # Arguments
2877    ///
2878    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2879    /// * `sendAsEmail` - The send-as alias to be retrieved.
2880    pub fn settings_send_as_get(
2881        &self,
2882        user_id: &str,
2883        send_as_email: &str,
2884    ) -> UserSettingSendAGetCall<'a, C> {
2885        UserSettingSendAGetCall {
2886            hub: self.hub,
2887            _user_id: user_id.to_string(),
2888            _send_as_email: send_as_email.to_string(),
2889            _delegate: Default::default(),
2890            _additional_params: Default::default(),
2891            _scopes: Default::default(),
2892        }
2893    }
2894
2895    /// Create a builder to help you perform the following task:
2896    ///
2897    /// Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases.
2898    ///
2899    /// # Arguments
2900    ///
2901    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2902    pub fn settings_send_as_list(&self, user_id: &str) -> UserSettingSendAListCall<'a, C> {
2903        UserSettingSendAListCall {
2904            hub: self.hub,
2905            _user_id: user_id.to_string(),
2906            _delegate: Default::default(),
2907            _additional_params: Default::default(),
2908            _scopes: Default::default(),
2909        }
2910    }
2911
2912    /// Create a builder to help you perform the following task:
2913    ///
2914    /// Patch the specified send-as alias.
2915    ///
2916    /// # Arguments
2917    ///
2918    /// * `request` - No description provided.
2919    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2920    /// * `sendAsEmail` - The send-as alias to be updated.
2921    pub fn settings_send_as_patch(
2922        &self,
2923        request: SendAs,
2924        user_id: &str,
2925        send_as_email: &str,
2926    ) -> UserSettingSendAPatchCall<'a, C> {
2927        UserSettingSendAPatchCall {
2928            hub: self.hub,
2929            _request: request,
2930            _user_id: user_id.to_string(),
2931            _send_as_email: send_as_email.to_string(),
2932            _delegate: Default::default(),
2933            _additional_params: Default::default(),
2934            _scopes: Default::default(),
2935        }
2936    }
2937
2938    /// Create a builder to help you perform the following task:
2939    ///
2940    /// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. Addresses other than the primary address for the account can only be updated by service account clients that have been delegated domain-wide authority.
2941    ///
2942    /// # Arguments
2943    ///
2944    /// * `request` - No description provided.
2945    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2946    /// * `sendAsEmail` - The send-as alias to be updated.
2947    pub fn settings_send_as_update(
2948        &self,
2949        request: SendAs,
2950        user_id: &str,
2951        send_as_email: &str,
2952    ) -> UserSettingSendAUpdateCall<'a, C> {
2953        UserSettingSendAUpdateCall {
2954            hub: self.hub,
2955            _request: request,
2956            _user_id: user_id.to_string(),
2957            _send_as_email: send_as_email.to_string(),
2958            _delegate: Default::default(),
2959            _additional_params: Default::default(),
2960            _scopes: Default::default(),
2961        }
2962    }
2963
2964    /// Create a builder to help you perform the following task:
2965    ///
2966    /// Sends a verification email to the specified send-as alias address. The verification status must be `pending`. This method is only available to service account clients that have been delegated domain-wide authority.
2967    ///
2968    /// # Arguments
2969    ///
2970    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2971    /// * `sendAsEmail` - The send-as alias to be verified.
2972    pub fn settings_send_as_verify(
2973        &self,
2974        user_id: &str,
2975        send_as_email: &str,
2976    ) -> UserSettingSendAVerifyCall<'a, C> {
2977        UserSettingSendAVerifyCall {
2978            hub: self.hub,
2979            _user_id: user_id.to_string(),
2980            _send_as_email: send_as_email.to_string(),
2981            _delegate: Default::default(),
2982            _additional_params: Default::default(),
2983            _scopes: Default::default(),
2984        }
2985    }
2986
2987    /// Create a builder to help you perform the following task:
2988    ///
2989    /// Gets the auto-forwarding setting for the specified account.
2990    ///
2991    /// # Arguments
2992    ///
2993    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
2994    pub fn settings_get_auto_forwarding(
2995        &self,
2996        user_id: &str,
2997    ) -> UserSettingGetAutoForwardingCall<'a, C> {
2998        UserSettingGetAutoForwardingCall {
2999            hub: self.hub,
3000            _user_id: user_id.to_string(),
3001            _delegate: Default::default(),
3002            _additional_params: Default::default(),
3003            _scopes: Default::default(),
3004        }
3005    }
3006
3007    /// Create a builder to help you perform the following task:
3008    ///
3009    /// Gets IMAP settings.
3010    ///
3011    /// # Arguments
3012    ///
3013    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3014    pub fn settings_get_imap(&self, user_id: &str) -> UserSettingGetImapCall<'a, C> {
3015        UserSettingGetImapCall {
3016            hub: self.hub,
3017            _user_id: user_id.to_string(),
3018            _delegate: Default::default(),
3019            _additional_params: Default::default(),
3020            _scopes: Default::default(),
3021        }
3022    }
3023
3024    /// Create a builder to help you perform the following task:
3025    ///
3026    /// Gets language settings.
3027    ///
3028    /// # Arguments
3029    ///
3030    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3031    pub fn settings_get_language(&self, user_id: &str) -> UserSettingGetLanguageCall<'a, C> {
3032        UserSettingGetLanguageCall {
3033            hub: self.hub,
3034            _user_id: user_id.to_string(),
3035            _delegate: Default::default(),
3036            _additional_params: Default::default(),
3037            _scopes: Default::default(),
3038        }
3039    }
3040
3041    /// Create a builder to help you perform the following task:
3042    ///
3043    /// Gets POP settings.
3044    ///
3045    /// # Arguments
3046    ///
3047    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3048    pub fn settings_get_pop(&self, user_id: &str) -> UserSettingGetPopCall<'a, C> {
3049        UserSettingGetPopCall {
3050            hub: self.hub,
3051            _user_id: user_id.to_string(),
3052            _delegate: Default::default(),
3053            _additional_params: Default::default(),
3054            _scopes: Default::default(),
3055        }
3056    }
3057
3058    /// Create a builder to help you perform the following task:
3059    ///
3060    /// Gets vacation responder settings.
3061    ///
3062    /// # Arguments
3063    ///
3064    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3065    pub fn settings_get_vacation(&self, user_id: &str) -> UserSettingGetVacationCall<'a, C> {
3066        UserSettingGetVacationCall {
3067            hub: self.hub,
3068            _user_id: user_id.to_string(),
3069            _delegate: Default::default(),
3070            _additional_params: Default::default(),
3071            _scopes: Default::default(),
3072        }
3073    }
3074
3075    /// Create a builder to help you perform the following task:
3076    ///
3077    /// Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled. This method is only available to service account clients that have been delegated domain-wide authority.
3078    ///
3079    /// # Arguments
3080    ///
3081    /// * `request` - No description provided.
3082    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3083    pub fn settings_update_auto_forwarding(
3084        &self,
3085        request: AutoForwarding,
3086        user_id: &str,
3087    ) -> UserSettingUpdateAutoForwardingCall<'a, C> {
3088        UserSettingUpdateAutoForwardingCall {
3089            hub: self.hub,
3090            _request: request,
3091            _user_id: user_id.to_string(),
3092            _delegate: Default::default(),
3093            _additional_params: Default::default(),
3094            _scopes: Default::default(),
3095        }
3096    }
3097
3098    /// Create a builder to help you perform the following task:
3099    ///
3100    /// Updates IMAP settings.
3101    ///
3102    /// # Arguments
3103    ///
3104    /// * `request` - No description provided.
3105    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3106    pub fn settings_update_imap(
3107        &self,
3108        request: ImapSettings,
3109        user_id: &str,
3110    ) -> UserSettingUpdateImapCall<'a, C> {
3111        UserSettingUpdateImapCall {
3112            hub: self.hub,
3113            _request: request,
3114            _user_id: user_id.to_string(),
3115            _delegate: Default::default(),
3116            _additional_params: Default::default(),
3117            _scopes: Default::default(),
3118        }
3119    }
3120
3121    /// Create a builder to help you perform the following task:
3122    ///
3123    /// Updates language settings. If successful, the return object contains the `displayLanguage` that was saved for the user, which may differ from the value passed into the request. This is because the requested `displayLanguage` may not be directly supported by Gmail but have a close variant that is, and so the variant may be chosen and saved instead.
3124    ///
3125    /// # Arguments
3126    ///
3127    /// * `request` - No description provided.
3128    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3129    pub fn settings_update_language(
3130        &self,
3131        request: LanguageSettings,
3132        user_id: &str,
3133    ) -> UserSettingUpdateLanguageCall<'a, C> {
3134        UserSettingUpdateLanguageCall {
3135            hub: self.hub,
3136            _request: request,
3137            _user_id: user_id.to_string(),
3138            _delegate: Default::default(),
3139            _additional_params: Default::default(),
3140            _scopes: Default::default(),
3141        }
3142    }
3143
3144    /// Create a builder to help you perform the following task:
3145    ///
3146    /// Updates POP settings.
3147    ///
3148    /// # Arguments
3149    ///
3150    /// * `request` - No description provided.
3151    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3152    pub fn settings_update_pop(
3153        &self,
3154        request: PopSettings,
3155        user_id: &str,
3156    ) -> UserSettingUpdatePopCall<'a, C> {
3157        UserSettingUpdatePopCall {
3158            hub: self.hub,
3159            _request: request,
3160            _user_id: user_id.to_string(),
3161            _delegate: Default::default(),
3162            _additional_params: Default::default(),
3163            _scopes: Default::default(),
3164        }
3165    }
3166
3167    /// Create a builder to help you perform the following task:
3168    ///
3169    /// Updates vacation responder settings.
3170    ///
3171    /// # Arguments
3172    ///
3173    /// * `request` - No description provided.
3174    /// * `userId` - User's email address. The special value "me" can be used to indicate the authenticated user.
3175    pub fn settings_update_vacation(
3176        &self,
3177        request: VacationSettings,
3178        user_id: &str,
3179    ) -> UserSettingUpdateVacationCall<'a, C> {
3180        UserSettingUpdateVacationCall {
3181            hub: self.hub,
3182            _request: request,
3183            _user_id: user_id.to_string(),
3184            _delegate: Default::default(),
3185            _additional_params: Default::default(),
3186            _scopes: Default::default(),
3187        }
3188    }
3189
3190    /// Create a builder to help you perform the following task:
3191    ///
3192    /// Immediately and permanently deletes the specified thread. Any messages that belong to the thread are also deleted. This operation cannot be undone. Prefer `threads.trash` instead.
3193    ///
3194    /// # Arguments
3195    ///
3196    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3197    /// * `id` - ID of the Thread to delete.
3198    pub fn threads_delete(&self, user_id: &str, id: &str) -> UserThreadDeleteCall<'a, C> {
3199        UserThreadDeleteCall {
3200            hub: self.hub,
3201            _user_id: user_id.to_string(),
3202            _id: id.to_string(),
3203            _delegate: Default::default(),
3204            _additional_params: Default::default(),
3205            _scopes: Default::default(),
3206        }
3207    }
3208
3209    /// Create a builder to help you perform the following task:
3210    ///
3211    /// Gets the specified thread.
3212    ///
3213    /// # Arguments
3214    ///
3215    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3216    /// * `id` - The ID of the thread to retrieve.
3217    pub fn threads_get(&self, user_id: &str, id: &str) -> UserThreadGetCall<'a, C> {
3218        UserThreadGetCall {
3219            hub: self.hub,
3220            _user_id: user_id.to_string(),
3221            _id: id.to_string(),
3222            _metadata_headers: Default::default(),
3223            _format: Default::default(),
3224            _delegate: Default::default(),
3225            _additional_params: Default::default(),
3226            _scopes: Default::default(),
3227        }
3228    }
3229
3230    /// Create a builder to help you perform the following task:
3231    ///
3232    /// Lists the threads in the user's mailbox.
3233    ///
3234    /// # Arguments
3235    ///
3236    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3237    pub fn threads_list(&self, user_id: &str) -> UserThreadListCall<'a, C> {
3238        UserThreadListCall {
3239            hub: self.hub,
3240            _user_id: user_id.to_string(),
3241            _q: Default::default(),
3242            _page_token: Default::default(),
3243            _max_results: Default::default(),
3244            _label_ids: Default::default(),
3245            _include_spam_trash: Default::default(),
3246            _delegate: Default::default(),
3247            _additional_params: Default::default(),
3248            _scopes: Default::default(),
3249        }
3250    }
3251
3252    /// Create a builder to help you perform the following task:
3253    ///
3254    /// Modifies the labels applied to the thread. This applies to all messages in the thread.
3255    ///
3256    /// # Arguments
3257    ///
3258    /// * `request` - No description provided.
3259    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3260    /// * `id` - The ID of the thread to modify.
3261    pub fn threads_modify(
3262        &self,
3263        request: ModifyThreadRequest,
3264        user_id: &str,
3265        id: &str,
3266    ) -> UserThreadModifyCall<'a, C> {
3267        UserThreadModifyCall {
3268            hub: self.hub,
3269            _request: request,
3270            _user_id: user_id.to_string(),
3271            _id: id.to_string(),
3272            _delegate: Default::default(),
3273            _additional_params: Default::default(),
3274            _scopes: Default::default(),
3275        }
3276    }
3277
3278    /// Create a builder to help you perform the following task:
3279    ///
3280    /// Moves the specified thread to the trash. Any messages that belong to the thread are also moved to the trash.
3281    ///
3282    /// # Arguments
3283    ///
3284    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3285    /// * `id` - The ID of the thread to Trash.
3286    pub fn threads_trash(&self, user_id: &str, id: &str) -> UserThreadTrashCall<'a, C> {
3287        UserThreadTrashCall {
3288            hub: self.hub,
3289            _user_id: user_id.to_string(),
3290            _id: id.to_string(),
3291            _delegate: Default::default(),
3292            _additional_params: Default::default(),
3293            _scopes: Default::default(),
3294        }
3295    }
3296
3297    /// Create a builder to help you perform the following task:
3298    ///
3299    /// Removes the specified thread from the trash. Any messages that belong to the thread are also removed from the trash.
3300    ///
3301    /// # Arguments
3302    ///
3303    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3304    /// * `id` - The ID of the thread to remove from Trash.
3305    pub fn threads_untrash(&self, user_id: &str, id: &str) -> UserThreadUntrashCall<'a, C> {
3306        UserThreadUntrashCall {
3307            hub: self.hub,
3308            _user_id: user_id.to_string(),
3309            _id: id.to_string(),
3310            _delegate: Default::default(),
3311            _additional_params: Default::default(),
3312            _scopes: Default::default(),
3313        }
3314    }
3315
3316    /// Create a builder to help you perform the following task:
3317    ///
3318    /// Gets the current user's Gmail profile.
3319    ///
3320    /// # Arguments
3321    ///
3322    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3323    pub fn get_profile(&self, user_id: &str) -> UserGetProfileCall<'a, C> {
3324        UserGetProfileCall {
3325            hub: self.hub,
3326            _user_id: user_id.to_string(),
3327            _delegate: Default::default(),
3328            _additional_params: Default::default(),
3329            _scopes: Default::default(),
3330        }
3331    }
3332
3333    /// Create a builder to help you perform the following task:
3334    ///
3335    /// Stop receiving push notifications for the given user mailbox.
3336    ///
3337    /// # Arguments
3338    ///
3339    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3340    pub fn stop(&self, user_id: &str) -> UserStopCall<'a, C> {
3341        UserStopCall {
3342            hub: self.hub,
3343            _user_id: user_id.to_string(),
3344            _delegate: Default::default(),
3345            _additional_params: Default::default(),
3346            _scopes: Default::default(),
3347        }
3348    }
3349
3350    /// Create a builder to help you perform the following task:
3351    ///
3352    /// Set up or update a push notification watch on the given user mailbox.
3353    ///
3354    /// # Arguments
3355    ///
3356    /// * `request` - No description provided.
3357    /// * `userId` - The user's email address. The special value `me` can be used to indicate the authenticated user.
3358    pub fn watch(&self, request: WatchRequest, user_id: &str) -> UserWatchCall<'a, C> {
3359        UserWatchCall {
3360            hub: self.hub,
3361            _request: request,
3362            _user_id: user_id.to_string(),
3363            _delegate: Default::default(),
3364            _additional_params: Default::default(),
3365            _scopes: Default::default(),
3366        }
3367    }
3368}
3369
3370// ###################
3371// CallBuilders   ###
3372// #################
3373
3374/// Creates a new draft with the `DRAFT` label.
3375///
3376/// A builder for the *drafts.create* method supported by a *user* resource.
3377/// It is not used directly, but through a [`UserMethods`] instance.
3378///
3379/// # Example
3380///
3381/// Instantiate a resource method builder
3382///
3383/// ```test_harness,no_run
3384/// # extern crate hyper;
3385/// # extern crate hyper_rustls;
3386/// # extern crate google_gmail1 as gmail1;
3387/// use gmail1::api::Draft;
3388/// use std::fs;
3389/// # async fn dox() {
3390/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3391///
3392/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3393/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3394/// #     .with_native_roots()
3395/// #     .unwrap()
3396/// #     .https_only()
3397/// #     .enable_http2()
3398/// #     .build();
3399///
3400/// # let executor = hyper_util::rt::TokioExecutor::new();
3401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3402/// #     secret,
3403/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3404/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3405/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3406/// #     ),
3407/// # ).build().await.unwrap();
3408///
3409/// # let client = hyper_util::client::legacy::Client::builder(
3410/// #     hyper_util::rt::TokioExecutor::new()
3411/// # )
3412/// # .build(
3413/// #     hyper_rustls::HttpsConnectorBuilder::new()
3414/// #         .with_native_roots()
3415/// #         .unwrap()
3416/// #         .https_or_http()
3417/// #         .enable_http2()
3418/// #         .build()
3419/// # );
3420/// # let mut hub = Gmail::new(client, auth);
3421/// // As the method needs a request, you would usually fill it with the desired information
3422/// // into the respective structure. Some of the parts shown here might not be applicable !
3423/// // Values shown here are possibly random and not representative !
3424/// let mut req = Draft::default();
3425///
3426/// // You can configure optional parameters by calling the respective setters at will, and
3427/// // execute the final call using `upload_resumable(...)`.
3428/// // Values shown here are possibly random and not representative !
3429/// let result = hub.users().drafts_create(req, "userId")
3430///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
3431/// # }
3432/// ```
3433pub struct UserDraftCreateCall<'a, C>
3434where
3435    C: 'a,
3436{
3437    hub: &'a Gmail<C>,
3438    _request: Draft,
3439    _user_id: String,
3440    _delegate: Option<&'a mut dyn common::Delegate>,
3441    _additional_params: HashMap<String, String>,
3442    _scopes: BTreeSet<String>,
3443}
3444
3445impl<'a, C> common::CallBuilder for UserDraftCreateCall<'a, C> {}
3446
3447impl<'a, C> UserDraftCreateCall<'a, C>
3448where
3449    C: common::Connector,
3450{
3451    /// Perform the operation you have build so far.
3452    async fn doit<RS>(
3453        mut self,
3454        mut reader: RS,
3455        reader_mime_type: mime::Mime,
3456        protocol: common::UploadProtocol,
3457    ) -> common::Result<(common::Response, Draft)>
3458    where
3459        RS: common::ReadSeek,
3460    {
3461        use std::borrow::Cow;
3462        use std::io::{Read, Seek};
3463
3464        use common::{url::Params, ToParts};
3465        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3466
3467        let mut dd = common::DefaultDelegate;
3468        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3469        dlg.begin(common::MethodInfo {
3470            id: "gmail.users.drafts.create",
3471            http_method: hyper::Method::POST,
3472        });
3473
3474        for &field in ["alt", "userId"].iter() {
3475            if self._additional_params.contains_key(field) {
3476                dlg.finished(false);
3477                return Err(common::Error::FieldClash(field));
3478            }
3479        }
3480
3481        let mut params = Params::with_capacity(4 + self._additional_params.len());
3482        params.push("userId", self._user_id);
3483
3484        params.extend(self._additional_params.iter());
3485
3486        params.push("alt", "json");
3487        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
3488            (
3489                self.hub._root_url.clone() + "resumable/upload/gmail/v1/users/{userId}/drafts",
3490                "resumable",
3491            )
3492        } else if protocol == common::UploadProtocol::Simple {
3493            (
3494                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/drafts",
3495                "multipart",
3496            )
3497        } else {
3498            unreachable!()
3499        };
3500        params.push("uploadType", upload_type);
3501        if self._scopes.is_empty() {
3502            self._scopes.insert(Scope::Gmai.as_ref().to_string());
3503        }
3504
3505        #[allow(clippy::single_element_loop)]
3506        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
3507            url = params.uri_replacement(url, param_name, find_this, false);
3508        }
3509        {
3510            let to_remove = ["userId"];
3511            params.remove_params(&to_remove);
3512        }
3513
3514        let url = params.parse_with_url(&url);
3515
3516        let mut json_mime_type = mime::APPLICATION_JSON;
3517        let mut request_value_reader = {
3518            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3519            common::remove_json_null_values(&mut value);
3520            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3521            serde_json::to_writer(&mut dst, &value).unwrap();
3522            dst
3523        };
3524        let request_size = request_value_reader
3525            .seek(std::io::SeekFrom::End(0))
3526            .unwrap();
3527        request_value_reader
3528            .seek(std::io::SeekFrom::Start(0))
3529            .unwrap();
3530
3531        let mut upload_url_from_server;
3532
3533        loop {
3534            let token = match self
3535                .hub
3536                .auth
3537                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3538                .await
3539            {
3540                Ok(token) => token,
3541                Err(e) => match dlg.token(e) {
3542                    Ok(token) => token,
3543                    Err(e) => {
3544                        dlg.finished(false);
3545                        return Err(common::Error::MissingToken(e));
3546                    }
3547                },
3548            };
3549            request_value_reader
3550                .seek(std::io::SeekFrom::Start(0))
3551                .unwrap();
3552            let mut req_result = {
3553                let mut mp_reader: common::MultiPartReader = Default::default();
3554                let (mut body_reader, content_type) = match protocol {
3555                    common::UploadProtocol::Simple => {
3556                        mp_reader.reserve_exact(2);
3557                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
3558                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
3559                        if size > 36700160 {
3560                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
3561                        }
3562                        mp_reader
3563                            .add_part(
3564                                &mut request_value_reader,
3565                                request_size,
3566                                json_mime_type.clone(),
3567                            )
3568                            .add_part(&mut reader, size, reader_mime_type.clone());
3569                        (
3570                            &mut mp_reader as &mut (dyn std::io::Read + Send),
3571                            common::MultiPartReader::mime_type(),
3572                        )
3573                    }
3574                    _ => (
3575                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
3576                        json_mime_type.clone(),
3577                    ),
3578                };
3579                let client = &self.hub.client;
3580                dlg.pre_request();
3581                let mut req_builder = hyper::Request::builder()
3582                    .method(hyper::Method::POST)
3583                    .uri(url.as_str())
3584                    .header(USER_AGENT, self.hub._user_agent.clone());
3585
3586                if let Some(token) = token.as_ref() {
3587                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3588                }
3589
3590                upload_url_from_server = true;
3591                if protocol == common::UploadProtocol::Resumable {
3592                    req_builder = req_builder
3593                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
3594                }
3595
3596                let mut body_reader_bytes = vec![];
3597                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
3598                let request = req_builder
3599                    .header(CONTENT_TYPE, content_type.to_string())
3600                    .body(common::to_body(body_reader_bytes.into()));
3601
3602                client.request(request.unwrap()).await
3603            };
3604
3605            match req_result {
3606                Err(err) => {
3607                    if let common::Retry::After(d) = dlg.http_error(&err) {
3608                        sleep(d).await;
3609                        continue;
3610                    }
3611                    dlg.finished(false);
3612                    return Err(common::Error::HttpError(err));
3613                }
3614                Ok(res) => {
3615                    let (mut parts, body) = res.into_parts();
3616                    let mut body = common::Body::new(body);
3617                    if !parts.status.is_success() {
3618                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3619                        let error = serde_json::from_str(&common::to_string(&bytes));
3620                        let response = common::to_response(parts, bytes.into());
3621
3622                        if let common::Retry::After(d) =
3623                            dlg.http_failure(&response, error.as_ref().ok())
3624                        {
3625                            sleep(d).await;
3626                            continue;
3627                        }
3628
3629                        dlg.finished(false);
3630
3631                        return Err(match error {
3632                            Ok(value) => common::Error::BadRequest(value),
3633                            _ => common::Error::Failure(response),
3634                        });
3635                    }
3636                    if protocol == common::UploadProtocol::Resumable {
3637                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
3638                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
3639                        if size > 36700160 {
3640                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
3641                        }
3642                        let upload_result = {
3643                            let url_str = &parts
3644                                .headers
3645                                .get("Location")
3646                                .expect("LOCATION header is part of protocol")
3647                                .to_str()
3648                                .unwrap();
3649                            if upload_url_from_server {
3650                                dlg.store_upload_url(Some(url_str));
3651                            }
3652
3653                            common::ResumableUploadHelper {
3654                                client: &self.hub.client,
3655                                delegate: dlg,
3656                                start_at: if upload_url_from_server {
3657                                    Some(0)
3658                                } else {
3659                                    None
3660                                },
3661                                auth: &self.hub.auth,
3662                                user_agent: &self.hub._user_agent,
3663                                // TODO: Check this assumption
3664                                auth_header: format!(
3665                                    "Bearer {}",
3666                                    token
3667                                        .ok_or_else(|| common::Error::MissingToken(
3668                                            "resumable upload requires token".into()
3669                                        ))?
3670                                        .as_str()
3671                                ),
3672                                url: url_str,
3673                                reader: &mut reader,
3674                                media_type: reader_mime_type.clone(),
3675                                content_length: size,
3676                            }
3677                            .upload()
3678                            .await
3679                        };
3680                        match upload_result {
3681                            None => {
3682                                dlg.finished(false);
3683                                return Err(common::Error::Cancelled);
3684                            }
3685                            Some(Err(err)) => {
3686                                dlg.finished(false);
3687                                return Err(common::Error::HttpError(err));
3688                            }
3689                            Some(Ok(response)) => {
3690                                (parts, body) = response.into_parts();
3691                                if !parts.status.is_success() {
3692                                    dlg.store_upload_url(None);
3693                                    dlg.finished(false);
3694                                    return Err(common::Error::Failure(
3695                                        common::Response::from_parts(parts, body),
3696                                    ));
3697                                }
3698                            }
3699                        }
3700                    }
3701                    let response = {
3702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3703                        let encoded = common::to_string(&bytes);
3704                        match serde_json::from_str(&encoded) {
3705                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3706                            Err(error) => {
3707                                dlg.response_json_decode_error(&encoded, &error);
3708                                return Err(common::Error::JsonDecodeError(
3709                                    encoded.to_string(),
3710                                    error,
3711                                ));
3712                            }
3713                        }
3714                    };
3715
3716                    dlg.finished(true);
3717                    return Ok(response);
3718                }
3719            }
3720        }
3721    }
3722
3723    /// Upload media in a resumable fashion.
3724    /// Even if the upload fails or is interrupted, it can be resumed for a
3725    /// certain amount of time as the server maintains state temporarily.
3726    ///
3727    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
3728    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
3729    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
3730    /// `cancel_chunk_upload(...)`.
3731    ///
3732    /// * *multipart*: yes
3733    /// * *max size*: 36700160
3734    /// * *valid mime types*: 'message/*'
3735    pub async fn upload_resumable<RS>(
3736        self,
3737        resumeable_stream: RS,
3738        mime_type: mime::Mime,
3739    ) -> common::Result<(common::Response, Draft)>
3740    where
3741        RS: common::ReadSeek,
3742    {
3743        self.doit(
3744            resumeable_stream,
3745            mime_type,
3746            common::UploadProtocol::Resumable,
3747        )
3748        .await
3749    }
3750    /// Upload media all at once.
3751    /// If the upload fails for whichever reason, all progress is lost.
3752    ///
3753    /// * *multipart*: yes
3754    /// * *max size*: 36700160
3755    /// * *valid mime types*: 'message/*'
3756    pub async fn upload<RS>(
3757        self,
3758        stream: RS,
3759        mime_type: mime::Mime,
3760    ) -> common::Result<(common::Response, Draft)>
3761    where
3762        RS: common::ReadSeek,
3763    {
3764        self.doit(stream, mime_type, common::UploadProtocol::Simple)
3765            .await
3766    }
3767
3768    ///
3769    /// Sets the *request* property to the given value.
3770    ///
3771    /// Even though the property as already been set when instantiating this call,
3772    /// we provide this method for API completeness.
3773    pub fn request(mut self, new_value: Draft) -> UserDraftCreateCall<'a, C> {
3774        self._request = new_value;
3775        self
3776    }
3777    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
3778    ///
3779    /// Sets the *user id* path property to the given value.
3780    ///
3781    /// Even though the property as already been set when instantiating this call,
3782    /// we provide this method for API completeness.
3783    pub fn user_id(mut self, new_value: &str) -> UserDraftCreateCall<'a, C> {
3784        self._user_id = new_value.to_string();
3785        self
3786    }
3787    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3788    /// while executing the actual API request.
3789    ///
3790    /// ````text
3791    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3792    /// ````
3793    ///
3794    /// Sets the *delegate* property to the given value.
3795    pub fn delegate(
3796        mut self,
3797        new_value: &'a mut dyn common::Delegate,
3798    ) -> UserDraftCreateCall<'a, C> {
3799        self._delegate = Some(new_value);
3800        self
3801    }
3802
3803    /// Set any additional parameter of the query string used in the request.
3804    /// It should be used to set parameters which are not yet available through their own
3805    /// setters.
3806    ///
3807    /// Please note that this method must not be used to set any of the known parameters
3808    /// which have their own setter method. If done anyway, the request will fail.
3809    ///
3810    /// # Additional Parameters
3811    ///
3812    /// * *$.xgafv* (query-string) - V1 error format.
3813    /// * *access_token* (query-string) - OAuth access token.
3814    /// * *alt* (query-string) - Data format for response.
3815    /// * *callback* (query-string) - JSONP
3816    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3817    /// * *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.
3818    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3819    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3820    /// * *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.
3821    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3822    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3823    pub fn param<T>(mut self, name: T, value: T) -> UserDraftCreateCall<'a, C>
3824    where
3825        T: AsRef<str>,
3826    {
3827        self._additional_params
3828            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3829        self
3830    }
3831
3832    /// Identifies the authorization scope for the method you are building.
3833    ///
3834    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3835    /// [`Scope::Gmai`].
3836    ///
3837    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3838    /// tokens for more than one scope.
3839    ///
3840    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3841    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3842    /// sufficient, a read-write scope will do as well.
3843    pub fn add_scope<St>(mut self, scope: St) -> UserDraftCreateCall<'a, C>
3844    where
3845        St: AsRef<str>,
3846    {
3847        self._scopes.insert(String::from(scope.as_ref()));
3848        self
3849    }
3850    /// Identifies the authorization scope(s) for the method you are building.
3851    ///
3852    /// See [`Self::add_scope()`] for details.
3853    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftCreateCall<'a, C>
3854    where
3855        I: IntoIterator<Item = St>,
3856        St: AsRef<str>,
3857    {
3858        self._scopes
3859            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3860        self
3861    }
3862
3863    /// Removes all scopes, and no default scope will be used either.
3864    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3865    /// for details).
3866    pub fn clear_scopes(mut self) -> UserDraftCreateCall<'a, C> {
3867        self._scopes.clear();
3868        self
3869    }
3870}
3871
3872/// Immediately and permanently deletes the specified draft. Does not simply trash it.
3873///
3874/// A builder for the *drafts.delete* method supported by a *user* resource.
3875/// It is not used directly, but through a [`UserMethods`] instance.
3876///
3877/// # Example
3878///
3879/// Instantiate a resource method builder
3880///
3881/// ```test_harness,no_run
3882/// # extern crate hyper;
3883/// # extern crate hyper_rustls;
3884/// # extern crate google_gmail1 as gmail1;
3885/// # async fn dox() {
3886/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3887///
3888/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3889/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3890/// #     .with_native_roots()
3891/// #     .unwrap()
3892/// #     .https_only()
3893/// #     .enable_http2()
3894/// #     .build();
3895///
3896/// # let executor = hyper_util::rt::TokioExecutor::new();
3897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3898/// #     secret,
3899/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3900/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3901/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3902/// #     ),
3903/// # ).build().await.unwrap();
3904///
3905/// # let client = hyper_util::client::legacy::Client::builder(
3906/// #     hyper_util::rt::TokioExecutor::new()
3907/// # )
3908/// # .build(
3909/// #     hyper_rustls::HttpsConnectorBuilder::new()
3910/// #         .with_native_roots()
3911/// #         .unwrap()
3912/// #         .https_or_http()
3913/// #         .enable_http2()
3914/// #         .build()
3915/// # );
3916/// # let mut hub = Gmail::new(client, auth);
3917/// // You can configure optional parameters by calling the respective setters at will, and
3918/// // execute the final call using `doit()`.
3919/// // Values shown here are possibly random and not representative !
3920/// let result = hub.users().drafts_delete("userId", "id")
3921///              .doit().await;
3922/// # }
3923/// ```
3924pub struct UserDraftDeleteCall<'a, C>
3925where
3926    C: 'a,
3927{
3928    hub: &'a Gmail<C>,
3929    _user_id: String,
3930    _id: String,
3931    _delegate: Option<&'a mut dyn common::Delegate>,
3932    _additional_params: HashMap<String, String>,
3933    _scopes: BTreeSet<String>,
3934}
3935
3936impl<'a, C> common::CallBuilder for UserDraftDeleteCall<'a, C> {}
3937
3938impl<'a, C> UserDraftDeleteCall<'a, C>
3939where
3940    C: common::Connector,
3941{
3942    /// Perform the operation you have build so far.
3943    pub async fn doit(mut self) -> common::Result<common::Response> {
3944        use std::borrow::Cow;
3945        use std::io::{Read, Seek};
3946
3947        use common::{url::Params, ToParts};
3948        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3949
3950        let mut dd = common::DefaultDelegate;
3951        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3952        dlg.begin(common::MethodInfo {
3953            id: "gmail.users.drafts.delete",
3954            http_method: hyper::Method::DELETE,
3955        });
3956
3957        for &field in ["userId", "id"].iter() {
3958            if self._additional_params.contains_key(field) {
3959                dlg.finished(false);
3960                return Err(common::Error::FieldClash(field));
3961            }
3962        }
3963
3964        let mut params = Params::with_capacity(3 + self._additional_params.len());
3965        params.push("userId", self._user_id);
3966        params.push("id", self._id);
3967
3968        params.extend(self._additional_params.iter());
3969
3970        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/drafts/{id}";
3971        if self._scopes.is_empty() {
3972            self._scopes.insert(Scope::Gmai.as_ref().to_string());
3973        }
3974
3975        #[allow(clippy::single_element_loop)]
3976        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
3977            url = params.uri_replacement(url, param_name, find_this, false);
3978        }
3979        {
3980            let to_remove = ["id", "userId"];
3981            params.remove_params(&to_remove);
3982        }
3983
3984        let url = params.parse_with_url(&url);
3985
3986        loop {
3987            let token = match self
3988                .hub
3989                .auth
3990                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3991                .await
3992            {
3993                Ok(token) => token,
3994                Err(e) => match dlg.token(e) {
3995                    Ok(token) => token,
3996                    Err(e) => {
3997                        dlg.finished(false);
3998                        return Err(common::Error::MissingToken(e));
3999                    }
4000                },
4001            };
4002            let mut req_result = {
4003                let client = &self.hub.client;
4004                dlg.pre_request();
4005                let mut req_builder = hyper::Request::builder()
4006                    .method(hyper::Method::DELETE)
4007                    .uri(url.as_str())
4008                    .header(USER_AGENT, self.hub._user_agent.clone());
4009
4010                if let Some(token) = token.as_ref() {
4011                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4012                }
4013
4014                let request = req_builder
4015                    .header(CONTENT_LENGTH, 0_u64)
4016                    .body(common::to_body::<String>(None));
4017
4018                client.request(request.unwrap()).await
4019            };
4020
4021            match req_result {
4022                Err(err) => {
4023                    if let common::Retry::After(d) = dlg.http_error(&err) {
4024                        sleep(d).await;
4025                        continue;
4026                    }
4027                    dlg.finished(false);
4028                    return Err(common::Error::HttpError(err));
4029                }
4030                Ok(res) => {
4031                    let (mut parts, body) = res.into_parts();
4032                    let mut body = common::Body::new(body);
4033                    if !parts.status.is_success() {
4034                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4035                        let error = serde_json::from_str(&common::to_string(&bytes));
4036                        let response = common::to_response(parts, bytes.into());
4037
4038                        if let common::Retry::After(d) =
4039                            dlg.http_failure(&response, error.as_ref().ok())
4040                        {
4041                            sleep(d).await;
4042                            continue;
4043                        }
4044
4045                        dlg.finished(false);
4046
4047                        return Err(match error {
4048                            Ok(value) => common::Error::BadRequest(value),
4049                            _ => common::Error::Failure(response),
4050                        });
4051                    }
4052                    let response = common::Response::from_parts(parts, body);
4053
4054                    dlg.finished(true);
4055                    return Ok(response);
4056                }
4057            }
4058        }
4059    }
4060
4061    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
4062    ///
4063    /// Sets the *user id* path property to the given value.
4064    ///
4065    /// Even though the property as already been set when instantiating this call,
4066    /// we provide this method for API completeness.
4067    pub fn user_id(mut self, new_value: &str) -> UserDraftDeleteCall<'a, C> {
4068        self._user_id = new_value.to_string();
4069        self
4070    }
4071    /// The ID of the draft to delete.
4072    ///
4073    /// Sets the *id* path property to the given value.
4074    ///
4075    /// Even though the property as already been set when instantiating this call,
4076    /// we provide this method for API completeness.
4077    pub fn id(mut self, new_value: &str) -> UserDraftDeleteCall<'a, C> {
4078        self._id = new_value.to_string();
4079        self
4080    }
4081    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4082    /// while executing the actual API request.
4083    ///
4084    /// ````text
4085    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4086    /// ````
4087    ///
4088    /// Sets the *delegate* property to the given value.
4089    pub fn delegate(
4090        mut self,
4091        new_value: &'a mut dyn common::Delegate,
4092    ) -> UserDraftDeleteCall<'a, C> {
4093        self._delegate = Some(new_value);
4094        self
4095    }
4096
4097    /// Set any additional parameter of the query string used in the request.
4098    /// It should be used to set parameters which are not yet available through their own
4099    /// setters.
4100    ///
4101    /// Please note that this method must not be used to set any of the known parameters
4102    /// which have their own setter method. If done anyway, the request will fail.
4103    ///
4104    /// # Additional Parameters
4105    ///
4106    /// * *$.xgafv* (query-string) - V1 error format.
4107    /// * *access_token* (query-string) - OAuth access token.
4108    /// * *alt* (query-string) - Data format for response.
4109    /// * *callback* (query-string) - JSONP
4110    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4111    /// * *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.
4112    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4113    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4114    /// * *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.
4115    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4116    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4117    pub fn param<T>(mut self, name: T, value: T) -> UserDraftDeleteCall<'a, C>
4118    where
4119        T: AsRef<str>,
4120    {
4121        self._additional_params
4122            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4123        self
4124    }
4125
4126    /// Identifies the authorization scope for the method you are building.
4127    ///
4128    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4129    /// [`Scope::Gmai`].
4130    ///
4131    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4132    /// tokens for more than one scope.
4133    ///
4134    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4135    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4136    /// sufficient, a read-write scope will do as well.
4137    pub fn add_scope<St>(mut self, scope: St) -> UserDraftDeleteCall<'a, C>
4138    where
4139        St: AsRef<str>,
4140    {
4141        self._scopes.insert(String::from(scope.as_ref()));
4142        self
4143    }
4144    /// Identifies the authorization scope(s) for the method you are building.
4145    ///
4146    /// See [`Self::add_scope()`] for details.
4147    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftDeleteCall<'a, C>
4148    where
4149        I: IntoIterator<Item = St>,
4150        St: AsRef<str>,
4151    {
4152        self._scopes
4153            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4154        self
4155    }
4156
4157    /// Removes all scopes, and no default scope will be used either.
4158    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4159    /// for details).
4160    pub fn clear_scopes(mut self) -> UserDraftDeleteCall<'a, C> {
4161        self._scopes.clear();
4162        self
4163    }
4164}
4165
4166/// Gets the specified draft.
4167///
4168/// A builder for the *drafts.get* method supported by a *user* resource.
4169/// It is not used directly, but through a [`UserMethods`] instance.
4170///
4171/// # Example
4172///
4173/// Instantiate a resource method builder
4174///
4175/// ```test_harness,no_run
4176/// # extern crate hyper;
4177/// # extern crate hyper_rustls;
4178/// # extern crate google_gmail1 as gmail1;
4179/// # async fn dox() {
4180/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4181///
4182/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4183/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4184/// #     .with_native_roots()
4185/// #     .unwrap()
4186/// #     .https_only()
4187/// #     .enable_http2()
4188/// #     .build();
4189///
4190/// # let executor = hyper_util::rt::TokioExecutor::new();
4191/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4192/// #     secret,
4193/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4194/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4195/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4196/// #     ),
4197/// # ).build().await.unwrap();
4198///
4199/// # let client = hyper_util::client::legacy::Client::builder(
4200/// #     hyper_util::rt::TokioExecutor::new()
4201/// # )
4202/// # .build(
4203/// #     hyper_rustls::HttpsConnectorBuilder::new()
4204/// #         .with_native_roots()
4205/// #         .unwrap()
4206/// #         .https_or_http()
4207/// #         .enable_http2()
4208/// #         .build()
4209/// # );
4210/// # let mut hub = Gmail::new(client, auth);
4211/// // You can configure optional parameters by calling the respective setters at will, and
4212/// // execute the final call using `doit()`.
4213/// // Values shown here are possibly random and not representative !
4214/// let result = hub.users().drafts_get("userId", "id")
4215///              .format("ipsum")
4216///              .doit().await;
4217/// # }
4218/// ```
4219pub struct UserDraftGetCall<'a, C>
4220where
4221    C: 'a,
4222{
4223    hub: &'a Gmail<C>,
4224    _user_id: String,
4225    _id: String,
4226    _format: Option<String>,
4227    _delegate: Option<&'a mut dyn common::Delegate>,
4228    _additional_params: HashMap<String, String>,
4229    _scopes: BTreeSet<String>,
4230}
4231
4232impl<'a, C> common::CallBuilder for UserDraftGetCall<'a, C> {}
4233
4234impl<'a, C> UserDraftGetCall<'a, C>
4235where
4236    C: common::Connector,
4237{
4238    /// Perform the operation you have build so far.
4239    pub async fn doit(mut self) -> common::Result<(common::Response, Draft)> {
4240        use std::borrow::Cow;
4241        use std::io::{Read, Seek};
4242
4243        use common::{url::Params, ToParts};
4244        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4245
4246        let mut dd = common::DefaultDelegate;
4247        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4248        dlg.begin(common::MethodInfo {
4249            id: "gmail.users.drafts.get",
4250            http_method: hyper::Method::GET,
4251        });
4252
4253        for &field in ["alt", "userId", "id", "format"].iter() {
4254            if self._additional_params.contains_key(field) {
4255                dlg.finished(false);
4256                return Err(common::Error::FieldClash(field));
4257            }
4258        }
4259
4260        let mut params = Params::with_capacity(5 + self._additional_params.len());
4261        params.push("userId", self._user_id);
4262        params.push("id", self._id);
4263        if let Some(value) = self._format.as_ref() {
4264            params.push("format", value);
4265        }
4266
4267        params.extend(self._additional_params.iter());
4268
4269        params.push("alt", "json");
4270        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/drafts/{id}";
4271        if self._scopes.is_empty() {
4272            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4273        }
4274
4275        #[allow(clippy::single_element_loop)]
4276        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
4277            url = params.uri_replacement(url, param_name, find_this, false);
4278        }
4279        {
4280            let to_remove = ["id", "userId"];
4281            params.remove_params(&to_remove);
4282        }
4283
4284        let url = params.parse_with_url(&url);
4285
4286        loop {
4287            let token = match self
4288                .hub
4289                .auth
4290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4291                .await
4292            {
4293                Ok(token) => token,
4294                Err(e) => match dlg.token(e) {
4295                    Ok(token) => token,
4296                    Err(e) => {
4297                        dlg.finished(false);
4298                        return Err(common::Error::MissingToken(e));
4299                    }
4300                },
4301            };
4302            let mut req_result = {
4303                let client = &self.hub.client;
4304                dlg.pre_request();
4305                let mut req_builder = hyper::Request::builder()
4306                    .method(hyper::Method::GET)
4307                    .uri(url.as_str())
4308                    .header(USER_AGENT, self.hub._user_agent.clone());
4309
4310                if let Some(token) = token.as_ref() {
4311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4312                }
4313
4314                let request = req_builder
4315                    .header(CONTENT_LENGTH, 0_u64)
4316                    .body(common::to_body::<String>(None));
4317
4318                client.request(request.unwrap()).await
4319            };
4320
4321            match req_result {
4322                Err(err) => {
4323                    if let common::Retry::After(d) = dlg.http_error(&err) {
4324                        sleep(d).await;
4325                        continue;
4326                    }
4327                    dlg.finished(false);
4328                    return Err(common::Error::HttpError(err));
4329                }
4330                Ok(res) => {
4331                    let (mut parts, body) = res.into_parts();
4332                    let mut body = common::Body::new(body);
4333                    if !parts.status.is_success() {
4334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4335                        let error = serde_json::from_str(&common::to_string(&bytes));
4336                        let response = common::to_response(parts, bytes.into());
4337
4338                        if let common::Retry::After(d) =
4339                            dlg.http_failure(&response, error.as_ref().ok())
4340                        {
4341                            sleep(d).await;
4342                            continue;
4343                        }
4344
4345                        dlg.finished(false);
4346
4347                        return Err(match error {
4348                            Ok(value) => common::Error::BadRequest(value),
4349                            _ => common::Error::Failure(response),
4350                        });
4351                    }
4352                    let response = {
4353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4354                        let encoded = common::to_string(&bytes);
4355                        match serde_json::from_str(&encoded) {
4356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4357                            Err(error) => {
4358                                dlg.response_json_decode_error(&encoded, &error);
4359                                return Err(common::Error::JsonDecodeError(
4360                                    encoded.to_string(),
4361                                    error,
4362                                ));
4363                            }
4364                        }
4365                    };
4366
4367                    dlg.finished(true);
4368                    return Ok(response);
4369                }
4370            }
4371        }
4372    }
4373
4374    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
4375    ///
4376    /// Sets the *user id* path property to the given value.
4377    ///
4378    /// Even though the property as already been set when instantiating this call,
4379    /// we provide this method for API completeness.
4380    pub fn user_id(mut self, new_value: &str) -> UserDraftGetCall<'a, C> {
4381        self._user_id = new_value.to_string();
4382        self
4383    }
4384    /// The ID of the draft to retrieve.
4385    ///
4386    /// Sets the *id* path property to the given value.
4387    ///
4388    /// Even though the property as already been set when instantiating this call,
4389    /// we provide this method for API completeness.
4390    pub fn id(mut self, new_value: &str) -> UserDraftGetCall<'a, C> {
4391        self._id = new_value.to_string();
4392        self
4393    }
4394    /// The format to return the draft in.
4395    ///
4396    /// Sets the *format* query property to the given value.
4397    pub fn format(mut self, new_value: &str) -> UserDraftGetCall<'a, C> {
4398        self._format = Some(new_value.to_string());
4399        self
4400    }
4401    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4402    /// while executing the actual API request.
4403    ///
4404    /// ````text
4405    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4406    /// ````
4407    ///
4408    /// Sets the *delegate* property to the given value.
4409    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDraftGetCall<'a, C> {
4410        self._delegate = Some(new_value);
4411        self
4412    }
4413
4414    /// Set any additional parameter of the query string used in the request.
4415    /// It should be used to set parameters which are not yet available through their own
4416    /// setters.
4417    ///
4418    /// Please note that this method must not be used to set any of the known parameters
4419    /// which have their own setter method. If done anyway, the request will fail.
4420    ///
4421    /// # Additional Parameters
4422    ///
4423    /// * *$.xgafv* (query-string) - V1 error format.
4424    /// * *access_token* (query-string) - OAuth access token.
4425    /// * *alt* (query-string) - Data format for response.
4426    /// * *callback* (query-string) - JSONP
4427    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4428    /// * *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.
4429    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4430    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4431    /// * *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.
4432    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4433    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4434    pub fn param<T>(mut self, name: T, value: T) -> UserDraftGetCall<'a, C>
4435    where
4436        T: AsRef<str>,
4437    {
4438        self._additional_params
4439            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4440        self
4441    }
4442
4443    /// Identifies the authorization scope for the method you are building.
4444    ///
4445    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4446    /// [`Scope::Readonly`].
4447    ///
4448    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4449    /// tokens for more than one scope.
4450    ///
4451    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4452    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4453    /// sufficient, a read-write scope will do as well.
4454    pub fn add_scope<St>(mut self, scope: St) -> UserDraftGetCall<'a, C>
4455    where
4456        St: AsRef<str>,
4457    {
4458        self._scopes.insert(String::from(scope.as_ref()));
4459        self
4460    }
4461    /// Identifies the authorization scope(s) for the method you are building.
4462    ///
4463    /// See [`Self::add_scope()`] for details.
4464    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftGetCall<'a, C>
4465    where
4466        I: IntoIterator<Item = St>,
4467        St: AsRef<str>,
4468    {
4469        self._scopes
4470            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4471        self
4472    }
4473
4474    /// Removes all scopes, and no default scope will be used either.
4475    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4476    /// for details).
4477    pub fn clear_scopes(mut self) -> UserDraftGetCall<'a, C> {
4478        self._scopes.clear();
4479        self
4480    }
4481}
4482
4483/// Lists the drafts in the user's mailbox.
4484///
4485/// A builder for the *drafts.list* method supported by a *user* resource.
4486/// It is not used directly, but through a [`UserMethods`] instance.
4487///
4488/// # Example
4489///
4490/// Instantiate a resource method builder
4491///
4492/// ```test_harness,no_run
4493/// # extern crate hyper;
4494/// # extern crate hyper_rustls;
4495/// # extern crate google_gmail1 as gmail1;
4496/// # async fn dox() {
4497/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4498///
4499/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4500/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4501/// #     .with_native_roots()
4502/// #     .unwrap()
4503/// #     .https_only()
4504/// #     .enable_http2()
4505/// #     .build();
4506///
4507/// # let executor = hyper_util::rt::TokioExecutor::new();
4508/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4509/// #     secret,
4510/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4511/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4512/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4513/// #     ),
4514/// # ).build().await.unwrap();
4515///
4516/// # let client = hyper_util::client::legacy::Client::builder(
4517/// #     hyper_util::rt::TokioExecutor::new()
4518/// # )
4519/// # .build(
4520/// #     hyper_rustls::HttpsConnectorBuilder::new()
4521/// #         .with_native_roots()
4522/// #         .unwrap()
4523/// #         .https_or_http()
4524/// #         .enable_http2()
4525/// #         .build()
4526/// # );
4527/// # let mut hub = Gmail::new(client, auth);
4528/// // You can configure optional parameters by calling the respective setters at will, and
4529/// // execute the final call using `doit()`.
4530/// // Values shown here are possibly random and not representative !
4531/// let result = hub.users().drafts_list("userId")
4532///              .q("est")
4533///              .page_token("gubergren")
4534///              .max_results(84)
4535///              .include_spam_trash(false)
4536///              .doit().await;
4537/// # }
4538/// ```
4539pub struct UserDraftListCall<'a, C>
4540where
4541    C: 'a,
4542{
4543    hub: &'a Gmail<C>,
4544    _user_id: String,
4545    _q: Option<String>,
4546    _page_token: Option<String>,
4547    _max_results: Option<u32>,
4548    _include_spam_trash: Option<bool>,
4549    _delegate: Option<&'a mut dyn common::Delegate>,
4550    _additional_params: HashMap<String, String>,
4551    _scopes: BTreeSet<String>,
4552}
4553
4554impl<'a, C> common::CallBuilder for UserDraftListCall<'a, C> {}
4555
4556impl<'a, C> UserDraftListCall<'a, C>
4557where
4558    C: common::Connector,
4559{
4560    /// Perform the operation you have build so far.
4561    pub async fn doit(mut self) -> common::Result<(common::Response, ListDraftsResponse)> {
4562        use std::borrow::Cow;
4563        use std::io::{Read, Seek};
4564
4565        use common::{url::Params, ToParts};
4566        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4567
4568        let mut dd = common::DefaultDelegate;
4569        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4570        dlg.begin(common::MethodInfo {
4571            id: "gmail.users.drafts.list",
4572            http_method: hyper::Method::GET,
4573        });
4574
4575        for &field in [
4576            "alt",
4577            "userId",
4578            "q",
4579            "pageToken",
4580            "maxResults",
4581            "includeSpamTrash",
4582        ]
4583        .iter()
4584        {
4585            if self._additional_params.contains_key(field) {
4586                dlg.finished(false);
4587                return Err(common::Error::FieldClash(field));
4588            }
4589        }
4590
4591        let mut params = Params::with_capacity(7 + self._additional_params.len());
4592        params.push("userId", self._user_id);
4593        if let Some(value) = self._q.as_ref() {
4594            params.push("q", value);
4595        }
4596        if let Some(value) = self._page_token.as_ref() {
4597            params.push("pageToken", value);
4598        }
4599        if let Some(value) = self._max_results.as_ref() {
4600            params.push("maxResults", value.to_string());
4601        }
4602        if let Some(value) = self._include_spam_trash.as_ref() {
4603            params.push("includeSpamTrash", value.to_string());
4604        }
4605
4606        params.extend(self._additional_params.iter());
4607
4608        params.push("alt", "json");
4609        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/drafts";
4610        if self._scopes.is_empty() {
4611            self._scopes.insert(Scope::Readonly.as_ref().to_string());
4612        }
4613
4614        #[allow(clippy::single_element_loop)]
4615        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
4616            url = params.uri_replacement(url, param_name, find_this, false);
4617        }
4618        {
4619            let to_remove = ["userId"];
4620            params.remove_params(&to_remove);
4621        }
4622
4623        let url = params.parse_with_url(&url);
4624
4625        loop {
4626            let token = match self
4627                .hub
4628                .auth
4629                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4630                .await
4631            {
4632                Ok(token) => token,
4633                Err(e) => match dlg.token(e) {
4634                    Ok(token) => token,
4635                    Err(e) => {
4636                        dlg.finished(false);
4637                        return Err(common::Error::MissingToken(e));
4638                    }
4639                },
4640            };
4641            let mut req_result = {
4642                let client = &self.hub.client;
4643                dlg.pre_request();
4644                let mut req_builder = hyper::Request::builder()
4645                    .method(hyper::Method::GET)
4646                    .uri(url.as_str())
4647                    .header(USER_AGENT, self.hub._user_agent.clone());
4648
4649                if let Some(token) = token.as_ref() {
4650                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4651                }
4652
4653                let request = req_builder
4654                    .header(CONTENT_LENGTH, 0_u64)
4655                    .body(common::to_body::<String>(None));
4656
4657                client.request(request.unwrap()).await
4658            };
4659
4660            match req_result {
4661                Err(err) => {
4662                    if let common::Retry::After(d) = dlg.http_error(&err) {
4663                        sleep(d).await;
4664                        continue;
4665                    }
4666                    dlg.finished(false);
4667                    return Err(common::Error::HttpError(err));
4668                }
4669                Ok(res) => {
4670                    let (mut parts, body) = res.into_parts();
4671                    let mut body = common::Body::new(body);
4672                    if !parts.status.is_success() {
4673                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4674                        let error = serde_json::from_str(&common::to_string(&bytes));
4675                        let response = common::to_response(parts, bytes.into());
4676
4677                        if let common::Retry::After(d) =
4678                            dlg.http_failure(&response, error.as_ref().ok())
4679                        {
4680                            sleep(d).await;
4681                            continue;
4682                        }
4683
4684                        dlg.finished(false);
4685
4686                        return Err(match error {
4687                            Ok(value) => common::Error::BadRequest(value),
4688                            _ => common::Error::Failure(response),
4689                        });
4690                    }
4691                    let response = {
4692                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4693                        let encoded = common::to_string(&bytes);
4694                        match serde_json::from_str(&encoded) {
4695                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4696                            Err(error) => {
4697                                dlg.response_json_decode_error(&encoded, &error);
4698                                return Err(common::Error::JsonDecodeError(
4699                                    encoded.to_string(),
4700                                    error,
4701                                ));
4702                            }
4703                        }
4704                    };
4705
4706                    dlg.finished(true);
4707                    return Ok(response);
4708                }
4709            }
4710        }
4711    }
4712
4713    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
4714    ///
4715    /// Sets the *user id* path property to the given value.
4716    ///
4717    /// Even though the property as already been set when instantiating this call,
4718    /// we provide this method for API completeness.
4719    pub fn user_id(mut self, new_value: &str) -> UserDraftListCall<'a, C> {
4720        self._user_id = new_value.to_string();
4721        self
4722    }
4723    /// Only return draft messages matching the specified query. Supports the same query format as the Gmail search box. For example, `"from:someuser@example.com rfc822msgid: is:unread"`.
4724    ///
4725    /// Sets the *q* query property to the given value.
4726    pub fn q(mut self, new_value: &str) -> UserDraftListCall<'a, C> {
4727        self._q = Some(new_value.to_string());
4728        self
4729    }
4730    /// Page token to retrieve a specific page of results in the list.
4731    ///
4732    /// Sets the *page token* query property to the given value.
4733    pub fn page_token(mut self, new_value: &str) -> UserDraftListCall<'a, C> {
4734        self._page_token = Some(new_value.to_string());
4735        self
4736    }
4737    /// Maximum number of drafts to return. This field defaults to 100. The maximum allowed value for this field is 500.
4738    ///
4739    /// Sets the *max results* query property to the given value.
4740    pub fn max_results(mut self, new_value: u32) -> UserDraftListCall<'a, C> {
4741        self._max_results = Some(new_value);
4742        self
4743    }
4744    /// Include drafts from `SPAM` and `TRASH` in the results.
4745    ///
4746    /// Sets the *include spam trash* query property to the given value.
4747    pub fn include_spam_trash(mut self, new_value: bool) -> UserDraftListCall<'a, C> {
4748        self._include_spam_trash = Some(new_value);
4749        self
4750    }
4751    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4752    /// while executing the actual API request.
4753    ///
4754    /// ````text
4755    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4756    /// ````
4757    ///
4758    /// Sets the *delegate* property to the given value.
4759    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDraftListCall<'a, C> {
4760        self._delegate = Some(new_value);
4761        self
4762    }
4763
4764    /// Set any additional parameter of the query string used in the request.
4765    /// It should be used to set parameters which are not yet available through their own
4766    /// setters.
4767    ///
4768    /// Please note that this method must not be used to set any of the known parameters
4769    /// which have their own setter method. If done anyway, the request will fail.
4770    ///
4771    /// # Additional Parameters
4772    ///
4773    /// * *$.xgafv* (query-string) - V1 error format.
4774    /// * *access_token* (query-string) - OAuth access token.
4775    /// * *alt* (query-string) - Data format for response.
4776    /// * *callback* (query-string) - JSONP
4777    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4778    /// * *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.
4779    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4780    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4781    /// * *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.
4782    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4783    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4784    pub fn param<T>(mut self, name: T, value: T) -> UserDraftListCall<'a, C>
4785    where
4786        T: AsRef<str>,
4787    {
4788        self._additional_params
4789            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4790        self
4791    }
4792
4793    /// Identifies the authorization scope for the method you are building.
4794    ///
4795    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4796    /// [`Scope::Readonly`].
4797    ///
4798    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4799    /// tokens for more than one scope.
4800    ///
4801    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4802    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4803    /// sufficient, a read-write scope will do as well.
4804    pub fn add_scope<St>(mut self, scope: St) -> UserDraftListCall<'a, C>
4805    where
4806        St: AsRef<str>,
4807    {
4808        self._scopes.insert(String::from(scope.as_ref()));
4809        self
4810    }
4811    /// Identifies the authorization scope(s) for the method you are building.
4812    ///
4813    /// See [`Self::add_scope()`] for details.
4814    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftListCall<'a, C>
4815    where
4816        I: IntoIterator<Item = St>,
4817        St: AsRef<str>,
4818    {
4819        self._scopes
4820            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4821        self
4822    }
4823
4824    /// Removes all scopes, and no default scope will be used either.
4825    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4826    /// for details).
4827    pub fn clear_scopes(mut self) -> UserDraftListCall<'a, C> {
4828        self._scopes.clear();
4829        self
4830    }
4831}
4832
4833/// Sends the specified, existing draft to the recipients in the `To`, `Cc`, and `Bcc` headers.
4834///
4835/// A builder for the *drafts.send* method supported by a *user* resource.
4836/// It is not used directly, but through a [`UserMethods`] instance.
4837///
4838/// # Example
4839///
4840/// Instantiate a resource method builder
4841///
4842/// ```test_harness,no_run
4843/// # extern crate hyper;
4844/// # extern crate hyper_rustls;
4845/// # extern crate google_gmail1 as gmail1;
4846/// use gmail1::api::Draft;
4847/// use std::fs;
4848/// # async fn dox() {
4849/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4850///
4851/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4852/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4853/// #     .with_native_roots()
4854/// #     .unwrap()
4855/// #     .https_only()
4856/// #     .enable_http2()
4857/// #     .build();
4858///
4859/// # let executor = hyper_util::rt::TokioExecutor::new();
4860/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4861/// #     secret,
4862/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4863/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4864/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4865/// #     ),
4866/// # ).build().await.unwrap();
4867///
4868/// # let client = hyper_util::client::legacy::Client::builder(
4869/// #     hyper_util::rt::TokioExecutor::new()
4870/// # )
4871/// # .build(
4872/// #     hyper_rustls::HttpsConnectorBuilder::new()
4873/// #         .with_native_roots()
4874/// #         .unwrap()
4875/// #         .https_or_http()
4876/// #         .enable_http2()
4877/// #         .build()
4878/// # );
4879/// # let mut hub = Gmail::new(client, auth);
4880/// // As the method needs a request, you would usually fill it with the desired information
4881/// // into the respective structure. Some of the parts shown here might not be applicable !
4882/// // Values shown here are possibly random and not representative !
4883/// let mut req = Draft::default();
4884///
4885/// // You can configure optional parameters by calling the respective setters at will, and
4886/// // execute the final call using `upload_resumable(...)`.
4887/// // Values shown here are possibly random and not representative !
4888/// let result = hub.users().drafts_send(req, "userId")
4889///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
4890/// # }
4891/// ```
4892pub struct UserDraftSendCall<'a, C>
4893where
4894    C: 'a,
4895{
4896    hub: &'a Gmail<C>,
4897    _request: Draft,
4898    _user_id: String,
4899    _delegate: Option<&'a mut dyn common::Delegate>,
4900    _additional_params: HashMap<String, String>,
4901    _scopes: BTreeSet<String>,
4902}
4903
4904impl<'a, C> common::CallBuilder for UserDraftSendCall<'a, C> {}
4905
4906impl<'a, C> UserDraftSendCall<'a, C>
4907where
4908    C: common::Connector,
4909{
4910    /// Perform the operation you have build so far.
4911    async fn doit<RS>(
4912        mut self,
4913        mut reader: RS,
4914        reader_mime_type: mime::Mime,
4915        protocol: common::UploadProtocol,
4916    ) -> common::Result<(common::Response, Message)>
4917    where
4918        RS: common::ReadSeek,
4919    {
4920        use std::borrow::Cow;
4921        use std::io::{Read, Seek};
4922
4923        use common::{url::Params, ToParts};
4924        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4925
4926        let mut dd = common::DefaultDelegate;
4927        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4928        dlg.begin(common::MethodInfo {
4929            id: "gmail.users.drafts.send",
4930            http_method: hyper::Method::POST,
4931        });
4932
4933        for &field in ["alt", "userId"].iter() {
4934            if self._additional_params.contains_key(field) {
4935                dlg.finished(false);
4936                return Err(common::Error::FieldClash(field));
4937            }
4938        }
4939
4940        let mut params = Params::with_capacity(4 + self._additional_params.len());
4941        params.push("userId", self._user_id);
4942
4943        params.extend(self._additional_params.iter());
4944
4945        params.push("alt", "json");
4946        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
4947            (
4948                self.hub._root_url.clone() + "resumable/upload/gmail/v1/users/{userId}/drafts/send",
4949                "resumable",
4950            )
4951        } else if protocol == common::UploadProtocol::Simple {
4952            (
4953                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/drafts/send",
4954                "multipart",
4955            )
4956        } else {
4957            unreachable!()
4958        };
4959        params.push("uploadType", upload_type);
4960        if self._scopes.is_empty() {
4961            self._scopes.insert(Scope::Gmai.as_ref().to_string());
4962        }
4963
4964        #[allow(clippy::single_element_loop)]
4965        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
4966            url = params.uri_replacement(url, param_name, find_this, false);
4967        }
4968        {
4969            let to_remove = ["userId"];
4970            params.remove_params(&to_remove);
4971        }
4972
4973        let url = params.parse_with_url(&url);
4974
4975        let mut json_mime_type = mime::APPLICATION_JSON;
4976        let mut request_value_reader = {
4977            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4978            common::remove_json_null_values(&mut value);
4979            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4980            serde_json::to_writer(&mut dst, &value).unwrap();
4981            dst
4982        };
4983        let request_size = request_value_reader
4984            .seek(std::io::SeekFrom::End(0))
4985            .unwrap();
4986        request_value_reader
4987            .seek(std::io::SeekFrom::Start(0))
4988            .unwrap();
4989
4990        let mut upload_url_from_server;
4991
4992        loop {
4993            let token = match self
4994                .hub
4995                .auth
4996                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4997                .await
4998            {
4999                Ok(token) => token,
5000                Err(e) => match dlg.token(e) {
5001                    Ok(token) => token,
5002                    Err(e) => {
5003                        dlg.finished(false);
5004                        return Err(common::Error::MissingToken(e));
5005                    }
5006                },
5007            };
5008            request_value_reader
5009                .seek(std::io::SeekFrom::Start(0))
5010                .unwrap();
5011            let mut req_result = {
5012                let mut mp_reader: common::MultiPartReader = Default::default();
5013                let (mut body_reader, content_type) = match protocol {
5014                    common::UploadProtocol::Simple => {
5015                        mp_reader.reserve_exact(2);
5016                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
5017                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
5018                        if size > 36700160 {
5019                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
5020                        }
5021                        mp_reader
5022                            .add_part(
5023                                &mut request_value_reader,
5024                                request_size,
5025                                json_mime_type.clone(),
5026                            )
5027                            .add_part(&mut reader, size, reader_mime_type.clone());
5028                        (
5029                            &mut mp_reader as &mut (dyn std::io::Read + Send),
5030                            common::MultiPartReader::mime_type(),
5031                        )
5032                    }
5033                    _ => (
5034                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
5035                        json_mime_type.clone(),
5036                    ),
5037                };
5038                let client = &self.hub.client;
5039                dlg.pre_request();
5040                let mut req_builder = hyper::Request::builder()
5041                    .method(hyper::Method::POST)
5042                    .uri(url.as_str())
5043                    .header(USER_AGENT, self.hub._user_agent.clone());
5044
5045                if let Some(token) = token.as_ref() {
5046                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5047                }
5048
5049                upload_url_from_server = true;
5050                if protocol == common::UploadProtocol::Resumable {
5051                    req_builder = req_builder
5052                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
5053                }
5054
5055                let mut body_reader_bytes = vec![];
5056                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
5057                let request = req_builder
5058                    .header(CONTENT_TYPE, content_type.to_string())
5059                    .body(common::to_body(body_reader_bytes.into()));
5060
5061                client.request(request.unwrap()).await
5062            };
5063
5064            match req_result {
5065                Err(err) => {
5066                    if let common::Retry::After(d) = dlg.http_error(&err) {
5067                        sleep(d).await;
5068                        continue;
5069                    }
5070                    dlg.finished(false);
5071                    return Err(common::Error::HttpError(err));
5072                }
5073                Ok(res) => {
5074                    let (mut parts, body) = res.into_parts();
5075                    let mut body = common::Body::new(body);
5076                    if !parts.status.is_success() {
5077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5078                        let error = serde_json::from_str(&common::to_string(&bytes));
5079                        let response = common::to_response(parts, bytes.into());
5080
5081                        if let common::Retry::After(d) =
5082                            dlg.http_failure(&response, error.as_ref().ok())
5083                        {
5084                            sleep(d).await;
5085                            continue;
5086                        }
5087
5088                        dlg.finished(false);
5089
5090                        return Err(match error {
5091                            Ok(value) => common::Error::BadRequest(value),
5092                            _ => common::Error::Failure(response),
5093                        });
5094                    }
5095                    if protocol == common::UploadProtocol::Resumable {
5096                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
5097                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
5098                        if size > 36700160 {
5099                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
5100                        }
5101                        let upload_result = {
5102                            let url_str = &parts
5103                                .headers
5104                                .get("Location")
5105                                .expect("LOCATION header is part of protocol")
5106                                .to_str()
5107                                .unwrap();
5108                            if upload_url_from_server {
5109                                dlg.store_upload_url(Some(url_str));
5110                            }
5111
5112                            common::ResumableUploadHelper {
5113                                client: &self.hub.client,
5114                                delegate: dlg,
5115                                start_at: if upload_url_from_server {
5116                                    Some(0)
5117                                } else {
5118                                    None
5119                                },
5120                                auth: &self.hub.auth,
5121                                user_agent: &self.hub._user_agent,
5122                                // TODO: Check this assumption
5123                                auth_header: format!(
5124                                    "Bearer {}",
5125                                    token
5126                                        .ok_or_else(|| common::Error::MissingToken(
5127                                            "resumable upload requires token".into()
5128                                        ))?
5129                                        .as_str()
5130                                ),
5131                                url: url_str,
5132                                reader: &mut reader,
5133                                media_type: reader_mime_type.clone(),
5134                                content_length: size,
5135                            }
5136                            .upload()
5137                            .await
5138                        };
5139                        match upload_result {
5140                            None => {
5141                                dlg.finished(false);
5142                                return Err(common::Error::Cancelled);
5143                            }
5144                            Some(Err(err)) => {
5145                                dlg.finished(false);
5146                                return Err(common::Error::HttpError(err));
5147                            }
5148                            Some(Ok(response)) => {
5149                                (parts, body) = response.into_parts();
5150                                if !parts.status.is_success() {
5151                                    dlg.store_upload_url(None);
5152                                    dlg.finished(false);
5153                                    return Err(common::Error::Failure(
5154                                        common::Response::from_parts(parts, body),
5155                                    ));
5156                                }
5157                            }
5158                        }
5159                    }
5160                    let response = {
5161                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5162                        let encoded = common::to_string(&bytes);
5163                        match serde_json::from_str(&encoded) {
5164                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5165                            Err(error) => {
5166                                dlg.response_json_decode_error(&encoded, &error);
5167                                return Err(common::Error::JsonDecodeError(
5168                                    encoded.to_string(),
5169                                    error,
5170                                ));
5171                            }
5172                        }
5173                    };
5174
5175                    dlg.finished(true);
5176                    return Ok(response);
5177                }
5178            }
5179        }
5180    }
5181
5182    /// Upload media in a resumable fashion.
5183    /// Even if the upload fails or is interrupted, it can be resumed for a
5184    /// certain amount of time as the server maintains state temporarily.
5185    ///
5186    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
5187    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
5188    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
5189    /// `cancel_chunk_upload(...)`.
5190    ///
5191    /// * *multipart*: yes
5192    /// * *max size*: 36700160
5193    /// * *valid mime types*: 'message/*'
5194    pub async fn upload_resumable<RS>(
5195        self,
5196        resumeable_stream: RS,
5197        mime_type: mime::Mime,
5198    ) -> common::Result<(common::Response, Message)>
5199    where
5200        RS: common::ReadSeek,
5201    {
5202        self.doit(
5203            resumeable_stream,
5204            mime_type,
5205            common::UploadProtocol::Resumable,
5206        )
5207        .await
5208    }
5209    /// Upload media all at once.
5210    /// If the upload fails for whichever reason, all progress is lost.
5211    ///
5212    /// * *multipart*: yes
5213    /// * *max size*: 36700160
5214    /// * *valid mime types*: 'message/*'
5215    pub async fn upload<RS>(
5216        self,
5217        stream: RS,
5218        mime_type: mime::Mime,
5219    ) -> common::Result<(common::Response, Message)>
5220    where
5221        RS: common::ReadSeek,
5222    {
5223        self.doit(stream, mime_type, common::UploadProtocol::Simple)
5224            .await
5225    }
5226
5227    ///
5228    /// Sets the *request* property to the given value.
5229    ///
5230    /// Even though the property as already been set when instantiating this call,
5231    /// we provide this method for API completeness.
5232    pub fn request(mut self, new_value: Draft) -> UserDraftSendCall<'a, C> {
5233        self._request = new_value;
5234        self
5235    }
5236    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
5237    ///
5238    /// Sets the *user id* path property to the given value.
5239    ///
5240    /// Even though the property as already been set when instantiating this call,
5241    /// we provide this method for API completeness.
5242    pub fn user_id(mut self, new_value: &str) -> UserDraftSendCall<'a, C> {
5243        self._user_id = new_value.to_string();
5244        self
5245    }
5246    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5247    /// while executing the actual API request.
5248    ///
5249    /// ````text
5250    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5251    /// ````
5252    ///
5253    /// Sets the *delegate* property to the given value.
5254    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserDraftSendCall<'a, C> {
5255        self._delegate = Some(new_value);
5256        self
5257    }
5258
5259    /// Set any additional parameter of the query string used in the request.
5260    /// It should be used to set parameters which are not yet available through their own
5261    /// setters.
5262    ///
5263    /// Please note that this method must not be used to set any of the known parameters
5264    /// which have their own setter method. If done anyway, the request will fail.
5265    ///
5266    /// # Additional Parameters
5267    ///
5268    /// * *$.xgafv* (query-string) - V1 error format.
5269    /// * *access_token* (query-string) - OAuth access token.
5270    /// * *alt* (query-string) - Data format for response.
5271    /// * *callback* (query-string) - JSONP
5272    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5273    /// * *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.
5274    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5275    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5276    /// * *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.
5277    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5278    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5279    pub fn param<T>(mut self, name: T, value: T) -> UserDraftSendCall<'a, C>
5280    where
5281        T: AsRef<str>,
5282    {
5283        self._additional_params
5284            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5285        self
5286    }
5287
5288    /// Identifies the authorization scope for the method you are building.
5289    ///
5290    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5291    /// [`Scope::Gmai`].
5292    ///
5293    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5294    /// tokens for more than one scope.
5295    ///
5296    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5297    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5298    /// sufficient, a read-write scope will do as well.
5299    pub fn add_scope<St>(mut self, scope: St) -> UserDraftSendCall<'a, C>
5300    where
5301        St: AsRef<str>,
5302    {
5303        self._scopes.insert(String::from(scope.as_ref()));
5304        self
5305    }
5306    /// Identifies the authorization scope(s) for the method you are building.
5307    ///
5308    /// See [`Self::add_scope()`] for details.
5309    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftSendCall<'a, C>
5310    where
5311        I: IntoIterator<Item = St>,
5312        St: AsRef<str>,
5313    {
5314        self._scopes
5315            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5316        self
5317    }
5318
5319    /// Removes all scopes, and no default scope will be used either.
5320    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5321    /// for details).
5322    pub fn clear_scopes(mut self) -> UserDraftSendCall<'a, C> {
5323        self._scopes.clear();
5324        self
5325    }
5326}
5327
5328/// Replaces a draft's content.
5329///
5330/// A builder for the *drafts.update* method supported by a *user* resource.
5331/// It is not used directly, but through a [`UserMethods`] instance.
5332///
5333/// # Example
5334///
5335/// Instantiate a resource method builder
5336///
5337/// ```test_harness,no_run
5338/// # extern crate hyper;
5339/// # extern crate hyper_rustls;
5340/// # extern crate google_gmail1 as gmail1;
5341/// use gmail1::api::Draft;
5342/// use std::fs;
5343/// # async fn dox() {
5344/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5345///
5346/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5347/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5348/// #     .with_native_roots()
5349/// #     .unwrap()
5350/// #     .https_only()
5351/// #     .enable_http2()
5352/// #     .build();
5353///
5354/// # let executor = hyper_util::rt::TokioExecutor::new();
5355/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5356/// #     secret,
5357/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5358/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5359/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5360/// #     ),
5361/// # ).build().await.unwrap();
5362///
5363/// # let client = hyper_util::client::legacy::Client::builder(
5364/// #     hyper_util::rt::TokioExecutor::new()
5365/// # )
5366/// # .build(
5367/// #     hyper_rustls::HttpsConnectorBuilder::new()
5368/// #         .with_native_roots()
5369/// #         .unwrap()
5370/// #         .https_or_http()
5371/// #         .enable_http2()
5372/// #         .build()
5373/// # );
5374/// # let mut hub = Gmail::new(client, auth);
5375/// // As the method needs a request, you would usually fill it with the desired information
5376/// // into the respective structure. Some of the parts shown here might not be applicable !
5377/// // Values shown here are possibly random and not representative !
5378/// let mut req = Draft::default();
5379///
5380/// // You can configure optional parameters by calling the respective setters at will, and
5381/// // execute the final call using `upload_resumable(...)`.
5382/// // Values shown here are possibly random and not representative !
5383/// let result = hub.users().drafts_update(req, "userId", "id")
5384///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
5385/// # }
5386/// ```
5387pub struct UserDraftUpdateCall<'a, C>
5388where
5389    C: 'a,
5390{
5391    hub: &'a Gmail<C>,
5392    _request: Draft,
5393    _user_id: String,
5394    _id: String,
5395    _delegate: Option<&'a mut dyn common::Delegate>,
5396    _additional_params: HashMap<String, String>,
5397    _scopes: BTreeSet<String>,
5398}
5399
5400impl<'a, C> common::CallBuilder for UserDraftUpdateCall<'a, C> {}
5401
5402impl<'a, C> UserDraftUpdateCall<'a, C>
5403where
5404    C: common::Connector,
5405{
5406    /// Perform the operation you have build so far.
5407    async fn doit<RS>(
5408        mut self,
5409        mut reader: RS,
5410        reader_mime_type: mime::Mime,
5411        protocol: common::UploadProtocol,
5412    ) -> common::Result<(common::Response, Draft)>
5413    where
5414        RS: common::ReadSeek,
5415    {
5416        use std::borrow::Cow;
5417        use std::io::{Read, Seek};
5418
5419        use common::{url::Params, ToParts};
5420        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5421
5422        let mut dd = common::DefaultDelegate;
5423        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5424        dlg.begin(common::MethodInfo {
5425            id: "gmail.users.drafts.update",
5426            http_method: hyper::Method::PUT,
5427        });
5428
5429        for &field in ["alt", "userId", "id"].iter() {
5430            if self._additional_params.contains_key(field) {
5431                dlg.finished(false);
5432                return Err(common::Error::FieldClash(field));
5433            }
5434        }
5435
5436        let mut params = Params::with_capacity(5 + self._additional_params.len());
5437        params.push("userId", self._user_id);
5438        params.push("id", self._id);
5439
5440        params.extend(self._additional_params.iter());
5441
5442        params.push("alt", "json");
5443        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
5444            (
5445                self.hub._root_url.clone() + "resumable/upload/gmail/v1/users/{userId}/drafts/{id}",
5446                "resumable",
5447            )
5448        } else if protocol == common::UploadProtocol::Simple {
5449            (
5450                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/drafts/{id}",
5451                "multipart",
5452            )
5453        } else {
5454            unreachable!()
5455        };
5456        params.push("uploadType", upload_type);
5457        if self._scopes.is_empty() {
5458            self._scopes.insert(Scope::Gmai.as_ref().to_string());
5459        }
5460
5461        #[allow(clippy::single_element_loop)]
5462        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
5463            url = params.uri_replacement(url, param_name, find_this, false);
5464        }
5465        {
5466            let to_remove = ["id", "userId"];
5467            params.remove_params(&to_remove);
5468        }
5469
5470        let url = params.parse_with_url(&url);
5471
5472        let mut json_mime_type = mime::APPLICATION_JSON;
5473        let mut request_value_reader = {
5474            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5475            common::remove_json_null_values(&mut value);
5476            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5477            serde_json::to_writer(&mut dst, &value).unwrap();
5478            dst
5479        };
5480        let request_size = request_value_reader
5481            .seek(std::io::SeekFrom::End(0))
5482            .unwrap();
5483        request_value_reader
5484            .seek(std::io::SeekFrom::Start(0))
5485            .unwrap();
5486
5487        let mut upload_url_from_server;
5488
5489        loop {
5490            let token = match self
5491                .hub
5492                .auth
5493                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5494                .await
5495            {
5496                Ok(token) => token,
5497                Err(e) => match dlg.token(e) {
5498                    Ok(token) => token,
5499                    Err(e) => {
5500                        dlg.finished(false);
5501                        return Err(common::Error::MissingToken(e));
5502                    }
5503                },
5504            };
5505            request_value_reader
5506                .seek(std::io::SeekFrom::Start(0))
5507                .unwrap();
5508            let mut req_result = {
5509                let mut mp_reader: common::MultiPartReader = Default::default();
5510                let (mut body_reader, content_type) = match protocol {
5511                    common::UploadProtocol::Simple => {
5512                        mp_reader.reserve_exact(2);
5513                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
5514                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
5515                        if size > 36700160 {
5516                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
5517                        }
5518                        mp_reader
5519                            .add_part(
5520                                &mut request_value_reader,
5521                                request_size,
5522                                json_mime_type.clone(),
5523                            )
5524                            .add_part(&mut reader, size, reader_mime_type.clone());
5525                        (
5526                            &mut mp_reader as &mut (dyn std::io::Read + Send),
5527                            common::MultiPartReader::mime_type(),
5528                        )
5529                    }
5530                    _ => (
5531                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
5532                        json_mime_type.clone(),
5533                    ),
5534                };
5535                let client = &self.hub.client;
5536                dlg.pre_request();
5537                let mut req_builder = hyper::Request::builder()
5538                    .method(hyper::Method::PUT)
5539                    .uri(url.as_str())
5540                    .header(USER_AGENT, self.hub._user_agent.clone());
5541
5542                if let Some(token) = token.as_ref() {
5543                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5544                }
5545
5546                upload_url_from_server = true;
5547                if protocol == common::UploadProtocol::Resumable {
5548                    req_builder = req_builder
5549                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
5550                }
5551
5552                let mut body_reader_bytes = vec![];
5553                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
5554                let request = req_builder
5555                    .header(CONTENT_TYPE, content_type.to_string())
5556                    .body(common::to_body(body_reader_bytes.into()));
5557
5558                client.request(request.unwrap()).await
5559            };
5560
5561            match req_result {
5562                Err(err) => {
5563                    if let common::Retry::After(d) = dlg.http_error(&err) {
5564                        sleep(d).await;
5565                        continue;
5566                    }
5567                    dlg.finished(false);
5568                    return Err(common::Error::HttpError(err));
5569                }
5570                Ok(res) => {
5571                    let (mut parts, body) = res.into_parts();
5572                    let mut body = common::Body::new(body);
5573                    if !parts.status.is_success() {
5574                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5575                        let error = serde_json::from_str(&common::to_string(&bytes));
5576                        let response = common::to_response(parts, bytes.into());
5577
5578                        if let common::Retry::After(d) =
5579                            dlg.http_failure(&response, error.as_ref().ok())
5580                        {
5581                            sleep(d).await;
5582                            continue;
5583                        }
5584
5585                        dlg.finished(false);
5586
5587                        return Err(match error {
5588                            Ok(value) => common::Error::BadRequest(value),
5589                            _ => common::Error::Failure(response),
5590                        });
5591                    }
5592                    if protocol == common::UploadProtocol::Resumable {
5593                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
5594                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
5595                        if size > 36700160 {
5596                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
5597                        }
5598                        let upload_result = {
5599                            let url_str = &parts
5600                                .headers
5601                                .get("Location")
5602                                .expect("LOCATION header is part of protocol")
5603                                .to_str()
5604                                .unwrap();
5605                            if upload_url_from_server {
5606                                dlg.store_upload_url(Some(url_str));
5607                            }
5608
5609                            common::ResumableUploadHelper {
5610                                client: &self.hub.client,
5611                                delegate: dlg,
5612                                start_at: if upload_url_from_server {
5613                                    Some(0)
5614                                } else {
5615                                    None
5616                                },
5617                                auth: &self.hub.auth,
5618                                user_agent: &self.hub._user_agent,
5619                                // TODO: Check this assumption
5620                                auth_header: format!(
5621                                    "Bearer {}",
5622                                    token
5623                                        .ok_or_else(|| common::Error::MissingToken(
5624                                            "resumable upload requires token".into()
5625                                        ))?
5626                                        .as_str()
5627                                ),
5628                                url: url_str,
5629                                reader: &mut reader,
5630                                media_type: reader_mime_type.clone(),
5631                                content_length: size,
5632                            }
5633                            .upload()
5634                            .await
5635                        };
5636                        match upload_result {
5637                            None => {
5638                                dlg.finished(false);
5639                                return Err(common::Error::Cancelled);
5640                            }
5641                            Some(Err(err)) => {
5642                                dlg.finished(false);
5643                                return Err(common::Error::HttpError(err));
5644                            }
5645                            Some(Ok(response)) => {
5646                                (parts, body) = response.into_parts();
5647                                if !parts.status.is_success() {
5648                                    dlg.store_upload_url(None);
5649                                    dlg.finished(false);
5650                                    return Err(common::Error::Failure(
5651                                        common::Response::from_parts(parts, body),
5652                                    ));
5653                                }
5654                            }
5655                        }
5656                    }
5657                    let response = {
5658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5659                        let encoded = common::to_string(&bytes);
5660                        match serde_json::from_str(&encoded) {
5661                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5662                            Err(error) => {
5663                                dlg.response_json_decode_error(&encoded, &error);
5664                                return Err(common::Error::JsonDecodeError(
5665                                    encoded.to_string(),
5666                                    error,
5667                                ));
5668                            }
5669                        }
5670                    };
5671
5672                    dlg.finished(true);
5673                    return Ok(response);
5674                }
5675            }
5676        }
5677    }
5678
5679    /// Upload media in a resumable fashion.
5680    /// Even if the upload fails or is interrupted, it can be resumed for a
5681    /// certain amount of time as the server maintains state temporarily.
5682    ///
5683    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
5684    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
5685    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
5686    /// `cancel_chunk_upload(...)`.
5687    ///
5688    /// * *multipart*: yes
5689    /// * *max size*: 36700160
5690    /// * *valid mime types*: 'message/*'
5691    pub async fn upload_resumable<RS>(
5692        self,
5693        resumeable_stream: RS,
5694        mime_type: mime::Mime,
5695    ) -> common::Result<(common::Response, Draft)>
5696    where
5697        RS: common::ReadSeek,
5698    {
5699        self.doit(
5700            resumeable_stream,
5701            mime_type,
5702            common::UploadProtocol::Resumable,
5703        )
5704        .await
5705    }
5706    /// Upload media all at once.
5707    /// If the upload fails for whichever reason, all progress is lost.
5708    ///
5709    /// * *multipart*: yes
5710    /// * *max size*: 36700160
5711    /// * *valid mime types*: 'message/*'
5712    pub async fn upload<RS>(
5713        self,
5714        stream: RS,
5715        mime_type: mime::Mime,
5716    ) -> common::Result<(common::Response, Draft)>
5717    where
5718        RS: common::ReadSeek,
5719    {
5720        self.doit(stream, mime_type, common::UploadProtocol::Simple)
5721            .await
5722    }
5723
5724    ///
5725    /// Sets the *request* property to the given value.
5726    ///
5727    /// Even though the property as already been set when instantiating this call,
5728    /// we provide this method for API completeness.
5729    pub fn request(mut self, new_value: Draft) -> UserDraftUpdateCall<'a, C> {
5730        self._request = new_value;
5731        self
5732    }
5733    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
5734    ///
5735    /// Sets the *user id* path property to the given value.
5736    ///
5737    /// Even though the property as already been set when instantiating this call,
5738    /// we provide this method for API completeness.
5739    pub fn user_id(mut self, new_value: &str) -> UserDraftUpdateCall<'a, C> {
5740        self._user_id = new_value.to_string();
5741        self
5742    }
5743    /// The ID of the draft to update.
5744    ///
5745    /// Sets the *id* path property to the given value.
5746    ///
5747    /// Even though the property as already been set when instantiating this call,
5748    /// we provide this method for API completeness.
5749    pub fn id(mut self, new_value: &str) -> UserDraftUpdateCall<'a, C> {
5750        self._id = new_value.to_string();
5751        self
5752    }
5753    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5754    /// while executing the actual API request.
5755    ///
5756    /// ````text
5757    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5758    /// ````
5759    ///
5760    /// Sets the *delegate* property to the given value.
5761    pub fn delegate(
5762        mut self,
5763        new_value: &'a mut dyn common::Delegate,
5764    ) -> UserDraftUpdateCall<'a, C> {
5765        self._delegate = Some(new_value);
5766        self
5767    }
5768
5769    /// Set any additional parameter of the query string used in the request.
5770    /// It should be used to set parameters which are not yet available through their own
5771    /// setters.
5772    ///
5773    /// Please note that this method must not be used to set any of the known parameters
5774    /// which have their own setter method. If done anyway, the request will fail.
5775    ///
5776    /// # Additional Parameters
5777    ///
5778    /// * *$.xgafv* (query-string) - V1 error format.
5779    /// * *access_token* (query-string) - OAuth access token.
5780    /// * *alt* (query-string) - Data format for response.
5781    /// * *callback* (query-string) - JSONP
5782    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5783    /// * *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.
5784    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5785    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5786    /// * *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.
5787    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5788    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5789    pub fn param<T>(mut self, name: T, value: T) -> UserDraftUpdateCall<'a, C>
5790    where
5791        T: AsRef<str>,
5792    {
5793        self._additional_params
5794            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5795        self
5796    }
5797
5798    /// Identifies the authorization scope for the method you are building.
5799    ///
5800    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5801    /// [`Scope::Gmai`].
5802    ///
5803    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5804    /// tokens for more than one scope.
5805    ///
5806    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5807    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5808    /// sufficient, a read-write scope will do as well.
5809    pub fn add_scope<St>(mut self, scope: St) -> UserDraftUpdateCall<'a, C>
5810    where
5811        St: AsRef<str>,
5812    {
5813        self._scopes.insert(String::from(scope.as_ref()));
5814        self
5815    }
5816    /// Identifies the authorization scope(s) for the method you are building.
5817    ///
5818    /// See [`Self::add_scope()`] for details.
5819    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserDraftUpdateCall<'a, C>
5820    where
5821        I: IntoIterator<Item = St>,
5822        St: AsRef<str>,
5823    {
5824        self._scopes
5825            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5826        self
5827    }
5828
5829    /// Removes all scopes, and no default scope will be used either.
5830    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5831    /// for details).
5832    pub fn clear_scopes(mut self) -> UserDraftUpdateCall<'a, C> {
5833        self._scopes.clear();
5834        self
5835    }
5836}
5837
5838/// Lists the history of all changes to the given mailbox. History results are returned in chronological order (increasing `historyId`).
5839///
5840/// A builder for the *history.list* method supported by a *user* resource.
5841/// It is not used directly, but through a [`UserMethods`] instance.
5842///
5843/// # Example
5844///
5845/// Instantiate a resource method builder
5846///
5847/// ```test_harness,no_run
5848/// # extern crate hyper;
5849/// # extern crate hyper_rustls;
5850/// # extern crate google_gmail1 as gmail1;
5851/// # async fn dox() {
5852/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5853///
5854/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5855/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5856/// #     .with_native_roots()
5857/// #     .unwrap()
5858/// #     .https_only()
5859/// #     .enable_http2()
5860/// #     .build();
5861///
5862/// # let executor = hyper_util::rt::TokioExecutor::new();
5863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5864/// #     secret,
5865/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5866/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5867/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5868/// #     ),
5869/// # ).build().await.unwrap();
5870///
5871/// # let client = hyper_util::client::legacy::Client::builder(
5872/// #     hyper_util::rt::TokioExecutor::new()
5873/// # )
5874/// # .build(
5875/// #     hyper_rustls::HttpsConnectorBuilder::new()
5876/// #         .with_native_roots()
5877/// #         .unwrap()
5878/// #         .https_or_http()
5879/// #         .enable_http2()
5880/// #         .build()
5881/// # );
5882/// # let mut hub = Gmail::new(client, auth);
5883/// // You can configure optional parameters by calling the respective setters at will, and
5884/// // execute the final call using `doit()`.
5885/// // Values shown here are possibly random and not representative !
5886/// let result = hub.users().history_list("userId")
5887///              .start_history_id(31)
5888///              .page_token("sed")
5889///              .max_results(40)
5890///              .label_id("Stet")
5891///              .add_history_types("kasd")
5892///              .doit().await;
5893/// # }
5894/// ```
5895pub struct UserHistoryListCall<'a, C>
5896where
5897    C: 'a,
5898{
5899    hub: &'a Gmail<C>,
5900    _user_id: String,
5901    _start_history_id: Option<u64>,
5902    _page_token: Option<String>,
5903    _max_results: Option<u32>,
5904    _label_id: Option<String>,
5905    _history_types: Vec<String>,
5906    _delegate: Option<&'a mut dyn common::Delegate>,
5907    _additional_params: HashMap<String, String>,
5908    _scopes: BTreeSet<String>,
5909}
5910
5911impl<'a, C> common::CallBuilder for UserHistoryListCall<'a, C> {}
5912
5913impl<'a, C> UserHistoryListCall<'a, C>
5914where
5915    C: common::Connector,
5916{
5917    /// Perform the operation you have build so far.
5918    pub async fn doit(mut self) -> common::Result<(common::Response, ListHistoryResponse)> {
5919        use std::borrow::Cow;
5920        use std::io::{Read, Seek};
5921
5922        use common::{url::Params, ToParts};
5923        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5924
5925        let mut dd = common::DefaultDelegate;
5926        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5927        dlg.begin(common::MethodInfo {
5928            id: "gmail.users.history.list",
5929            http_method: hyper::Method::GET,
5930        });
5931
5932        for &field in [
5933            "alt",
5934            "userId",
5935            "startHistoryId",
5936            "pageToken",
5937            "maxResults",
5938            "labelId",
5939            "historyTypes",
5940        ]
5941        .iter()
5942        {
5943            if self._additional_params.contains_key(field) {
5944                dlg.finished(false);
5945                return Err(common::Error::FieldClash(field));
5946            }
5947        }
5948
5949        let mut params = Params::with_capacity(8 + self._additional_params.len());
5950        params.push("userId", self._user_id);
5951        if let Some(value) = self._start_history_id.as_ref() {
5952            params.push("startHistoryId", value.to_string());
5953        }
5954        if let Some(value) = self._page_token.as_ref() {
5955            params.push("pageToken", value);
5956        }
5957        if let Some(value) = self._max_results.as_ref() {
5958            params.push("maxResults", value.to_string());
5959        }
5960        if let Some(value) = self._label_id.as_ref() {
5961            params.push("labelId", value);
5962        }
5963        if !self._history_types.is_empty() {
5964            for f in self._history_types.iter() {
5965                params.push("historyTypes", f);
5966            }
5967        }
5968
5969        params.extend(self._additional_params.iter());
5970
5971        params.push("alt", "json");
5972        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/history";
5973        if self._scopes.is_empty() {
5974            self._scopes.insert(Scope::Readonly.as_ref().to_string());
5975        }
5976
5977        #[allow(clippy::single_element_loop)]
5978        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
5979            url = params.uri_replacement(url, param_name, find_this, false);
5980        }
5981        {
5982            let to_remove = ["userId"];
5983            params.remove_params(&to_remove);
5984        }
5985
5986        let url = params.parse_with_url(&url);
5987
5988        loop {
5989            let token = match self
5990                .hub
5991                .auth
5992                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5993                .await
5994            {
5995                Ok(token) => token,
5996                Err(e) => match dlg.token(e) {
5997                    Ok(token) => token,
5998                    Err(e) => {
5999                        dlg.finished(false);
6000                        return Err(common::Error::MissingToken(e));
6001                    }
6002                },
6003            };
6004            let mut req_result = {
6005                let client = &self.hub.client;
6006                dlg.pre_request();
6007                let mut req_builder = hyper::Request::builder()
6008                    .method(hyper::Method::GET)
6009                    .uri(url.as_str())
6010                    .header(USER_AGENT, self.hub._user_agent.clone());
6011
6012                if let Some(token) = token.as_ref() {
6013                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6014                }
6015
6016                let request = req_builder
6017                    .header(CONTENT_LENGTH, 0_u64)
6018                    .body(common::to_body::<String>(None));
6019
6020                client.request(request.unwrap()).await
6021            };
6022
6023            match req_result {
6024                Err(err) => {
6025                    if let common::Retry::After(d) = dlg.http_error(&err) {
6026                        sleep(d).await;
6027                        continue;
6028                    }
6029                    dlg.finished(false);
6030                    return Err(common::Error::HttpError(err));
6031                }
6032                Ok(res) => {
6033                    let (mut parts, body) = res.into_parts();
6034                    let mut body = common::Body::new(body);
6035                    if !parts.status.is_success() {
6036                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6037                        let error = serde_json::from_str(&common::to_string(&bytes));
6038                        let response = common::to_response(parts, bytes.into());
6039
6040                        if let common::Retry::After(d) =
6041                            dlg.http_failure(&response, error.as_ref().ok())
6042                        {
6043                            sleep(d).await;
6044                            continue;
6045                        }
6046
6047                        dlg.finished(false);
6048
6049                        return Err(match error {
6050                            Ok(value) => common::Error::BadRequest(value),
6051                            _ => common::Error::Failure(response),
6052                        });
6053                    }
6054                    let response = {
6055                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6056                        let encoded = common::to_string(&bytes);
6057                        match serde_json::from_str(&encoded) {
6058                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6059                            Err(error) => {
6060                                dlg.response_json_decode_error(&encoded, &error);
6061                                return Err(common::Error::JsonDecodeError(
6062                                    encoded.to_string(),
6063                                    error,
6064                                ));
6065                            }
6066                        }
6067                    };
6068
6069                    dlg.finished(true);
6070                    return Ok(response);
6071                }
6072            }
6073        }
6074    }
6075
6076    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
6077    ///
6078    /// Sets the *user id* path property to the given value.
6079    ///
6080    /// Even though the property as already been set when instantiating this call,
6081    /// we provide this method for API completeness.
6082    pub fn user_id(mut self, new_value: &str) -> UserHistoryListCall<'a, C> {
6083        self._user_id = new_value.to_string();
6084        self
6085    }
6086    /// Required. Returns history records after the specified `startHistoryId`. The supplied `startHistoryId` should be obtained from the `historyId` of a message, thread, or previous `list` response. History IDs increase chronologically but are not contiguous with random gaps in between valid IDs. Supplying an invalid or out of date `startHistoryId` typically returns an `HTTP 404` error code. A `historyId` is typically valid for at least a week, but in some rare circumstances may be valid for only a few hours. If you receive an `HTTP 404` error response, your application should perform a full sync. If you receive no `nextPageToken` in the response, there are no updates to retrieve and you can store the returned `historyId` for a future request.
6087    ///
6088    /// Sets the *start history id* query property to the given value.
6089    pub fn start_history_id(mut self, new_value: u64) -> UserHistoryListCall<'a, C> {
6090        self._start_history_id = Some(new_value);
6091        self
6092    }
6093    /// Page token to retrieve a specific page of results in the list.
6094    ///
6095    /// Sets the *page token* query property to the given value.
6096    pub fn page_token(mut self, new_value: &str) -> UserHistoryListCall<'a, C> {
6097        self._page_token = Some(new_value.to_string());
6098        self
6099    }
6100    /// Maximum number of history records to return. This field defaults to 100. The maximum allowed value for this field is 500.
6101    ///
6102    /// Sets the *max results* query property to the given value.
6103    pub fn max_results(mut self, new_value: u32) -> UserHistoryListCall<'a, C> {
6104        self._max_results = Some(new_value);
6105        self
6106    }
6107    /// Only return messages with a label matching the ID.
6108    ///
6109    /// Sets the *label id* query property to the given value.
6110    pub fn label_id(mut self, new_value: &str) -> UserHistoryListCall<'a, C> {
6111        self._label_id = Some(new_value.to_string());
6112        self
6113    }
6114    /// History types to be returned by the function
6115    ///
6116    /// Append the given value to the *history types* query property.
6117    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
6118    pub fn add_history_types(mut self, new_value: &str) -> UserHistoryListCall<'a, C> {
6119        self._history_types.push(new_value.to_string());
6120        self
6121    }
6122    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6123    /// while executing the actual API request.
6124    ///
6125    /// ````text
6126    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6127    /// ````
6128    ///
6129    /// Sets the *delegate* property to the given value.
6130    pub fn delegate(
6131        mut self,
6132        new_value: &'a mut dyn common::Delegate,
6133    ) -> UserHistoryListCall<'a, C> {
6134        self._delegate = Some(new_value);
6135        self
6136    }
6137
6138    /// Set any additional parameter of the query string used in the request.
6139    /// It should be used to set parameters which are not yet available through their own
6140    /// setters.
6141    ///
6142    /// Please note that this method must not be used to set any of the known parameters
6143    /// which have their own setter method. If done anyway, the request will fail.
6144    ///
6145    /// # Additional Parameters
6146    ///
6147    /// * *$.xgafv* (query-string) - V1 error format.
6148    /// * *access_token* (query-string) - OAuth access token.
6149    /// * *alt* (query-string) - Data format for response.
6150    /// * *callback* (query-string) - JSONP
6151    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6152    /// * *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.
6153    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6154    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6155    /// * *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.
6156    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6157    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6158    pub fn param<T>(mut self, name: T, value: T) -> UserHistoryListCall<'a, C>
6159    where
6160        T: AsRef<str>,
6161    {
6162        self._additional_params
6163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6164        self
6165    }
6166
6167    /// Identifies the authorization scope for the method you are building.
6168    ///
6169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6170    /// [`Scope::Readonly`].
6171    ///
6172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6173    /// tokens for more than one scope.
6174    ///
6175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6177    /// sufficient, a read-write scope will do as well.
6178    pub fn add_scope<St>(mut self, scope: St) -> UserHistoryListCall<'a, C>
6179    where
6180        St: AsRef<str>,
6181    {
6182        self._scopes.insert(String::from(scope.as_ref()));
6183        self
6184    }
6185    /// Identifies the authorization scope(s) for the method you are building.
6186    ///
6187    /// See [`Self::add_scope()`] for details.
6188    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserHistoryListCall<'a, C>
6189    where
6190        I: IntoIterator<Item = St>,
6191        St: AsRef<str>,
6192    {
6193        self._scopes
6194            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6195        self
6196    }
6197
6198    /// Removes all scopes, and no default scope will be used either.
6199    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6200    /// for details).
6201    pub fn clear_scopes(mut self) -> UserHistoryListCall<'a, C> {
6202        self._scopes.clear();
6203        self
6204    }
6205}
6206
6207/// Creates a new label.
6208///
6209/// A builder for the *labels.create* method supported by a *user* resource.
6210/// It is not used directly, but through a [`UserMethods`] instance.
6211///
6212/// # Example
6213///
6214/// Instantiate a resource method builder
6215///
6216/// ```test_harness,no_run
6217/// # extern crate hyper;
6218/// # extern crate hyper_rustls;
6219/// # extern crate google_gmail1 as gmail1;
6220/// use gmail1::api::Label;
6221/// # async fn dox() {
6222/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6223///
6224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6225/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6226/// #     .with_native_roots()
6227/// #     .unwrap()
6228/// #     .https_only()
6229/// #     .enable_http2()
6230/// #     .build();
6231///
6232/// # let executor = hyper_util::rt::TokioExecutor::new();
6233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6234/// #     secret,
6235/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6236/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6237/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6238/// #     ),
6239/// # ).build().await.unwrap();
6240///
6241/// # let client = hyper_util::client::legacy::Client::builder(
6242/// #     hyper_util::rt::TokioExecutor::new()
6243/// # )
6244/// # .build(
6245/// #     hyper_rustls::HttpsConnectorBuilder::new()
6246/// #         .with_native_roots()
6247/// #         .unwrap()
6248/// #         .https_or_http()
6249/// #         .enable_http2()
6250/// #         .build()
6251/// # );
6252/// # let mut hub = Gmail::new(client, auth);
6253/// // As the method needs a request, you would usually fill it with the desired information
6254/// // into the respective structure. Some of the parts shown here might not be applicable !
6255/// // Values shown here are possibly random and not representative !
6256/// let mut req = Label::default();
6257///
6258/// // You can configure optional parameters by calling the respective setters at will, and
6259/// // execute the final call using `doit()`.
6260/// // Values shown here are possibly random and not representative !
6261/// let result = hub.users().labels_create(req, "userId")
6262///              .doit().await;
6263/// # }
6264/// ```
6265pub struct UserLabelCreateCall<'a, C>
6266where
6267    C: 'a,
6268{
6269    hub: &'a Gmail<C>,
6270    _request: Label,
6271    _user_id: String,
6272    _delegate: Option<&'a mut dyn common::Delegate>,
6273    _additional_params: HashMap<String, String>,
6274    _scopes: BTreeSet<String>,
6275}
6276
6277impl<'a, C> common::CallBuilder for UserLabelCreateCall<'a, C> {}
6278
6279impl<'a, C> UserLabelCreateCall<'a, C>
6280where
6281    C: common::Connector,
6282{
6283    /// Perform the operation you have build so far.
6284    pub async fn doit(mut self) -> common::Result<(common::Response, Label)> {
6285        use std::borrow::Cow;
6286        use std::io::{Read, Seek};
6287
6288        use common::{url::Params, ToParts};
6289        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6290
6291        let mut dd = common::DefaultDelegate;
6292        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6293        dlg.begin(common::MethodInfo {
6294            id: "gmail.users.labels.create",
6295            http_method: hyper::Method::POST,
6296        });
6297
6298        for &field in ["alt", "userId"].iter() {
6299            if self._additional_params.contains_key(field) {
6300                dlg.finished(false);
6301                return Err(common::Error::FieldClash(field));
6302            }
6303        }
6304
6305        let mut params = Params::with_capacity(4 + self._additional_params.len());
6306        params.push("userId", self._user_id);
6307
6308        params.extend(self._additional_params.iter());
6309
6310        params.push("alt", "json");
6311        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels";
6312        if self._scopes.is_empty() {
6313            self._scopes.insert(Scope::Gmai.as_ref().to_string());
6314        }
6315
6316        #[allow(clippy::single_element_loop)]
6317        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
6318            url = params.uri_replacement(url, param_name, find_this, false);
6319        }
6320        {
6321            let to_remove = ["userId"];
6322            params.remove_params(&to_remove);
6323        }
6324
6325        let url = params.parse_with_url(&url);
6326
6327        let mut json_mime_type = mime::APPLICATION_JSON;
6328        let mut request_value_reader = {
6329            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6330            common::remove_json_null_values(&mut value);
6331            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6332            serde_json::to_writer(&mut dst, &value).unwrap();
6333            dst
6334        };
6335        let request_size = request_value_reader
6336            .seek(std::io::SeekFrom::End(0))
6337            .unwrap();
6338        request_value_reader
6339            .seek(std::io::SeekFrom::Start(0))
6340            .unwrap();
6341
6342        loop {
6343            let token = match self
6344                .hub
6345                .auth
6346                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6347                .await
6348            {
6349                Ok(token) => token,
6350                Err(e) => match dlg.token(e) {
6351                    Ok(token) => token,
6352                    Err(e) => {
6353                        dlg.finished(false);
6354                        return Err(common::Error::MissingToken(e));
6355                    }
6356                },
6357            };
6358            request_value_reader
6359                .seek(std::io::SeekFrom::Start(0))
6360                .unwrap();
6361            let mut req_result = {
6362                let client = &self.hub.client;
6363                dlg.pre_request();
6364                let mut req_builder = hyper::Request::builder()
6365                    .method(hyper::Method::POST)
6366                    .uri(url.as_str())
6367                    .header(USER_AGENT, self.hub._user_agent.clone());
6368
6369                if let Some(token) = token.as_ref() {
6370                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6371                }
6372
6373                let request = req_builder
6374                    .header(CONTENT_TYPE, json_mime_type.to_string())
6375                    .header(CONTENT_LENGTH, request_size as u64)
6376                    .body(common::to_body(
6377                        request_value_reader.get_ref().clone().into(),
6378                    ));
6379
6380                client.request(request.unwrap()).await
6381            };
6382
6383            match req_result {
6384                Err(err) => {
6385                    if let common::Retry::After(d) = dlg.http_error(&err) {
6386                        sleep(d).await;
6387                        continue;
6388                    }
6389                    dlg.finished(false);
6390                    return Err(common::Error::HttpError(err));
6391                }
6392                Ok(res) => {
6393                    let (mut parts, body) = res.into_parts();
6394                    let mut body = common::Body::new(body);
6395                    if !parts.status.is_success() {
6396                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6397                        let error = serde_json::from_str(&common::to_string(&bytes));
6398                        let response = common::to_response(parts, bytes.into());
6399
6400                        if let common::Retry::After(d) =
6401                            dlg.http_failure(&response, error.as_ref().ok())
6402                        {
6403                            sleep(d).await;
6404                            continue;
6405                        }
6406
6407                        dlg.finished(false);
6408
6409                        return Err(match error {
6410                            Ok(value) => common::Error::BadRequest(value),
6411                            _ => common::Error::Failure(response),
6412                        });
6413                    }
6414                    let response = {
6415                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6416                        let encoded = common::to_string(&bytes);
6417                        match serde_json::from_str(&encoded) {
6418                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6419                            Err(error) => {
6420                                dlg.response_json_decode_error(&encoded, &error);
6421                                return Err(common::Error::JsonDecodeError(
6422                                    encoded.to_string(),
6423                                    error,
6424                                ));
6425                            }
6426                        }
6427                    };
6428
6429                    dlg.finished(true);
6430                    return Ok(response);
6431                }
6432            }
6433        }
6434    }
6435
6436    ///
6437    /// Sets the *request* property to the given value.
6438    ///
6439    /// Even though the property as already been set when instantiating this call,
6440    /// we provide this method for API completeness.
6441    pub fn request(mut self, new_value: Label) -> UserLabelCreateCall<'a, C> {
6442        self._request = new_value;
6443        self
6444    }
6445    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
6446    ///
6447    /// Sets the *user id* path property to the given value.
6448    ///
6449    /// Even though the property as already been set when instantiating this call,
6450    /// we provide this method for API completeness.
6451    pub fn user_id(mut self, new_value: &str) -> UserLabelCreateCall<'a, C> {
6452        self._user_id = new_value.to_string();
6453        self
6454    }
6455    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6456    /// while executing the actual API request.
6457    ///
6458    /// ````text
6459    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6460    /// ````
6461    ///
6462    /// Sets the *delegate* property to the given value.
6463    pub fn delegate(
6464        mut self,
6465        new_value: &'a mut dyn common::Delegate,
6466    ) -> UserLabelCreateCall<'a, C> {
6467        self._delegate = Some(new_value);
6468        self
6469    }
6470
6471    /// Set any additional parameter of the query string used in the request.
6472    /// It should be used to set parameters which are not yet available through their own
6473    /// setters.
6474    ///
6475    /// Please note that this method must not be used to set any of the known parameters
6476    /// which have their own setter method. If done anyway, the request will fail.
6477    ///
6478    /// # Additional Parameters
6479    ///
6480    /// * *$.xgafv* (query-string) - V1 error format.
6481    /// * *access_token* (query-string) - OAuth access token.
6482    /// * *alt* (query-string) - Data format for response.
6483    /// * *callback* (query-string) - JSONP
6484    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6485    /// * *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.
6486    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6487    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6488    /// * *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.
6489    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6490    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6491    pub fn param<T>(mut self, name: T, value: T) -> UserLabelCreateCall<'a, C>
6492    where
6493        T: AsRef<str>,
6494    {
6495        self._additional_params
6496            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6497        self
6498    }
6499
6500    /// Identifies the authorization scope for the method you are building.
6501    ///
6502    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6503    /// [`Scope::Gmai`].
6504    ///
6505    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6506    /// tokens for more than one scope.
6507    ///
6508    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6509    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6510    /// sufficient, a read-write scope will do as well.
6511    pub fn add_scope<St>(mut self, scope: St) -> UserLabelCreateCall<'a, C>
6512    where
6513        St: AsRef<str>,
6514    {
6515        self._scopes.insert(String::from(scope.as_ref()));
6516        self
6517    }
6518    /// Identifies the authorization scope(s) for the method you are building.
6519    ///
6520    /// See [`Self::add_scope()`] for details.
6521    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelCreateCall<'a, C>
6522    where
6523        I: IntoIterator<Item = St>,
6524        St: AsRef<str>,
6525    {
6526        self._scopes
6527            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6528        self
6529    }
6530
6531    /// Removes all scopes, and no default scope will be used either.
6532    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6533    /// for details).
6534    pub fn clear_scopes(mut self) -> UserLabelCreateCall<'a, C> {
6535        self._scopes.clear();
6536        self
6537    }
6538}
6539
6540/// Immediately and permanently deletes the specified label and removes it from any messages and threads that it is applied to.
6541///
6542/// A builder for the *labels.delete* method supported by a *user* resource.
6543/// It is not used directly, but through a [`UserMethods`] instance.
6544///
6545/// # Example
6546///
6547/// Instantiate a resource method builder
6548///
6549/// ```test_harness,no_run
6550/// # extern crate hyper;
6551/// # extern crate hyper_rustls;
6552/// # extern crate google_gmail1 as gmail1;
6553/// # async fn dox() {
6554/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6555///
6556/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6557/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6558/// #     .with_native_roots()
6559/// #     .unwrap()
6560/// #     .https_only()
6561/// #     .enable_http2()
6562/// #     .build();
6563///
6564/// # let executor = hyper_util::rt::TokioExecutor::new();
6565/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6566/// #     secret,
6567/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6568/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6569/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6570/// #     ),
6571/// # ).build().await.unwrap();
6572///
6573/// # let client = hyper_util::client::legacy::Client::builder(
6574/// #     hyper_util::rt::TokioExecutor::new()
6575/// # )
6576/// # .build(
6577/// #     hyper_rustls::HttpsConnectorBuilder::new()
6578/// #         .with_native_roots()
6579/// #         .unwrap()
6580/// #         .https_or_http()
6581/// #         .enable_http2()
6582/// #         .build()
6583/// # );
6584/// # let mut hub = Gmail::new(client, auth);
6585/// // You can configure optional parameters by calling the respective setters at will, and
6586/// // execute the final call using `doit()`.
6587/// // Values shown here are possibly random and not representative !
6588/// let result = hub.users().labels_delete("userId", "id")
6589///              .doit().await;
6590/// # }
6591/// ```
6592pub struct UserLabelDeleteCall<'a, C>
6593where
6594    C: 'a,
6595{
6596    hub: &'a Gmail<C>,
6597    _user_id: String,
6598    _id: String,
6599    _delegate: Option<&'a mut dyn common::Delegate>,
6600    _additional_params: HashMap<String, String>,
6601    _scopes: BTreeSet<String>,
6602}
6603
6604impl<'a, C> common::CallBuilder for UserLabelDeleteCall<'a, C> {}
6605
6606impl<'a, C> UserLabelDeleteCall<'a, C>
6607where
6608    C: common::Connector,
6609{
6610    /// Perform the operation you have build so far.
6611    pub async fn doit(mut self) -> common::Result<common::Response> {
6612        use std::borrow::Cow;
6613        use std::io::{Read, Seek};
6614
6615        use common::{url::Params, ToParts};
6616        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6617
6618        let mut dd = common::DefaultDelegate;
6619        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6620        dlg.begin(common::MethodInfo {
6621            id: "gmail.users.labels.delete",
6622            http_method: hyper::Method::DELETE,
6623        });
6624
6625        for &field in ["userId", "id"].iter() {
6626            if self._additional_params.contains_key(field) {
6627                dlg.finished(false);
6628                return Err(common::Error::FieldClash(field));
6629            }
6630        }
6631
6632        let mut params = Params::with_capacity(3 + self._additional_params.len());
6633        params.push("userId", self._user_id);
6634        params.push("id", self._id);
6635
6636        params.extend(self._additional_params.iter());
6637
6638        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels/{id}";
6639        if self._scopes.is_empty() {
6640            self._scopes.insert(Scope::Gmai.as_ref().to_string());
6641        }
6642
6643        #[allow(clippy::single_element_loop)]
6644        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
6645            url = params.uri_replacement(url, param_name, find_this, false);
6646        }
6647        {
6648            let to_remove = ["id", "userId"];
6649            params.remove_params(&to_remove);
6650        }
6651
6652        let url = params.parse_with_url(&url);
6653
6654        loop {
6655            let token = match self
6656                .hub
6657                .auth
6658                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6659                .await
6660            {
6661                Ok(token) => token,
6662                Err(e) => match dlg.token(e) {
6663                    Ok(token) => token,
6664                    Err(e) => {
6665                        dlg.finished(false);
6666                        return Err(common::Error::MissingToken(e));
6667                    }
6668                },
6669            };
6670            let mut req_result = {
6671                let client = &self.hub.client;
6672                dlg.pre_request();
6673                let mut req_builder = hyper::Request::builder()
6674                    .method(hyper::Method::DELETE)
6675                    .uri(url.as_str())
6676                    .header(USER_AGENT, self.hub._user_agent.clone());
6677
6678                if let Some(token) = token.as_ref() {
6679                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6680                }
6681
6682                let request = req_builder
6683                    .header(CONTENT_LENGTH, 0_u64)
6684                    .body(common::to_body::<String>(None));
6685
6686                client.request(request.unwrap()).await
6687            };
6688
6689            match req_result {
6690                Err(err) => {
6691                    if let common::Retry::After(d) = dlg.http_error(&err) {
6692                        sleep(d).await;
6693                        continue;
6694                    }
6695                    dlg.finished(false);
6696                    return Err(common::Error::HttpError(err));
6697                }
6698                Ok(res) => {
6699                    let (mut parts, body) = res.into_parts();
6700                    let mut body = common::Body::new(body);
6701                    if !parts.status.is_success() {
6702                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6703                        let error = serde_json::from_str(&common::to_string(&bytes));
6704                        let response = common::to_response(parts, bytes.into());
6705
6706                        if let common::Retry::After(d) =
6707                            dlg.http_failure(&response, error.as_ref().ok())
6708                        {
6709                            sleep(d).await;
6710                            continue;
6711                        }
6712
6713                        dlg.finished(false);
6714
6715                        return Err(match error {
6716                            Ok(value) => common::Error::BadRequest(value),
6717                            _ => common::Error::Failure(response),
6718                        });
6719                    }
6720                    let response = common::Response::from_parts(parts, body);
6721
6722                    dlg.finished(true);
6723                    return Ok(response);
6724                }
6725            }
6726        }
6727    }
6728
6729    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
6730    ///
6731    /// Sets the *user id* path property to the given value.
6732    ///
6733    /// Even though the property as already been set when instantiating this call,
6734    /// we provide this method for API completeness.
6735    pub fn user_id(mut self, new_value: &str) -> UserLabelDeleteCall<'a, C> {
6736        self._user_id = new_value.to_string();
6737        self
6738    }
6739    /// The ID of the label to delete.
6740    ///
6741    /// Sets the *id* path property to the given value.
6742    ///
6743    /// Even though the property as already been set when instantiating this call,
6744    /// we provide this method for API completeness.
6745    pub fn id(mut self, new_value: &str) -> UserLabelDeleteCall<'a, C> {
6746        self._id = new_value.to_string();
6747        self
6748    }
6749    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6750    /// while executing the actual API request.
6751    ///
6752    /// ````text
6753    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6754    /// ````
6755    ///
6756    /// Sets the *delegate* property to the given value.
6757    pub fn delegate(
6758        mut self,
6759        new_value: &'a mut dyn common::Delegate,
6760    ) -> UserLabelDeleteCall<'a, C> {
6761        self._delegate = Some(new_value);
6762        self
6763    }
6764
6765    /// Set any additional parameter of the query string used in the request.
6766    /// It should be used to set parameters which are not yet available through their own
6767    /// setters.
6768    ///
6769    /// Please note that this method must not be used to set any of the known parameters
6770    /// which have their own setter method. If done anyway, the request will fail.
6771    ///
6772    /// # Additional Parameters
6773    ///
6774    /// * *$.xgafv* (query-string) - V1 error format.
6775    /// * *access_token* (query-string) - OAuth access token.
6776    /// * *alt* (query-string) - Data format for response.
6777    /// * *callback* (query-string) - JSONP
6778    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6779    /// * *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.
6780    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6781    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6782    /// * *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.
6783    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6784    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6785    pub fn param<T>(mut self, name: T, value: T) -> UserLabelDeleteCall<'a, C>
6786    where
6787        T: AsRef<str>,
6788    {
6789        self._additional_params
6790            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6791        self
6792    }
6793
6794    /// Identifies the authorization scope for the method you are building.
6795    ///
6796    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6797    /// [`Scope::Gmai`].
6798    ///
6799    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6800    /// tokens for more than one scope.
6801    ///
6802    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6803    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6804    /// sufficient, a read-write scope will do as well.
6805    pub fn add_scope<St>(mut self, scope: St) -> UserLabelDeleteCall<'a, C>
6806    where
6807        St: AsRef<str>,
6808    {
6809        self._scopes.insert(String::from(scope.as_ref()));
6810        self
6811    }
6812    /// Identifies the authorization scope(s) for the method you are building.
6813    ///
6814    /// See [`Self::add_scope()`] for details.
6815    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelDeleteCall<'a, C>
6816    where
6817        I: IntoIterator<Item = St>,
6818        St: AsRef<str>,
6819    {
6820        self._scopes
6821            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6822        self
6823    }
6824
6825    /// Removes all scopes, and no default scope will be used either.
6826    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6827    /// for details).
6828    pub fn clear_scopes(mut self) -> UserLabelDeleteCall<'a, C> {
6829        self._scopes.clear();
6830        self
6831    }
6832}
6833
6834/// Gets the specified label.
6835///
6836/// A builder for the *labels.get* method supported by a *user* resource.
6837/// It is not used directly, but through a [`UserMethods`] instance.
6838///
6839/// # Example
6840///
6841/// Instantiate a resource method builder
6842///
6843/// ```test_harness,no_run
6844/// # extern crate hyper;
6845/// # extern crate hyper_rustls;
6846/// # extern crate google_gmail1 as gmail1;
6847/// # async fn dox() {
6848/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6849///
6850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6851/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6852/// #     .with_native_roots()
6853/// #     .unwrap()
6854/// #     .https_only()
6855/// #     .enable_http2()
6856/// #     .build();
6857///
6858/// # let executor = hyper_util::rt::TokioExecutor::new();
6859/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6860/// #     secret,
6861/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6862/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6863/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6864/// #     ),
6865/// # ).build().await.unwrap();
6866///
6867/// # let client = hyper_util::client::legacy::Client::builder(
6868/// #     hyper_util::rt::TokioExecutor::new()
6869/// # )
6870/// # .build(
6871/// #     hyper_rustls::HttpsConnectorBuilder::new()
6872/// #         .with_native_roots()
6873/// #         .unwrap()
6874/// #         .https_or_http()
6875/// #         .enable_http2()
6876/// #         .build()
6877/// # );
6878/// # let mut hub = Gmail::new(client, auth);
6879/// // You can configure optional parameters by calling the respective setters at will, and
6880/// // execute the final call using `doit()`.
6881/// // Values shown here are possibly random and not representative !
6882/// let result = hub.users().labels_get("userId", "id")
6883///              .doit().await;
6884/// # }
6885/// ```
6886pub struct UserLabelGetCall<'a, C>
6887where
6888    C: 'a,
6889{
6890    hub: &'a Gmail<C>,
6891    _user_id: String,
6892    _id: String,
6893    _delegate: Option<&'a mut dyn common::Delegate>,
6894    _additional_params: HashMap<String, String>,
6895    _scopes: BTreeSet<String>,
6896}
6897
6898impl<'a, C> common::CallBuilder for UserLabelGetCall<'a, C> {}
6899
6900impl<'a, C> UserLabelGetCall<'a, C>
6901where
6902    C: common::Connector,
6903{
6904    /// Perform the operation you have build so far.
6905    pub async fn doit(mut self) -> common::Result<(common::Response, Label)> {
6906        use std::borrow::Cow;
6907        use std::io::{Read, Seek};
6908
6909        use common::{url::Params, ToParts};
6910        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6911
6912        let mut dd = common::DefaultDelegate;
6913        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6914        dlg.begin(common::MethodInfo {
6915            id: "gmail.users.labels.get",
6916            http_method: hyper::Method::GET,
6917        });
6918
6919        for &field in ["alt", "userId", "id"].iter() {
6920            if self._additional_params.contains_key(field) {
6921                dlg.finished(false);
6922                return Err(common::Error::FieldClash(field));
6923            }
6924        }
6925
6926        let mut params = Params::with_capacity(4 + self._additional_params.len());
6927        params.push("userId", self._user_id);
6928        params.push("id", self._id);
6929
6930        params.extend(self._additional_params.iter());
6931
6932        params.push("alt", "json");
6933        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels/{id}";
6934        if self._scopes.is_empty() {
6935            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6936        }
6937
6938        #[allow(clippy::single_element_loop)]
6939        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
6940            url = params.uri_replacement(url, param_name, find_this, false);
6941        }
6942        {
6943            let to_remove = ["id", "userId"];
6944            params.remove_params(&to_remove);
6945        }
6946
6947        let url = params.parse_with_url(&url);
6948
6949        loop {
6950            let token = match self
6951                .hub
6952                .auth
6953                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6954                .await
6955            {
6956                Ok(token) => token,
6957                Err(e) => match dlg.token(e) {
6958                    Ok(token) => token,
6959                    Err(e) => {
6960                        dlg.finished(false);
6961                        return Err(common::Error::MissingToken(e));
6962                    }
6963                },
6964            };
6965            let mut req_result = {
6966                let client = &self.hub.client;
6967                dlg.pre_request();
6968                let mut req_builder = hyper::Request::builder()
6969                    .method(hyper::Method::GET)
6970                    .uri(url.as_str())
6971                    .header(USER_AGENT, self.hub._user_agent.clone());
6972
6973                if let Some(token) = token.as_ref() {
6974                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6975                }
6976
6977                let request = req_builder
6978                    .header(CONTENT_LENGTH, 0_u64)
6979                    .body(common::to_body::<String>(None));
6980
6981                client.request(request.unwrap()).await
6982            };
6983
6984            match req_result {
6985                Err(err) => {
6986                    if let common::Retry::After(d) = dlg.http_error(&err) {
6987                        sleep(d).await;
6988                        continue;
6989                    }
6990                    dlg.finished(false);
6991                    return Err(common::Error::HttpError(err));
6992                }
6993                Ok(res) => {
6994                    let (mut parts, body) = res.into_parts();
6995                    let mut body = common::Body::new(body);
6996                    if !parts.status.is_success() {
6997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6998                        let error = serde_json::from_str(&common::to_string(&bytes));
6999                        let response = common::to_response(parts, bytes.into());
7000
7001                        if let common::Retry::After(d) =
7002                            dlg.http_failure(&response, error.as_ref().ok())
7003                        {
7004                            sleep(d).await;
7005                            continue;
7006                        }
7007
7008                        dlg.finished(false);
7009
7010                        return Err(match error {
7011                            Ok(value) => common::Error::BadRequest(value),
7012                            _ => common::Error::Failure(response),
7013                        });
7014                    }
7015                    let response = {
7016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7017                        let encoded = common::to_string(&bytes);
7018                        match serde_json::from_str(&encoded) {
7019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7020                            Err(error) => {
7021                                dlg.response_json_decode_error(&encoded, &error);
7022                                return Err(common::Error::JsonDecodeError(
7023                                    encoded.to_string(),
7024                                    error,
7025                                ));
7026                            }
7027                        }
7028                    };
7029
7030                    dlg.finished(true);
7031                    return Ok(response);
7032                }
7033            }
7034        }
7035    }
7036
7037    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
7038    ///
7039    /// Sets the *user id* path property to the given value.
7040    ///
7041    /// Even though the property as already been set when instantiating this call,
7042    /// we provide this method for API completeness.
7043    pub fn user_id(mut self, new_value: &str) -> UserLabelGetCall<'a, C> {
7044        self._user_id = new_value.to_string();
7045        self
7046    }
7047    /// The ID of the label to retrieve.
7048    ///
7049    /// Sets the *id* path property to the given value.
7050    ///
7051    /// Even though the property as already been set when instantiating this call,
7052    /// we provide this method for API completeness.
7053    pub fn id(mut self, new_value: &str) -> UserLabelGetCall<'a, C> {
7054        self._id = new_value.to_string();
7055        self
7056    }
7057    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7058    /// while executing the actual API request.
7059    ///
7060    /// ````text
7061    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7062    /// ````
7063    ///
7064    /// Sets the *delegate* property to the given value.
7065    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserLabelGetCall<'a, C> {
7066        self._delegate = Some(new_value);
7067        self
7068    }
7069
7070    /// Set any additional parameter of the query string used in the request.
7071    /// It should be used to set parameters which are not yet available through their own
7072    /// setters.
7073    ///
7074    /// Please note that this method must not be used to set any of the known parameters
7075    /// which have their own setter method. If done anyway, the request will fail.
7076    ///
7077    /// # Additional Parameters
7078    ///
7079    /// * *$.xgafv* (query-string) - V1 error format.
7080    /// * *access_token* (query-string) - OAuth access token.
7081    /// * *alt* (query-string) - Data format for response.
7082    /// * *callback* (query-string) - JSONP
7083    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7084    /// * *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.
7085    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7086    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7087    /// * *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.
7088    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7089    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7090    pub fn param<T>(mut self, name: T, value: T) -> UserLabelGetCall<'a, C>
7091    where
7092        T: AsRef<str>,
7093    {
7094        self._additional_params
7095            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7096        self
7097    }
7098
7099    /// Identifies the authorization scope for the method you are building.
7100    ///
7101    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7102    /// [`Scope::Readonly`].
7103    ///
7104    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7105    /// tokens for more than one scope.
7106    ///
7107    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7108    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7109    /// sufficient, a read-write scope will do as well.
7110    pub fn add_scope<St>(mut self, scope: St) -> UserLabelGetCall<'a, C>
7111    where
7112        St: AsRef<str>,
7113    {
7114        self._scopes.insert(String::from(scope.as_ref()));
7115        self
7116    }
7117    /// Identifies the authorization scope(s) for the method you are building.
7118    ///
7119    /// See [`Self::add_scope()`] for details.
7120    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelGetCall<'a, C>
7121    where
7122        I: IntoIterator<Item = St>,
7123        St: AsRef<str>,
7124    {
7125        self._scopes
7126            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7127        self
7128    }
7129
7130    /// Removes all scopes, and no default scope will be used either.
7131    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7132    /// for details).
7133    pub fn clear_scopes(mut self) -> UserLabelGetCall<'a, C> {
7134        self._scopes.clear();
7135        self
7136    }
7137}
7138
7139/// Lists all labels in the user's mailbox.
7140///
7141/// A builder for the *labels.list* method supported by a *user* resource.
7142/// It is not used directly, but through a [`UserMethods`] instance.
7143///
7144/// # Example
7145///
7146/// Instantiate a resource method builder
7147///
7148/// ```test_harness,no_run
7149/// # extern crate hyper;
7150/// # extern crate hyper_rustls;
7151/// # extern crate google_gmail1 as gmail1;
7152/// # async fn dox() {
7153/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7154///
7155/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7156/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7157/// #     .with_native_roots()
7158/// #     .unwrap()
7159/// #     .https_only()
7160/// #     .enable_http2()
7161/// #     .build();
7162///
7163/// # let executor = hyper_util::rt::TokioExecutor::new();
7164/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7165/// #     secret,
7166/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7167/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7168/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7169/// #     ),
7170/// # ).build().await.unwrap();
7171///
7172/// # let client = hyper_util::client::legacy::Client::builder(
7173/// #     hyper_util::rt::TokioExecutor::new()
7174/// # )
7175/// # .build(
7176/// #     hyper_rustls::HttpsConnectorBuilder::new()
7177/// #         .with_native_roots()
7178/// #         .unwrap()
7179/// #         .https_or_http()
7180/// #         .enable_http2()
7181/// #         .build()
7182/// # );
7183/// # let mut hub = Gmail::new(client, auth);
7184/// // You can configure optional parameters by calling the respective setters at will, and
7185/// // execute the final call using `doit()`.
7186/// // Values shown here are possibly random and not representative !
7187/// let result = hub.users().labels_list("userId")
7188///              .doit().await;
7189/// # }
7190/// ```
7191pub struct UserLabelListCall<'a, C>
7192where
7193    C: 'a,
7194{
7195    hub: &'a Gmail<C>,
7196    _user_id: String,
7197    _delegate: Option<&'a mut dyn common::Delegate>,
7198    _additional_params: HashMap<String, String>,
7199    _scopes: BTreeSet<String>,
7200}
7201
7202impl<'a, C> common::CallBuilder for UserLabelListCall<'a, C> {}
7203
7204impl<'a, C> UserLabelListCall<'a, C>
7205where
7206    C: common::Connector,
7207{
7208    /// Perform the operation you have build so far.
7209    pub async fn doit(mut self) -> common::Result<(common::Response, ListLabelsResponse)> {
7210        use std::borrow::Cow;
7211        use std::io::{Read, Seek};
7212
7213        use common::{url::Params, ToParts};
7214        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7215
7216        let mut dd = common::DefaultDelegate;
7217        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7218        dlg.begin(common::MethodInfo {
7219            id: "gmail.users.labels.list",
7220            http_method: hyper::Method::GET,
7221        });
7222
7223        for &field in ["alt", "userId"].iter() {
7224            if self._additional_params.contains_key(field) {
7225                dlg.finished(false);
7226                return Err(common::Error::FieldClash(field));
7227            }
7228        }
7229
7230        let mut params = Params::with_capacity(3 + self._additional_params.len());
7231        params.push("userId", self._user_id);
7232
7233        params.extend(self._additional_params.iter());
7234
7235        params.push("alt", "json");
7236        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels";
7237        if self._scopes.is_empty() {
7238            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7239        }
7240
7241        #[allow(clippy::single_element_loop)]
7242        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
7243            url = params.uri_replacement(url, param_name, find_this, false);
7244        }
7245        {
7246            let to_remove = ["userId"];
7247            params.remove_params(&to_remove);
7248        }
7249
7250        let url = params.parse_with_url(&url);
7251
7252        loop {
7253            let token = match self
7254                .hub
7255                .auth
7256                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7257                .await
7258            {
7259                Ok(token) => token,
7260                Err(e) => match dlg.token(e) {
7261                    Ok(token) => token,
7262                    Err(e) => {
7263                        dlg.finished(false);
7264                        return Err(common::Error::MissingToken(e));
7265                    }
7266                },
7267            };
7268            let mut req_result = {
7269                let client = &self.hub.client;
7270                dlg.pre_request();
7271                let mut req_builder = hyper::Request::builder()
7272                    .method(hyper::Method::GET)
7273                    .uri(url.as_str())
7274                    .header(USER_AGENT, self.hub._user_agent.clone());
7275
7276                if let Some(token) = token.as_ref() {
7277                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7278                }
7279
7280                let request = req_builder
7281                    .header(CONTENT_LENGTH, 0_u64)
7282                    .body(common::to_body::<String>(None));
7283
7284                client.request(request.unwrap()).await
7285            };
7286
7287            match req_result {
7288                Err(err) => {
7289                    if let common::Retry::After(d) = dlg.http_error(&err) {
7290                        sleep(d).await;
7291                        continue;
7292                    }
7293                    dlg.finished(false);
7294                    return Err(common::Error::HttpError(err));
7295                }
7296                Ok(res) => {
7297                    let (mut parts, body) = res.into_parts();
7298                    let mut body = common::Body::new(body);
7299                    if !parts.status.is_success() {
7300                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7301                        let error = serde_json::from_str(&common::to_string(&bytes));
7302                        let response = common::to_response(parts, bytes.into());
7303
7304                        if let common::Retry::After(d) =
7305                            dlg.http_failure(&response, error.as_ref().ok())
7306                        {
7307                            sleep(d).await;
7308                            continue;
7309                        }
7310
7311                        dlg.finished(false);
7312
7313                        return Err(match error {
7314                            Ok(value) => common::Error::BadRequest(value),
7315                            _ => common::Error::Failure(response),
7316                        });
7317                    }
7318                    let response = {
7319                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7320                        let encoded = common::to_string(&bytes);
7321                        match serde_json::from_str(&encoded) {
7322                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7323                            Err(error) => {
7324                                dlg.response_json_decode_error(&encoded, &error);
7325                                return Err(common::Error::JsonDecodeError(
7326                                    encoded.to_string(),
7327                                    error,
7328                                ));
7329                            }
7330                        }
7331                    };
7332
7333                    dlg.finished(true);
7334                    return Ok(response);
7335                }
7336            }
7337        }
7338    }
7339
7340    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
7341    ///
7342    /// Sets the *user id* path property to the given value.
7343    ///
7344    /// Even though the property as already been set when instantiating this call,
7345    /// we provide this method for API completeness.
7346    pub fn user_id(mut self, new_value: &str) -> UserLabelListCall<'a, C> {
7347        self._user_id = new_value.to_string();
7348        self
7349    }
7350    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7351    /// while executing the actual API request.
7352    ///
7353    /// ````text
7354    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7355    /// ````
7356    ///
7357    /// Sets the *delegate* property to the given value.
7358    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserLabelListCall<'a, C> {
7359        self._delegate = Some(new_value);
7360        self
7361    }
7362
7363    /// Set any additional parameter of the query string used in the request.
7364    /// It should be used to set parameters which are not yet available through their own
7365    /// setters.
7366    ///
7367    /// Please note that this method must not be used to set any of the known parameters
7368    /// which have their own setter method. If done anyway, the request will fail.
7369    ///
7370    /// # Additional Parameters
7371    ///
7372    /// * *$.xgafv* (query-string) - V1 error format.
7373    /// * *access_token* (query-string) - OAuth access token.
7374    /// * *alt* (query-string) - Data format for response.
7375    /// * *callback* (query-string) - JSONP
7376    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7377    /// * *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.
7378    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7379    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7380    /// * *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.
7381    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7382    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7383    pub fn param<T>(mut self, name: T, value: T) -> UserLabelListCall<'a, C>
7384    where
7385        T: AsRef<str>,
7386    {
7387        self._additional_params
7388            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7389        self
7390    }
7391
7392    /// Identifies the authorization scope for the method you are building.
7393    ///
7394    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7395    /// [`Scope::Readonly`].
7396    ///
7397    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7398    /// tokens for more than one scope.
7399    ///
7400    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7401    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7402    /// sufficient, a read-write scope will do as well.
7403    pub fn add_scope<St>(mut self, scope: St) -> UserLabelListCall<'a, C>
7404    where
7405        St: AsRef<str>,
7406    {
7407        self._scopes.insert(String::from(scope.as_ref()));
7408        self
7409    }
7410    /// Identifies the authorization scope(s) for the method you are building.
7411    ///
7412    /// See [`Self::add_scope()`] for details.
7413    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelListCall<'a, C>
7414    where
7415        I: IntoIterator<Item = St>,
7416        St: AsRef<str>,
7417    {
7418        self._scopes
7419            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7420        self
7421    }
7422
7423    /// Removes all scopes, and no default scope will be used either.
7424    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7425    /// for details).
7426    pub fn clear_scopes(mut self) -> UserLabelListCall<'a, C> {
7427        self._scopes.clear();
7428        self
7429    }
7430}
7431
7432/// Patch the specified label.
7433///
7434/// A builder for the *labels.patch* method supported by a *user* resource.
7435/// It is not used directly, but through a [`UserMethods`] instance.
7436///
7437/// # Example
7438///
7439/// Instantiate a resource method builder
7440///
7441/// ```test_harness,no_run
7442/// # extern crate hyper;
7443/// # extern crate hyper_rustls;
7444/// # extern crate google_gmail1 as gmail1;
7445/// use gmail1::api::Label;
7446/// # async fn dox() {
7447/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7448///
7449/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7450/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7451/// #     .with_native_roots()
7452/// #     .unwrap()
7453/// #     .https_only()
7454/// #     .enable_http2()
7455/// #     .build();
7456///
7457/// # let executor = hyper_util::rt::TokioExecutor::new();
7458/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7459/// #     secret,
7460/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7461/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7462/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7463/// #     ),
7464/// # ).build().await.unwrap();
7465///
7466/// # let client = hyper_util::client::legacy::Client::builder(
7467/// #     hyper_util::rt::TokioExecutor::new()
7468/// # )
7469/// # .build(
7470/// #     hyper_rustls::HttpsConnectorBuilder::new()
7471/// #         .with_native_roots()
7472/// #         .unwrap()
7473/// #         .https_or_http()
7474/// #         .enable_http2()
7475/// #         .build()
7476/// # );
7477/// # let mut hub = Gmail::new(client, auth);
7478/// // As the method needs a request, you would usually fill it with the desired information
7479/// // into the respective structure. Some of the parts shown here might not be applicable !
7480/// // Values shown here are possibly random and not representative !
7481/// let mut req = Label::default();
7482///
7483/// // You can configure optional parameters by calling the respective setters at will, and
7484/// // execute the final call using `doit()`.
7485/// // Values shown here are possibly random and not representative !
7486/// let result = hub.users().labels_patch(req, "userId", "id")
7487///              .doit().await;
7488/// # }
7489/// ```
7490pub struct UserLabelPatchCall<'a, C>
7491where
7492    C: 'a,
7493{
7494    hub: &'a Gmail<C>,
7495    _request: Label,
7496    _user_id: String,
7497    _id: String,
7498    _delegate: Option<&'a mut dyn common::Delegate>,
7499    _additional_params: HashMap<String, String>,
7500    _scopes: BTreeSet<String>,
7501}
7502
7503impl<'a, C> common::CallBuilder for UserLabelPatchCall<'a, C> {}
7504
7505impl<'a, C> UserLabelPatchCall<'a, C>
7506where
7507    C: common::Connector,
7508{
7509    /// Perform the operation you have build so far.
7510    pub async fn doit(mut self) -> common::Result<(common::Response, Label)> {
7511        use std::borrow::Cow;
7512        use std::io::{Read, Seek};
7513
7514        use common::{url::Params, ToParts};
7515        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7516
7517        let mut dd = common::DefaultDelegate;
7518        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7519        dlg.begin(common::MethodInfo {
7520            id: "gmail.users.labels.patch",
7521            http_method: hyper::Method::PATCH,
7522        });
7523
7524        for &field in ["alt", "userId", "id"].iter() {
7525            if self._additional_params.contains_key(field) {
7526                dlg.finished(false);
7527                return Err(common::Error::FieldClash(field));
7528            }
7529        }
7530
7531        let mut params = Params::with_capacity(5 + self._additional_params.len());
7532        params.push("userId", self._user_id);
7533        params.push("id", self._id);
7534
7535        params.extend(self._additional_params.iter());
7536
7537        params.push("alt", "json");
7538        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels/{id}";
7539        if self._scopes.is_empty() {
7540            self._scopes.insert(Scope::Gmai.as_ref().to_string());
7541        }
7542
7543        #[allow(clippy::single_element_loop)]
7544        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
7545            url = params.uri_replacement(url, param_name, find_this, false);
7546        }
7547        {
7548            let to_remove = ["id", "userId"];
7549            params.remove_params(&to_remove);
7550        }
7551
7552        let url = params.parse_with_url(&url);
7553
7554        let mut json_mime_type = mime::APPLICATION_JSON;
7555        let mut request_value_reader = {
7556            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7557            common::remove_json_null_values(&mut value);
7558            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7559            serde_json::to_writer(&mut dst, &value).unwrap();
7560            dst
7561        };
7562        let request_size = request_value_reader
7563            .seek(std::io::SeekFrom::End(0))
7564            .unwrap();
7565        request_value_reader
7566            .seek(std::io::SeekFrom::Start(0))
7567            .unwrap();
7568
7569        loop {
7570            let token = match self
7571                .hub
7572                .auth
7573                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7574                .await
7575            {
7576                Ok(token) => token,
7577                Err(e) => match dlg.token(e) {
7578                    Ok(token) => token,
7579                    Err(e) => {
7580                        dlg.finished(false);
7581                        return Err(common::Error::MissingToken(e));
7582                    }
7583                },
7584            };
7585            request_value_reader
7586                .seek(std::io::SeekFrom::Start(0))
7587                .unwrap();
7588            let mut req_result = {
7589                let client = &self.hub.client;
7590                dlg.pre_request();
7591                let mut req_builder = hyper::Request::builder()
7592                    .method(hyper::Method::PATCH)
7593                    .uri(url.as_str())
7594                    .header(USER_AGENT, self.hub._user_agent.clone());
7595
7596                if let Some(token) = token.as_ref() {
7597                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7598                }
7599
7600                let request = req_builder
7601                    .header(CONTENT_TYPE, json_mime_type.to_string())
7602                    .header(CONTENT_LENGTH, request_size as u64)
7603                    .body(common::to_body(
7604                        request_value_reader.get_ref().clone().into(),
7605                    ));
7606
7607                client.request(request.unwrap()).await
7608            };
7609
7610            match req_result {
7611                Err(err) => {
7612                    if let common::Retry::After(d) = dlg.http_error(&err) {
7613                        sleep(d).await;
7614                        continue;
7615                    }
7616                    dlg.finished(false);
7617                    return Err(common::Error::HttpError(err));
7618                }
7619                Ok(res) => {
7620                    let (mut parts, body) = res.into_parts();
7621                    let mut body = common::Body::new(body);
7622                    if !parts.status.is_success() {
7623                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7624                        let error = serde_json::from_str(&common::to_string(&bytes));
7625                        let response = common::to_response(parts, bytes.into());
7626
7627                        if let common::Retry::After(d) =
7628                            dlg.http_failure(&response, error.as_ref().ok())
7629                        {
7630                            sleep(d).await;
7631                            continue;
7632                        }
7633
7634                        dlg.finished(false);
7635
7636                        return Err(match error {
7637                            Ok(value) => common::Error::BadRequest(value),
7638                            _ => common::Error::Failure(response),
7639                        });
7640                    }
7641                    let response = {
7642                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7643                        let encoded = common::to_string(&bytes);
7644                        match serde_json::from_str(&encoded) {
7645                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7646                            Err(error) => {
7647                                dlg.response_json_decode_error(&encoded, &error);
7648                                return Err(common::Error::JsonDecodeError(
7649                                    encoded.to_string(),
7650                                    error,
7651                                ));
7652                            }
7653                        }
7654                    };
7655
7656                    dlg.finished(true);
7657                    return Ok(response);
7658                }
7659            }
7660        }
7661    }
7662
7663    ///
7664    /// Sets the *request* property to the given value.
7665    ///
7666    /// Even though the property as already been set when instantiating this call,
7667    /// we provide this method for API completeness.
7668    pub fn request(mut self, new_value: Label) -> UserLabelPatchCall<'a, C> {
7669        self._request = new_value;
7670        self
7671    }
7672    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
7673    ///
7674    /// Sets the *user id* path property to the given value.
7675    ///
7676    /// Even though the property as already been set when instantiating this call,
7677    /// we provide this method for API completeness.
7678    pub fn user_id(mut self, new_value: &str) -> UserLabelPatchCall<'a, C> {
7679        self._user_id = new_value.to_string();
7680        self
7681    }
7682    /// The ID of the label to update.
7683    ///
7684    /// Sets the *id* path property to the given value.
7685    ///
7686    /// Even though the property as already been set when instantiating this call,
7687    /// we provide this method for API completeness.
7688    pub fn id(mut self, new_value: &str) -> UserLabelPatchCall<'a, C> {
7689        self._id = new_value.to_string();
7690        self
7691    }
7692    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7693    /// while executing the actual API request.
7694    ///
7695    /// ````text
7696    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7697    /// ````
7698    ///
7699    /// Sets the *delegate* property to the given value.
7700    pub fn delegate(
7701        mut self,
7702        new_value: &'a mut dyn common::Delegate,
7703    ) -> UserLabelPatchCall<'a, C> {
7704        self._delegate = Some(new_value);
7705        self
7706    }
7707
7708    /// Set any additional parameter of the query string used in the request.
7709    /// It should be used to set parameters which are not yet available through their own
7710    /// setters.
7711    ///
7712    /// Please note that this method must not be used to set any of the known parameters
7713    /// which have their own setter method. If done anyway, the request will fail.
7714    ///
7715    /// # Additional Parameters
7716    ///
7717    /// * *$.xgafv* (query-string) - V1 error format.
7718    /// * *access_token* (query-string) - OAuth access token.
7719    /// * *alt* (query-string) - Data format for response.
7720    /// * *callback* (query-string) - JSONP
7721    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7722    /// * *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.
7723    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7724    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7725    /// * *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.
7726    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7727    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7728    pub fn param<T>(mut self, name: T, value: T) -> UserLabelPatchCall<'a, C>
7729    where
7730        T: AsRef<str>,
7731    {
7732        self._additional_params
7733            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7734        self
7735    }
7736
7737    /// Identifies the authorization scope for the method you are building.
7738    ///
7739    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7740    /// [`Scope::Gmai`].
7741    ///
7742    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7743    /// tokens for more than one scope.
7744    ///
7745    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7746    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7747    /// sufficient, a read-write scope will do as well.
7748    pub fn add_scope<St>(mut self, scope: St) -> UserLabelPatchCall<'a, C>
7749    where
7750        St: AsRef<str>,
7751    {
7752        self._scopes.insert(String::from(scope.as_ref()));
7753        self
7754    }
7755    /// Identifies the authorization scope(s) for the method you are building.
7756    ///
7757    /// See [`Self::add_scope()`] for details.
7758    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelPatchCall<'a, C>
7759    where
7760        I: IntoIterator<Item = St>,
7761        St: AsRef<str>,
7762    {
7763        self._scopes
7764            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7765        self
7766    }
7767
7768    /// Removes all scopes, and no default scope will be used either.
7769    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7770    /// for details).
7771    pub fn clear_scopes(mut self) -> UserLabelPatchCall<'a, C> {
7772        self._scopes.clear();
7773        self
7774    }
7775}
7776
7777/// Updates the specified label.
7778///
7779/// A builder for the *labels.update* method supported by a *user* resource.
7780/// It is not used directly, but through a [`UserMethods`] instance.
7781///
7782/// # Example
7783///
7784/// Instantiate a resource method builder
7785///
7786/// ```test_harness,no_run
7787/// # extern crate hyper;
7788/// # extern crate hyper_rustls;
7789/// # extern crate google_gmail1 as gmail1;
7790/// use gmail1::api::Label;
7791/// # async fn dox() {
7792/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7793///
7794/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7795/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7796/// #     .with_native_roots()
7797/// #     .unwrap()
7798/// #     .https_only()
7799/// #     .enable_http2()
7800/// #     .build();
7801///
7802/// # let executor = hyper_util::rt::TokioExecutor::new();
7803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7804/// #     secret,
7805/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7806/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7807/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7808/// #     ),
7809/// # ).build().await.unwrap();
7810///
7811/// # let client = hyper_util::client::legacy::Client::builder(
7812/// #     hyper_util::rt::TokioExecutor::new()
7813/// # )
7814/// # .build(
7815/// #     hyper_rustls::HttpsConnectorBuilder::new()
7816/// #         .with_native_roots()
7817/// #         .unwrap()
7818/// #         .https_or_http()
7819/// #         .enable_http2()
7820/// #         .build()
7821/// # );
7822/// # let mut hub = Gmail::new(client, auth);
7823/// // As the method needs a request, you would usually fill it with the desired information
7824/// // into the respective structure. Some of the parts shown here might not be applicable !
7825/// // Values shown here are possibly random and not representative !
7826/// let mut req = Label::default();
7827///
7828/// // You can configure optional parameters by calling the respective setters at will, and
7829/// // execute the final call using `doit()`.
7830/// // Values shown here are possibly random and not representative !
7831/// let result = hub.users().labels_update(req, "userId", "id")
7832///              .doit().await;
7833/// # }
7834/// ```
7835pub struct UserLabelUpdateCall<'a, C>
7836where
7837    C: 'a,
7838{
7839    hub: &'a Gmail<C>,
7840    _request: Label,
7841    _user_id: String,
7842    _id: String,
7843    _delegate: Option<&'a mut dyn common::Delegate>,
7844    _additional_params: HashMap<String, String>,
7845    _scopes: BTreeSet<String>,
7846}
7847
7848impl<'a, C> common::CallBuilder for UserLabelUpdateCall<'a, C> {}
7849
7850impl<'a, C> UserLabelUpdateCall<'a, C>
7851where
7852    C: common::Connector,
7853{
7854    /// Perform the operation you have build so far.
7855    pub async fn doit(mut self) -> common::Result<(common::Response, Label)> {
7856        use std::borrow::Cow;
7857        use std::io::{Read, Seek};
7858
7859        use common::{url::Params, ToParts};
7860        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7861
7862        let mut dd = common::DefaultDelegate;
7863        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7864        dlg.begin(common::MethodInfo {
7865            id: "gmail.users.labels.update",
7866            http_method: hyper::Method::PUT,
7867        });
7868
7869        for &field in ["alt", "userId", "id"].iter() {
7870            if self._additional_params.contains_key(field) {
7871                dlg.finished(false);
7872                return Err(common::Error::FieldClash(field));
7873            }
7874        }
7875
7876        let mut params = Params::with_capacity(5 + self._additional_params.len());
7877        params.push("userId", self._user_id);
7878        params.push("id", self._id);
7879
7880        params.extend(self._additional_params.iter());
7881
7882        params.push("alt", "json");
7883        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/labels/{id}";
7884        if self._scopes.is_empty() {
7885            self._scopes.insert(Scope::Gmai.as_ref().to_string());
7886        }
7887
7888        #[allow(clippy::single_element_loop)]
7889        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
7890            url = params.uri_replacement(url, param_name, find_this, false);
7891        }
7892        {
7893            let to_remove = ["id", "userId"];
7894            params.remove_params(&to_remove);
7895        }
7896
7897        let url = params.parse_with_url(&url);
7898
7899        let mut json_mime_type = mime::APPLICATION_JSON;
7900        let mut request_value_reader = {
7901            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7902            common::remove_json_null_values(&mut value);
7903            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7904            serde_json::to_writer(&mut dst, &value).unwrap();
7905            dst
7906        };
7907        let request_size = request_value_reader
7908            .seek(std::io::SeekFrom::End(0))
7909            .unwrap();
7910        request_value_reader
7911            .seek(std::io::SeekFrom::Start(0))
7912            .unwrap();
7913
7914        loop {
7915            let token = match self
7916                .hub
7917                .auth
7918                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7919                .await
7920            {
7921                Ok(token) => token,
7922                Err(e) => match dlg.token(e) {
7923                    Ok(token) => token,
7924                    Err(e) => {
7925                        dlg.finished(false);
7926                        return Err(common::Error::MissingToken(e));
7927                    }
7928                },
7929            };
7930            request_value_reader
7931                .seek(std::io::SeekFrom::Start(0))
7932                .unwrap();
7933            let mut req_result = {
7934                let client = &self.hub.client;
7935                dlg.pre_request();
7936                let mut req_builder = hyper::Request::builder()
7937                    .method(hyper::Method::PUT)
7938                    .uri(url.as_str())
7939                    .header(USER_AGENT, self.hub._user_agent.clone());
7940
7941                if let Some(token) = token.as_ref() {
7942                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7943                }
7944
7945                let request = req_builder
7946                    .header(CONTENT_TYPE, json_mime_type.to_string())
7947                    .header(CONTENT_LENGTH, request_size as u64)
7948                    .body(common::to_body(
7949                        request_value_reader.get_ref().clone().into(),
7950                    ));
7951
7952                client.request(request.unwrap()).await
7953            };
7954
7955            match req_result {
7956                Err(err) => {
7957                    if let common::Retry::After(d) = dlg.http_error(&err) {
7958                        sleep(d).await;
7959                        continue;
7960                    }
7961                    dlg.finished(false);
7962                    return Err(common::Error::HttpError(err));
7963                }
7964                Ok(res) => {
7965                    let (mut parts, body) = res.into_parts();
7966                    let mut body = common::Body::new(body);
7967                    if !parts.status.is_success() {
7968                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7969                        let error = serde_json::from_str(&common::to_string(&bytes));
7970                        let response = common::to_response(parts, bytes.into());
7971
7972                        if let common::Retry::After(d) =
7973                            dlg.http_failure(&response, error.as_ref().ok())
7974                        {
7975                            sleep(d).await;
7976                            continue;
7977                        }
7978
7979                        dlg.finished(false);
7980
7981                        return Err(match error {
7982                            Ok(value) => common::Error::BadRequest(value),
7983                            _ => common::Error::Failure(response),
7984                        });
7985                    }
7986                    let response = {
7987                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7988                        let encoded = common::to_string(&bytes);
7989                        match serde_json::from_str(&encoded) {
7990                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7991                            Err(error) => {
7992                                dlg.response_json_decode_error(&encoded, &error);
7993                                return Err(common::Error::JsonDecodeError(
7994                                    encoded.to_string(),
7995                                    error,
7996                                ));
7997                            }
7998                        }
7999                    };
8000
8001                    dlg.finished(true);
8002                    return Ok(response);
8003                }
8004            }
8005        }
8006    }
8007
8008    ///
8009    /// Sets the *request* property to the given value.
8010    ///
8011    /// Even though the property as already been set when instantiating this call,
8012    /// we provide this method for API completeness.
8013    pub fn request(mut self, new_value: Label) -> UserLabelUpdateCall<'a, C> {
8014        self._request = new_value;
8015        self
8016    }
8017    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
8018    ///
8019    /// Sets the *user id* path property to the given value.
8020    ///
8021    /// Even though the property as already been set when instantiating this call,
8022    /// we provide this method for API completeness.
8023    pub fn user_id(mut self, new_value: &str) -> UserLabelUpdateCall<'a, C> {
8024        self._user_id = new_value.to_string();
8025        self
8026    }
8027    /// The ID of the label to update.
8028    ///
8029    /// Sets the *id* path property to the given value.
8030    ///
8031    /// Even though the property as already been set when instantiating this call,
8032    /// we provide this method for API completeness.
8033    pub fn id(mut self, new_value: &str) -> UserLabelUpdateCall<'a, C> {
8034        self._id = new_value.to_string();
8035        self
8036    }
8037    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8038    /// while executing the actual API request.
8039    ///
8040    /// ````text
8041    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8042    /// ````
8043    ///
8044    /// Sets the *delegate* property to the given value.
8045    pub fn delegate(
8046        mut self,
8047        new_value: &'a mut dyn common::Delegate,
8048    ) -> UserLabelUpdateCall<'a, C> {
8049        self._delegate = Some(new_value);
8050        self
8051    }
8052
8053    /// Set any additional parameter of the query string used in the request.
8054    /// It should be used to set parameters which are not yet available through their own
8055    /// setters.
8056    ///
8057    /// Please note that this method must not be used to set any of the known parameters
8058    /// which have their own setter method. If done anyway, the request will fail.
8059    ///
8060    /// # Additional Parameters
8061    ///
8062    /// * *$.xgafv* (query-string) - V1 error format.
8063    /// * *access_token* (query-string) - OAuth access token.
8064    /// * *alt* (query-string) - Data format for response.
8065    /// * *callback* (query-string) - JSONP
8066    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8067    /// * *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.
8068    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8069    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8070    /// * *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.
8071    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8072    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8073    pub fn param<T>(mut self, name: T, value: T) -> UserLabelUpdateCall<'a, C>
8074    where
8075        T: AsRef<str>,
8076    {
8077        self._additional_params
8078            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8079        self
8080    }
8081
8082    /// Identifies the authorization scope for the method you are building.
8083    ///
8084    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8085    /// [`Scope::Gmai`].
8086    ///
8087    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8088    /// tokens for more than one scope.
8089    ///
8090    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8091    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8092    /// sufficient, a read-write scope will do as well.
8093    pub fn add_scope<St>(mut self, scope: St) -> UserLabelUpdateCall<'a, C>
8094    where
8095        St: AsRef<str>,
8096    {
8097        self._scopes.insert(String::from(scope.as_ref()));
8098        self
8099    }
8100    /// Identifies the authorization scope(s) for the method you are building.
8101    ///
8102    /// See [`Self::add_scope()`] for details.
8103    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserLabelUpdateCall<'a, C>
8104    where
8105        I: IntoIterator<Item = St>,
8106        St: AsRef<str>,
8107    {
8108        self._scopes
8109            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8110        self
8111    }
8112
8113    /// Removes all scopes, and no default scope will be used either.
8114    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8115    /// for details).
8116    pub fn clear_scopes(mut self) -> UserLabelUpdateCall<'a, C> {
8117        self._scopes.clear();
8118        self
8119    }
8120}
8121
8122/// Gets the specified message attachment.
8123///
8124/// A builder for the *messages.attachments.get* method supported by a *user* resource.
8125/// It is not used directly, but through a [`UserMethods`] instance.
8126///
8127/// # Example
8128///
8129/// Instantiate a resource method builder
8130///
8131/// ```test_harness,no_run
8132/// # extern crate hyper;
8133/// # extern crate hyper_rustls;
8134/// # extern crate google_gmail1 as gmail1;
8135/// # async fn dox() {
8136/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8137///
8138/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8139/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8140/// #     .with_native_roots()
8141/// #     .unwrap()
8142/// #     .https_only()
8143/// #     .enable_http2()
8144/// #     .build();
8145///
8146/// # let executor = hyper_util::rt::TokioExecutor::new();
8147/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8148/// #     secret,
8149/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8150/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8151/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8152/// #     ),
8153/// # ).build().await.unwrap();
8154///
8155/// # let client = hyper_util::client::legacy::Client::builder(
8156/// #     hyper_util::rt::TokioExecutor::new()
8157/// # )
8158/// # .build(
8159/// #     hyper_rustls::HttpsConnectorBuilder::new()
8160/// #         .with_native_roots()
8161/// #         .unwrap()
8162/// #         .https_or_http()
8163/// #         .enable_http2()
8164/// #         .build()
8165/// # );
8166/// # let mut hub = Gmail::new(client, auth);
8167/// // You can configure optional parameters by calling the respective setters at will, and
8168/// // execute the final call using `doit()`.
8169/// // Values shown here are possibly random and not representative !
8170/// let result = hub.users().messages_attachments_get("userId", "messageId", "id")
8171///              .doit().await;
8172/// # }
8173/// ```
8174pub struct UserMessageAttachmentGetCall<'a, C>
8175where
8176    C: 'a,
8177{
8178    hub: &'a Gmail<C>,
8179    _user_id: String,
8180    _message_id: String,
8181    _id: String,
8182    _delegate: Option<&'a mut dyn common::Delegate>,
8183    _additional_params: HashMap<String, String>,
8184    _scopes: BTreeSet<String>,
8185}
8186
8187impl<'a, C> common::CallBuilder for UserMessageAttachmentGetCall<'a, C> {}
8188
8189impl<'a, C> UserMessageAttachmentGetCall<'a, C>
8190where
8191    C: common::Connector,
8192{
8193    /// Perform the operation you have build so far.
8194    pub async fn doit(mut self) -> common::Result<(common::Response, MessagePartBody)> {
8195        use std::borrow::Cow;
8196        use std::io::{Read, Seek};
8197
8198        use common::{url::Params, ToParts};
8199        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8200
8201        let mut dd = common::DefaultDelegate;
8202        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8203        dlg.begin(common::MethodInfo {
8204            id: "gmail.users.messages.attachments.get",
8205            http_method: hyper::Method::GET,
8206        });
8207
8208        for &field in ["alt", "userId", "messageId", "id"].iter() {
8209            if self._additional_params.contains_key(field) {
8210                dlg.finished(false);
8211                return Err(common::Error::FieldClash(field));
8212            }
8213        }
8214
8215        let mut params = Params::with_capacity(5 + self._additional_params.len());
8216        params.push("userId", self._user_id);
8217        params.push("messageId", self._message_id);
8218        params.push("id", self._id);
8219
8220        params.extend(self._additional_params.iter());
8221
8222        params.push("alt", "json");
8223        let mut url = self.hub._base_url.clone()
8224            + "gmail/v1/users/{userId}/messages/{messageId}/attachments/{id}";
8225        if self._scopes.is_empty() {
8226            self._scopes
8227                .insert(Scope::AddonCurrentMessageReadonly.as_ref().to_string());
8228        }
8229
8230        #[allow(clippy::single_element_loop)]
8231        for &(find_this, param_name) in [
8232            ("{userId}", "userId"),
8233            ("{messageId}", "messageId"),
8234            ("{id}", "id"),
8235        ]
8236        .iter()
8237        {
8238            url = params.uri_replacement(url, param_name, find_this, false);
8239        }
8240        {
8241            let to_remove = ["id", "messageId", "userId"];
8242            params.remove_params(&to_remove);
8243        }
8244
8245        let url = params.parse_with_url(&url);
8246
8247        loop {
8248            let token = match self
8249                .hub
8250                .auth
8251                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8252                .await
8253            {
8254                Ok(token) => token,
8255                Err(e) => match dlg.token(e) {
8256                    Ok(token) => token,
8257                    Err(e) => {
8258                        dlg.finished(false);
8259                        return Err(common::Error::MissingToken(e));
8260                    }
8261                },
8262            };
8263            let mut req_result = {
8264                let client = &self.hub.client;
8265                dlg.pre_request();
8266                let mut req_builder = hyper::Request::builder()
8267                    .method(hyper::Method::GET)
8268                    .uri(url.as_str())
8269                    .header(USER_AGENT, self.hub._user_agent.clone());
8270
8271                if let Some(token) = token.as_ref() {
8272                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8273                }
8274
8275                let request = req_builder
8276                    .header(CONTENT_LENGTH, 0_u64)
8277                    .body(common::to_body::<String>(None));
8278
8279                client.request(request.unwrap()).await
8280            };
8281
8282            match req_result {
8283                Err(err) => {
8284                    if let common::Retry::After(d) = dlg.http_error(&err) {
8285                        sleep(d).await;
8286                        continue;
8287                    }
8288                    dlg.finished(false);
8289                    return Err(common::Error::HttpError(err));
8290                }
8291                Ok(res) => {
8292                    let (mut parts, body) = res.into_parts();
8293                    let mut body = common::Body::new(body);
8294                    if !parts.status.is_success() {
8295                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8296                        let error = serde_json::from_str(&common::to_string(&bytes));
8297                        let response = common::to_response(parts, bytes.into());
8298
8299                        if let common::Retry::After(d) =
8300                            dlg.http_failure(&response, error.as_ref().ok())
8301                        {
8302                            sleep(d).await;
8303                            continue;
8304                        }
8305
8306                        dlg.finished(false);
8307
8308                        return Err(match error {
8309                            Ok(value) => common::Error::BadRequest(value),
8310                            _ => common::Error::Failure(response),
8311                        });
8312                    }
8313                    let response = {
8314                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8315                        let encoded = common::to_string(&bytes);
8316                        match serde_json::from_str(&encoded) {
8317                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8318                            Err(error) => {
8319                                dlg.response_json_decode_error(&encoded, &error);
8320                                return Err(common::Error::JsonDecodeError(
8321                                    encoded.to_string(),
8322                                    error,
8323                                ));
8324                            }
8325                        }
8326                    };
8327
8328                    dlg.finished(true);
8329                    return Ok(response);
8330                }
8331            }
8332        }
8333    }
8334
8335    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
8336    ///
8337    /// Sets the *user id* path property to the given value.
8338    ///
8339    /// Even though the property as already been set when instantiating this call,
8340    /// we provide this method for API completeness.
8341    pub fn user_id(mut self, new_value: &str) -> UserMessageAttachmentGetCall<'a, C> {
8342        self._user_id = new_value.to_string();
8343        self
8344    }
8345    /// The ID of the message containing the attachment.
8346    ///
8347    /// Sets the *message id* path property to the given value.
8348    ///
8349    /// Even though the property as already been set when instantiating this call,
8350    /// we provide this method for API completeness.
8351    pub fn message_id(mut self, new_value: &str) -> UserMessageAttachmentGetCall<'a, C> {
8352        self._message_id = new_value.to_string();
8353        self
8354    }
8355    /// The ID of the attachment.
8356    ///
8357    /// Sets the *id* path property to the given value.
8358    ///
8359    /// Even though the property as already been set when instantiating this call,
8360    /// we provide this method for API completeness.
8361    pub fn id(mut self, new_value: &str) -> UserMessageAttachmentGetCall<'a, C> {
8362        self._id = new_value.to_string();
8363        self
8364    }
8365    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8366    /// while executing the actual API request.
8367    ///
8368    /// ````text
8369    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8370    /// ````
8371    ///
8372    /// Sets the *delegate* property to the given value.
8373    pub fn delegate(
8374        mut self,
8375        new_value: &'a mut dyn common::Delegate,
8376    ) -> UserMessageAttachmentGetCall<'a, C> {
8377        self._delegate = Some(new_value);
8378        self
8379    }
8380
8381    /// Set any additional parameter of the query string used in the request.
8382    /// It should be used to set parameters which are not yet available through their own
8383    /// setters.
8384    ///
8385    /// Please note that this method must not be used to set any of the known parameters
8386    /// which have their own setter method. If done anyway, the request will fail.
8387    ///
8388    /// # Additional Parameters
8389    ///
8390    /// * *$.xgafv* (query-string) - V1 error format.
8391    /// * *access_token* (query-string) - OAuth access token.
8392    /// * *alt* (query-string) - Data format for response.
8393    /// * *callback* (query-string) - JSONP
8394    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8395    /// * *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.
8396    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8397    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8398    /// * *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.
8399    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8400    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8401    pub fn param<T>(mut self, name: T, value: T) -> UserMessageAttachmentGetCall<'a, C>
8402    where
8403        T: AsRef<str>,
8404    {
8405        self._additional_params
8406            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8407        self
8408    }
8409
8410    /// Identifies the authorization scope for the method you are building.
8411    ///
8412    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8413    /// [`Scope::AddonCurrentMessageReadonly`].
8414    ///
8415    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8416    /// tokens for more than one scope.
8417    ///
8418    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8419    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8420    /// sufficient, a read-write scope will do as well.
8421    pub fn add_scope<St>(mut self, scope: St) -> UserMessageAttachmentGetCall<'a, C>
8422    where
8423        St: AsRef<str>,
8424    {
8425        self._scopes.insert(String::from(scope.as_ref()));
8426        self
8427    }
8428    /// Identifies the authorization scope(s) for the method you are building.
8429    ///
8430    /// See [`Self::add_scope()`] for details.
8431    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageAttachmentGetCall<'a, C>
8432    where
8433        I: IntoIterator<Item = St>,
8434        St: AsRef<str>,
8435    {
8436        self._scopes
8437            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8438        self
8439    }
8440
8441    /// Removes all scopes, and no default scope will be used either.
8442    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8443    /// for details).
8444    pub fn clear_scopes(mut self) -> UserMessageAttachmentGetCall<'a, C> {
8445        self._scopes.clear();
8446        self
8447    }
8448}
8449
8450/// Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.
8451///
8452/// A builder for the *messages.batchDelete* method supported by a *user* resource.
8453/// It is not used directly, but through a [`UserMethods`] instance.
8454///
8455/// # Example
8456///
8457/// Instantiate a resource method builder
8458///
8459/// ```test_harness,no_run
8460/// # extern crate hyper;
8461/// # extern crate hyper_rustls;
8462/// # extern crate google_gmail1 as gmail1;
8463/// use gmail1::api::BatchDeleteMessagesRequest;
8464/// # async fn dox() {
8465/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8466///
8467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8469/// #     .with_native_roots()
8470/// #     .unwrap()
8471/// #     .https_only()
8472/// #     .enable_http2()
8473/// #     .build();
8474///
8475/// # let executor = hyper_util::rt::TokioExecutor::new();
8476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8477/// #     secret,
8478/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8479/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8480/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8481/// #     ),
8482/// # ).build().await.unwrap();
8483///
8484/// # let client = hyper_util::client::legacy::Client::builder(
8485/// #     hyper_util::rt::TokioExecutor::new()
8486/// # )
8487/// # .build(
8488/// #     hyper_rustls::HttpsConnectorBuilder::new()
8489/// #         .with_native_roots()
8490/// #         .unwrap()
8491/// #         .https_or_http()
8492/// #         .enable_http2()
8493/// #         .build()
8494/// # );
8495/// # let mut hub = Gmail::new(client, auth);
8496/// // As the method needs a request, you would usually fill it with the desired information
8497/// // into the respective structure. Some of the parts shown here might not be applicable !
8498/// // Values shown here are possibly random and not representative !
8499/// let mut req = BatchDeleteMessagesRequest::default();
8500///
8501/// // You can configure optional parameters by calling the respective setters at will, and
8502/// // execute the final call using `doit()`.
8503/// // Values shown here are possibly random and not representative !
8504/// let result = hub.users().messages_batch_delete(req, "userId")
8505///              .doit().await;
8506/// # }
8507/// ```
8508pub struct UserMessageBatchDeleteCall<'a, C>
8509where
8510    C: 'a,
8511{
8512    hub: &'a Gmail<C>,
8513    _request: BatchDeleteMessagesRequest,
8514    _user_id: String,
8515    _delegate: Option<&'a mut dyn common::Delegate>,
8516    _additional_params: HashMap<String, String>,
8517    _scopes: BTreeSet<String>,
8518}
8519
8520impl<'a, C> common::CallBuilder for UserMessageBatchDeleteCall<'a, C> {}
8521
8522impl<'a, C> UserMessageBatchDeleteCall<'a, C>
8523where
8524    C: common::Connector,
8525{
8526    /// Perform the operation you have build so far.
8527    pub async fn doit(mut self) -> common::Result<common::Response> {
8528        use std::borrow::Cow;
8529        use std::io::{Read, Seek};
8530
8531        use common::{url::Params, ToParts};
8532        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8533
8534        let mut dd = common::DefaultDelegate;
8535        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8536        dlg.begin(common::MethodInfo {
8537            id: "gmail.users.messages.batchDelete",
8538            http_method: hyper::Method::POST,
8539        });
8540
8541        for &field in ["userId"].iter() {
8542            if self._additional_params.contains_key(field) {
8543                dlg.finished(false);
8544                return Err(common::Error::FieldClash(field));
8545            }
8546        }
8547
8548        let mut params = Params::with_capacity(3 + self._additional_params.len());
8549        params.push("userId", self._user_id);
8550
8551        params.extend(self._additional_params.iter());
8552
8553        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/batchDelete";
8554        if self._scopes.is_empty() {
8555            self._scopes.insert(Scope::Gmai.as_ref().to_string());
8556        }
8557
8558        #[allow(clippy::single_element_loop)]
8559        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
8560            url = params.uri_replacement(url, param_name, find_this, false);
8561        }
8562        {
8563            let to_remove = ["userId"];
8564            params.remove_params(&to_remove);
8565        }
8566
8567        let url = params.parse_with_url(&url);
8568
8569        let mut json_mime_type = mime::APPLICATION_JSON;
8570        let mut request_value_reader = {
8571            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8572            common::remove_json_null_values(&mut value);
8573            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8574            serde_json::to_writer(&mut dst, &value).unwrap();
8575            dst
8576        };
8577        let request_size = request_value_reader
8578            .seek(std::io::SeekFrom::End(0))
8579            .unwrap();
8580        request_value_reader
8581            .seek(std::io::SeekFrom::Start(0))
8582            .unwrap();
8583
8584        loop {
8585            let token = match self
8586                .hub
8587                .auth
8588                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8589                .await
8590            {
8591                Ok(token) => token,
8592                Err(e) => match dlg.token(e) {
8593                    Ok(token) => token,
8594                    Err(e) => {
8595                        dlg.finished(false);
8596                        return Err(common::Error::MissingToken(e));
8597                    }
8598                },
8599            };
8600            request_value_reader
8601                .seek(std::io::SeekFrom::Start(0))
8602                .unwrap();
8603            let mut req_result = {
8604                let client = &self.hub.client;
8605                dlg.pre_request();
8606                let mut req_builder = hyper::Request::builder()
8607                    .method(hyper::Method::POST)
8608                    .uri(url.as_str())
8609                    .header(USER_AGENT, self.hub._user_agent.clone());
8610
8611                if let Some(token) = token.as_ref() {
8612                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8613                }
8614
8615                let request = req_builder
8616                    .header(CONTENT_TYPE, json_mime_type.to_string())
8617                    .header(CONTENT_LENGTH, request_size as u64)
8618                    .body(common::to_body(
8619                        request_value_reader.get_ref().clone().into(),
8620                    ));
8621
8622                client.request(request.unwrap()).await
8623            };
8624
8625            match req_result {
8626                Err(err) => {
8627                    if let common::Retry::After(d) = dlg.http_error(&err) {
8628                        sleep(d).await;
8629                        continue;
8630                    }
8631                    dlg.finished(false);
8632                    return Err(common::Error::HttpError(err));
8633                }
8634                Ok(res) => {
8635                    let (mut parts, body) = res.into_parts();
8636                    let mut body = common::Body::new(body);
8637                    if !parts.status.is_success() {
8638                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8639                        let error = serde_json::from_str(&common::to_string(&bytes));
8640                        let response = common::to_response(parts, bytes.into());
8641
8642                        if let common::Retry::After(d) =
8643                            dlg.http_failure(&response, error.as_ref().ok())
8644                        {
8645                            sleep(d).await;
8646                            continue;
8647                        }
8648
8649                        dlg.finished(false);
8650
8651                        return Err(match error {
8652                            Ok(value) => common::Error::BadRequest(value),
8653                            _ => common::Error::Failure(response),
8654                        });
8655                    }
8656                    let response = common::Response::from_parts(parts, body);
8657
8658                    dlg.finished(true);
8659                    return Ok(response);
8660                }
8661            }
8662        }
8663    }
8664
8665    ///
8666    /// Sets the *request* property to the given value.
8667    ///
8668    /// Even though the property as already been set when instantiating this call,
8669    /// we provide this method for API completeness.
8670    pub fn request(
8671        mut self,
8672        new_value: BatchDeleteMessagesRequest,
8673    ) -> UserMessageBatchDeleteCall<'a, C> {
8674        self._request = new_value;
8675        self
8676    }
8677    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
8678    ///
8679    /// Sets the *user id* path property to the given value.
8680    ///
8681    /// Even though the property as already been set when instantiating this call,
8682    /// we provide this method for API completeness.
8683    pub fn user_id(mut self, new_value: &str) -> UserMessageBatchDeleteCall<'a, C> {
8684        self._user_id = new_value.to_string();
8685        self
8686    }
8687    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8688    /// while executing the actual API request.
8689    ///
8690    /// ````text
8691    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8692    /// ````
8693    ///
8694    /// Sets the *delegate* property to the given value.
8695    pub fn delegate(
8696        mut self,
8697        new_value: &'a mut dyn common::Delegate,
8698    ) -> UserMessageBatchDeleteCall<'a, C> {
8699        self._delegate = Some(new_value);
8700        self
8701    }
8702
8703    /// Set any additional parameter of the query string used in the request.
8704    /// It should be used to set parameters which are not yet available through their own
8705    /// setters.
8706    ///
8707    /// Please note that this method must not be used to set any of the known parameters
8708    /// which have their own setter method. If done anyway, the request will fail.
8709    ///
8710    /// # Additional Parameters
8711    ///
8712    /// * *$.xgafv* (query-string) - V1 error format.
8713    /// * *access_token* (query-string) - OAuth access token.
8714    /// * *alt* (query-string) - Data format for response.
8715    /// * *callback* (query-string) - JSONP
8716    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8717    /// * *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.
8718    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8719    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8720    /// * *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.
8721    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8722    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8723    pub fn param<T>(mut self, name: T, value: T) -> UserMessageBatchDeleteCall<'a, C>
8724    where
8725        T: AsRef<str>,
8726    {
8727        self._additional_params
8728            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8729        self
8730    }
8731
8732    /// Identifies the authorization scope for the method you are building.
8733    ///
8734    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8735    /// [`Scope::Gmai`].
8736    ///
8737    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8738    /// tokens for more than one scope.
8739    ///
8740    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8741    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8742    /// sufficient, a read-write scope will do as well.
8743    pub fn add_scope<St>(mut self, scope: St) -> UserMessageBatchDeleteCall<'a, C>
8744    where
8745        St: AsRef<str>,
8746    {
8747        self._scopes.insert(String::from(scope.as_ref()));
8748        self
8749    }
8750    /// Identifies the authorization scope(s) for the method you are building.
8751    ///
8752    /// See [`Self::add_scope()`] for details.
8753    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageBatchDeleteCall<'a, C>
8754    where
8755        I: IntoIterator<Item = St>,
8756        St: AsRef<str>,
8757    {
8758        self._scopes
8759            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8760        self
8761    }
8762
8763    /// Removes all scopes, and no default scope will be used either.
8764    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8765    /// for details).
8766    pub fn clear_scopes(mut self) -> UserMessageBatchDeleteCall<'a, C> {
8767        self._scopes.clear();
8768        self
8769    }
8770}
8771
8772/// Modifies the labels on the specified messages.
8773///
8774/// A builder for the *messages.batchModify* method supported by a *user* resource.
8775/// It is not used directly, but through a [`UserMethods`] instance.
8776///
8777/// # Example
8778///
8779/// Instantiate a resource method builder
8780///
8781/// ```test_harness,no_run
8782/// # extern crate hyper;
8783/// # extern crate hyper_rustls;
8784/// # extern crate google_gmail1 as gmail1;
8785/// use gmail1::api::BatchModifyMessagesRequest;
8786/// # async fn dox() {
8787/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8788///
8789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8790/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8791/// #     .with_native_roots()
8792/// #     .unwrap()
8793/// #     .https_only()
8794/// #     .enable_http2()
8795/// #     .build();
8796///
8797/// # let executor = hyper_util::rt::TokioExecutor::new();
8798/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8799/// #     secret,
8800/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8801/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8802/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8803/// #     ),
8804/// # ).build().await.unwrap();
8805///
8806/// # let client = hyper_util::client::legacy::Client::builder(
8807/// #     hyper_util::rt::TokioExecutor::new()
8808/// # )
8809/// # .build(
8810/// #     hyper_rustls::HttpsConnectorBuilder::new()
8811/// #         .with_native_roots()
8812/// #         .unwrap()
8813/// #         .https_or_http()
8814/// #         .enable_http2()
8815/// #         .build()
8816/// # );
8817/// # let mut hub = Gmail::new(client, auth);
8818/// // As the method needs a request, you would usually fill it with the desired information
8819/// // into the respective structure. Some of the parts shown here might not be applicable !
8820/// // Values shown here are possibly random and not representative !
8821/// let mut req = BatchModifyMessagesRequest::default();
8822///
8823/// // You can configure optional parameters by calling the respective setters at will, and
8824/// // execute the final call using `doit()`.
8825/// // Values shown here are possibly random and not representative !
8826/// let result = hub.users().messages_batch_modify(req, "userId")
8827///              .doit().await;
8828/// # }
8829/// ```
8830pub struct UserMessageBatchModifyCall<'a, C>
8831where
8832    C: 'a,
8833{
8834    hub: &'a Gmail<C>,
8835    _request: BatchModifyMessagesRequest,
8836    _user_id: String,
8837    _delegate: Option<&'a mut dyn common::Delegate>,
8838    _additional_params: HashMap<String, String>,
8839    _scopes: BTreeSet<String>,
8840}
8841
8842impl<'a, C> common::CallBuilder for UserMessageBatchModifyCall<'a, C> {}
8843
8844impl<'a, C> UserMessageBatchModifyCall<'a, C>
8845where
8846    C: common::Connector,
8847{
8848    /// Perform the operation you have build so far.
8849    pub async fn doit(mut self) -> common::Result<common::Response> {
8850        use std::borrow::Cow;
8851        use std::io::{Read, Seek};
8852
8853        use common::{url::Params, ToParts};
8854        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8855
8856        let mut dd = common::DefaultDelegate;
8857        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8858        dlg.begin(common::MethodInfo {
8859            id: "gmail.users.messages.batchModify",
8860            http_method: hyper::Method::POST,
8861        });
8862
8863        for &field in ["userId"].iter() {
8864            if self._additional_params.contains_key(field) {
8865                dlg.finished(false);
8866                return Err(common::Error::FieldClash(field));
8867            }
8868        }
8869
8870        let mut params = Params::with_capacity(3 + self._additional_params.len());
8871        params.push("userId", self._user_id);
8872
8873        params.extend(self._additional_params.iter());
8874
8875        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/batchModify";
8876        if self._scopes.is_empty() {
8877            self._scopes.insert(Scope::Gmai.as_ref().to_string());
8878        }
8879
8880        #[allow(clippy::single_element_loop)]
8881        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
8882            url = params.uri_replacement(url, param_name, find_this, false);
8883        }
8884        {
8885            let to_remove = ["userId"];
8886            params.remove_params(&to_remove);
8887        }
8888
8889        let url = params.parse_with_url(&url);
8890
8891        let mut json_mime_type = mime::APPLICATION_JSON;
8892        let mut request_value_reader = {
8893            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8894            common::remove_json_null_values(&mut value);
8895            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8896            serde_json::to_writer(&mut dst, &value).unwrap();
8897            dst
8898        };
8899        let request_size = request_value_reader
8900            .seek(std::io::SeekFrom::End(0))
8901            .unwrap();
8902        request_value_reader
8903            .seek(std::io::SeekFrom::Start(0))
8904            .unwrap();
8905
8906        loop {
8907            let token = match self
8908                .hub
8909                .auth
8910                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8911                .await
8912            {
8913                Ok(token) => token,
8914                Err(e) => match dlg.token(e) {
8915                    Ok(token) => token,
8916                    Err(e) => {
8917                        dlg.finished(false);
8918                        return Err(common::Error::MissingToken(e));
8919                    }
8920                },
8921            };
8922            request_value_reader
8923                .seek(std::io::SeekFrom::Start(0))
8924                .unwrap();
8925            let mut req_result = {
8926                let client = &self.hub.client;
8927                dlg.pre_request();
8928                let mut req_builder = hyper::Request::builder()
8929                    .method(hyper::Method::POST)
8930                    .uri(url.as_str())
8931                    .header(USER_AGENT, self.hub._user_agent.clone());
8932
8933                if let Some(token) = token.as_ref() {
8934                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8935                }
8936
8937                let request = req_builder
8938                    .header(CONTENT_TYPE, json_mime_type.to_string())
8939                    .header(CONTENT_LENGTH, request_size as u64)
8940                    .body(common::to_body(
8941                        request_value_reader.get_ref().clone().into(),
8942                    ));
8943
8944                client.request(request.unwrap()).await
8945            };
8946
8947            match req_result {
8948                Err(err) => {
8949                    if let common::Retry::After(d) = dlg.http_error(&err) {
8950                        sleep(d).await;
8951                        continue;
8952                    }
8953                    dlg.finished(false);
8954                    return Err(common::Error::HttpError(err));
8955                }
8956                Ok(res) => {
8957                    let (mut parts, body) = res.into_parts();
8958                    let mut body = common::Body::new(body);
8959                    if !parts.status.is_success() {
8960                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8961                        let error = serde_json::from_str(&common::to_string(&bytes));
8962                        let response = common::to_response(parts, bytes.into());
8963
8964                        if let common::Retry::After(d) =
8965                            dlg.http_failure(&response, error.as_ref().ok())
8966                        {
8967                            sleep(d).await;
8968                            continue;
8969                        }
8970
8971                        dlg.finished(false);
8972
8973                        return Err(match error {
8974                            Ok(value) => common::Error::BadRequest(value),
8975                            _ => common::Error::Failure(response),
8976                        });
8977                    }
8978                    let response = common::Response::from_parts(parts, body);
8979
8980                    dlg.finished(true);
8981                    return Ok(response);
8982                }
8983            }
8984        }
8985    }
8986
8987    ///
8988    /// Sets the *request* property to the given value.
8989    ///
8990    /// Even though the property as already been set when instantiating this call,
8991    /// we provide this method for API completeness.
8992    pub fn request(
8993        mut self,
8994        new_value: BatchModifyMessagesRequest,
8995    ) -> UserMessageBatchModifyCall<'a, C> {
8996        self._request = new_value;
8997        self
8998    }
8999    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
9000    ///
9001    /// Sets the *user id* path property to the given value.
9002    ///
9003    /// Even though the property as already been set when instantiating this call,
9004    /// we provide this method for API completeness.
9005    pub fn user_id(mut self, new_value: &str) -> UserMessageBatchModifyCall<'a, C> {
9006        self._user_id = new_value.to_string();
9007        self
9008    }
9009    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9010    /// while executing the actual API request.
9011    ///
9012    /// ````text
9013    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9014    /// ````
9015    ///
9016    /// Sets the *delegate* property to the given value.
9017    pub fn delegate(
9018        mut self,
9019        new_value: &'a mut dyn common::Delegate,
9020    ) -> UserMessageBatchModifyCall<'a, C> {
9021        self._delegate = Some(new_value);
9022        self
9023    }
9024
9025    /// Set any additional parameter of the query string used in the request.
9026    /// It should be used to set parameters which are not yet available through their own
9027    /// setters.
9028    ///
9029    /// Please note that this method must not be used to set any of the known parameters
9030    /// which have their own setter method. If done anyway, the request will fail.
9031    ///
9032    /// # Additional Parameters
9033    ///
9034    /// * *$.xgafv* (query-string) - V1 error format.
9035    /// * *access_token* (query-string) - OAuth access token.
9036    /// * *alt* (query-string) - Data format for response.
9037    /// * *callback* (query-string) - JSONP
9038    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9039    /// * *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.
9040    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9041    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9042    /// * *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.
9043    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9044    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9045    pub fn param<T>(mut self, name: T, value: T) -> UserMessageBatchModifyCall<'a, C>
9046    where
9047        T: AsRef<str>,
9048    {
9049        self._additional_params
9050            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9051        self
9052    }
9053
9054    /// Identifies the authorization scope for the method you are building.
9055    ///
9056    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9057    /// [`Scope::Gmai`].
9058    ///
9059    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9060    /// tokens for more than one scope.
9061    ///
9062    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9063    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9064    /// sufficient, a read-write scope will do as well.
9065    pub fn add_scope<St>(mut self, scope: St) -> UserMessageBatchModifyCall<'a, C>
9066    where
9067        St: AsRef<str>,
9068    {
9069        self._scopes.insert(String::from(scope.as_ref()));
9070        self
9071    }
9072    /// Identifies the authorization scope(s) for the method you are building.
9073    ///
9074    /// See [`Self::add_scope()`] for details.
9075    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageBatchModifyCall<'a, C>
9076    where
9077        I: IntoIterator<Item = St>,
9078        St: AsRef<str>,
9079    {
9080        self._scopes
9081            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9082        self
9083    }
9084
9085    /// Removes all scopes, and no default scope will be used either.
9086    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9087    /// for details).
9088    pub fn clear_scopes(mut self) -> UserMessageBatchModifyCall<'a, C> {
9089        self._scopes.clear();
9090        self
9091    }
9092}
9093
9094/// Immediately and permanently deletes the specified message. This operation cannot be undone. Prefer `messages.trash` instead.
9095///
9096/// A builder for the *messages.delete* method supported by a *user* resource.
9097/// It is not used directly, but through a [`UserMethods`] instance.
9098///
9099/// # Example
9100///
9101/// Instantiate a resource method builder
9102///
9103/// ```test_harness,no_run
9104/// # extern crate hyper;
9105/// # extern crate hyper_rustls;
9106/// # extern crate google_gmail1 as gmail1;
9107/// # async fn dox() {
9108/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9109///
9110/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9111/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9112/// #     .with_native_roots()
9113/// #     .unwrap()
9114/// #     .https_only()
9115/// #     .enable_http2()
9116/// #     .build();
9117///
9118/// # let executor = hyper_util::rt::TokioExecutor::new();
9119/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9120/// #     secret,
9121/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9122/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9123/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9124/// #     ),
9125/// # ).build().await.unwrap();
9126///
9127/// # let client = hyper_util::client::legacy::Client::builder(
9128/// #     hyper_util::rt::TokioExecutor::new()
9129/// # )
9130/// # .build(
9131/// #     hyper_rustls::HttpsConnectorBuilder::new()
9132/// #         .with_native_roots()
9133/// #         .unwrap()
9134/// #         .https_or_http()
9135/// #         .enable_http2()
9136/// #         .build()
9137/// # );
9138/// # let mut hub = Gmail::new(client, auth);
9139/// // You can configure optional parameters by calling the respective setters at will, and
9140/// // execute the final call using `doit()`.
9141/// // Values shown here are possibly random and not representative !
9142/// let result = hub.users().messages_delete("userId", "id")
9143///              .doit().await;
9144/// # }
9145/// ```
9146pub struct UserMessageDeleteCall<'a, C>
9147where
9148    C: 'a,
9149{
9150    hub: &'a Gmail<C>,
9151    _user_id: String,
9152    _id: String,
9153    _delegate: Option<&'a mut dyn common::Delegate>,
9154    _additional_params: HashMap<String, String>,
9155    _scopes: BTreeSet<String>,
9156}
9157
9158impl<'a, C> common::CallBuilder for UserMessageDeleteCall<'a, C> {}
9159
9160impl<'a, C> UserMessageDeleteCall<'a, C>
9161where
9162    C: common::Connector,
9163{
9164    /// Perform the operation you have build so far.
9165    pub async fn doit(mut self) -> common::Result<common::Response> {
9166        use std::borrow::Cow;
9167        use std::io::{Read, Seek};
9168
9169        use common::{url::Params, ToParts};
9170        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9171
9172        let mut dd = common::DefaultDelegate;
9173        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9174        dlg.begin(common::MethodInfo {
9175            id: "gmail.users.messages.delete",
9176            http_method: hyper::Method::DELETE,
9177        });
9178
9179        for &field in ["userId", "id"].iter() {
9180            if self._additional_params.contains_key(field) {
9181                dlg.finished(false);
9182                return Err(common::Error::FieldClash(field));
9183            }
9184        }
9185
9186        let mut params = Params::with_capacity(3 + self._additional_params.len());
9187        params.push("userId", self._user_id);
9188        params.push("id", self._id);
9189
9190        params.extend(self._additional_params.iter());
9191
9192        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/{id}";
9193        if self._scopes.is_empty() {
9194            self._scopes.insert(Scope::Gmai.as_ref().to_string());
9195        }
9196
9197        #[allow(clippy::single_element_loop)]
9198        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
9199            url = params.uri_replacement(url, param_name, find_this, false);
9200        }
9201        {
9202            let to_remove = ["id", "userId"];
9203            params.remove_params(&to_remove);
9204        }
9205
9206        let url = params.parse_with_url(&url);
9207
9208        loop {
9209            let token = match self
9210                .hub
9211                .auth
9212                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9213                .await
9214            {
9215                Ok(token) => token,
9216                Err(e) => match dlg.token(e) {
9217                    Ok(token) => token,
9218                    Err(e) => {
9219                        dlg.finished(false);
9220                        return Err(common::Error::MissingToken(e));
9221                    }
9222                },
9223            };
9224            let mut req_result = {
9225                let client = &self.hub.client;
9226                dlg.pre_request();
9227                let mut req_builder = hyper::Request::builder()
9228                    .method(hyper::Method::DELETE)
9229                    .uri(url.as_str())
9230                    .header(USER_AGENT, self.hub._user_agent.clone());
9231
9232                if let Some(token) = token.as_ref() {
9233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9234                }
9235
9236                let request = req_builder
9237                    .header(CONTENT_LENGTH, 0_u64)
9238                    .body(common::to_body::<String>(None));
9239
9240                client.request(request.unwrap()).await
9241            };
9242
9243            match req_result {
9244                Err(err) => {
9245                    if let common::Retry::After(d) = dlg.http_error(&err) {
9246                        sleep(d).await;
9247                        continue;
9248                    }
9249                    dlg.finished(false);
9250                    return Err(common::Error::HttpError(err));
9251                }
9252                Ok(res) => {
9253                    let (mut parts, body) = res.into_parts();
9254                    let mut body = common::Body::new(body);
9255                    if !parts.status.is_success() {
9256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9257                        let error = serde_json::from_str(&common::to_string(&bytes));
9258                        let response = common::to_response(parts, bytes.into());
9259
9260                        if let common::Retry::After(d) =
9261                            dlg.http_failure(&response, error.as_ref().ok())
9262                        {
9263                            sleep(d).await;
9264                            continue;
9265                        }
9266
9267                        dlg.finished(false);
9268
9269                        return Err(match error {
9270                            Ok(value) => common::Error::BadRequest(value),
9271                            _ => common::Error::Failure(response),
9272                        });
9273                    }
9274                    let response = common::Response::from_parts(parts, body);
9275
9276                    dlg.finished(true);
9277                    return Ok(response);
9278                }
9279            }
9280        }
9281    }
9282
9283    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
9284    ///
9285    /// Sets the *user id* path property to the given value.
9286    ///
9287    /// Even though the property as already been set when instantiating this call,
9288    /// we provide this method for API completeness.
9289    pub fn user_id(mut self, new_value: &str) -> UserMessageDeleteCall<'a, C> {
9290        self._user_id = new_value.to_string();
9291        self
9292    }
9293    /// The ID of the message to delete.
9294    ///
9295    /// Sets the *id* path property to the given value.
9296    ///
9297    /// Even though the property as already been set when instantiating this call,
9298    /// we provide this method for API completeness.
9299    pub fn id(mut self, new_value: &str) -> UserMessageDeleteCall<'a, C> {
9300        self._id = new_value.to_string();
9301        self
9302    }
9303    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9304    /// while executing the actual API request.
9305    ///
9306    /// ````text
9307    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9308    /// ````
9309    ///
9310    /// Sets the *delegate* property to the given value.
9311    pub fn delegate(
9312        mut self,
9313        new_value: &'a mut dyn common::Delegate,
9314    ) -> UserMessageDeleteCall<'a, C> {
9315        self._delegate = Some(new_value);
9316        self
9317    }
9318
9319    /// Set any additional parameter of the query string used in the request.
9320    /// It should be used to set parameters which are not yet available through their own
9321    /// setters.
9322    ///
9323    /// Please note that this method must not be used to set any of the known parameters
9324    /// which have their own setter method. If done anyway, the request will fail.
9325    ///
9326    /// # Additional Parameters
9327    ///
9328    /// * *$.xgafv* (query-string) - V1 error format.
9329    /// * *access_token* (query-string) - OAuth access token.
9330    /// * *alt* (query-string) - Data format for response.
9331    /// * *callback* (query-string) - JSONP
9332    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9333    /// * *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.
9334    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9335    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9336    /// * *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.
9337    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9338    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9339    pub fn param<T>(mut self, name: T, value: T) -> UserMessageDeleteCall<'a, C>
9340    where
9341        T: AsRef<str>,
9342    {
9343        self._additional_params
9344            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9345        self
9346    }
9347
9348    /// Identifies the authorization scope for the method you are building.
9349    ///
9350    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9351    /// [`Scope::Gmai`].
9352    ///
9353    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9354    /// tokens for more than one scope.
9355    ///
9356    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9357    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9358    /// sufficient, a read-write scope will do as well.
9359    pub fn add_scope<St>(mut self, scope: St) -> UserMessageDeleteCall<'a, C>
9360    where
9361        St: AsRef<str>,
9362    {
9363        self._scopes.insert(String::from(scope.as_ref()));
9364        self
9365    }
9366    /// Identifies the authorization scope(s) for the method you are building.
9367    ///
9368    /// See [`Self::add_scope()`] for details.
9369    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageDeleteCall<'a, C>
9370    where
9371        I: IntoIterator<Item = St>,
9372        St: AsRef<str>,
9373    {
9374        self._scopes
9375            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9376        self
9377    }
9378
9379    /// Removes all scopes, and no default scope will be used either.
9380    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9381    /// for details).
9382    pub fn clear_scopes(mut self) -> UserMessageDeleteCall<'a, C> {
9383        self._scopes.clear();
9384        self
9385    }
9386}
9387
9388/// Gets the specified message.
9389///
9390/// A builder for the *messages.get* method supported by a *user* resource.
9391/// It is not used directly, but through a [`UserMethods`] instance.
9392///
9393/// # Example
9394///
9395/// Instantiate a resource method builder
9396///
9397/// ```test_harness,no_run
9398/// # extern crate hyper;
9399/// # extern crate hyper_rustls;
9400/// # extern crate google_gmail1 as gmail1;
9401/// # async fn dox() {
9402/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9403///
9404/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9405/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9406/// #     .with_native_roots()
9407/// #     .unwrap()
9408/// #     .https_only()
9409/// #     .enable_http2()
9410/// #     .build();
9411///
9412/// # let executor = hyper_util::rt::TokioExecutor::new();
9413/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9414/// #     secret,
9415/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9416/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9417/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9418/// #     ),
9419/// # ).build().await.unwrap();
9420///
9421/// # let client = hyper_util::client::legacy::Client::builder(
9422/// #     hyper_util::rt::TokioExecutor::new()
9423/// # )
9424/// # .build(
9425/// #     hyper_rustls::HttpsConnectorBuilder::new()
9426/// #         .with_native_roots()
9427/// #         .unwrap()
9428/// #         .https_or_http()
9429/// #         .enable_http2()
9430/// #         .build()
9431/// # );
9432/// # let mut hub = Gmail::new(client, auth);
9433/// // You can configure optional parameters by calling the respective setters at will, and
9434/// // execute the final call using `doit()`.
9435/// // Values shown here are possibly random and not representative !
9436/// let result = hub.users().messages_get("userId", "id")
9437///              .add_metadata_headers("dolor")
9438///              .format("duo")
9439///              .doit().await;
9440/// # }
9441/// ```
9442pub struct UserMessageGetCall<'a, C>
9443where
9444    C: 'a,
9445{
9446    hub: &'a Gmail<C>,
9447    _user_id: String,
9448    _id: String,
9449    _metadata_headers: Vec<String>,
9450    _format: Option<String>,
9451    _delegate: Option<&'a mut dyn common::Delegate>,
9452    _additional_params: HashMap<String, String>,
9453    _scopes: BTreeSet<String>,
9454}
9455
9456impl<'a, C> common::CallBuilder for UserMessageGetCall<'a, C> {}
9457
9458impl<'a, C> UserMessageGetCall<'a, C>
9459where
9460    C: common::Connector,
9461{
9462    /// Perform the operation you have build so far.
9463    pub async fn doit(mut self) -> common::Result<(common::Response, Message)> {
9464        use std::borrow::Cow;
9465        use std::io::{Read, Seek};
9466
9467        use common::{url::Params, ToParts};
9468        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9469
9470        let mut dd = common::DefaultDelegate;
9471        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9472        dlg.begin(common::MethodInfo {
9473            id: "gmail.users.messages.get",
9474            http_method: hyper::Method::GET,
9475        });
9476
9477        for &field in ["alt", "userId", "id", "metadataHeaders", "format"].iter() {
9478            if self._additional_params.contains_key(field) {
9479                dlg.finished(false);
9480                return Err(common::Error::FieldClash(field));
9481            }
9482        }
9483
9484        let mut params = Params::with_capacity(6 + self._additional_params.len());
9485        params.push("userId", self._user_id);
9486        params.push("id", self._id);
9487        if !self._metadata_headers.is_empty() {
9488            for f in self._metadata_headers.iter() {
9489                params.push("metadataHeaders", f);
9490            }
9491        }
9492        if let Some(value) = self._format.as_ref() {
9493            params.push("format", value);
9494        }
9495
9496        params.extend(self._additional_params.iter());
9497
9498        params.push("alt", "json");
9499        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/{id}";
9500        if self._scopes.is_empty() {
9501            self._scopes
9502                .insert(Scope::AddonCurrentMessageReadonly.as_ref().to_string());
9503        }
9504
9505        #[allow(clippy::single_element_loop)]
9506        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
9507            url = params.uri_replacement(url, param_name, find_this, false);
9508        }
9509        {
9510            let to_remove = ["id", "userId"];
9511            params.remove_params(&to_remove);
9512        }
9513
9514        let url = params.parse_with_url(&url);
9515
9516        loop {
9517            let token = match self
9518                .hub
9519                .auth
9520                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9521                .await
9522            {
9523                Ok(token) => token,
9524                Err(e) => match dlg.token(e) {
9525                    Ok(token) => token,
9526                    Err(e) => {
9527                        dlg.finished(false);
9528                        return Err(common::Error::MissingToken(e));
9529                    }
9530                },
9531            };
9532            let mut req_result = {
9533                let client = &self.hub.client;
9534                dlg.pre_request();
9535                let mut req_builder = hyper::Request::builder()
9536                    .method(hyper::Method::GET)
9537                    .uri(url.as_str())
9538                    .header(USER_AGENT, self.hub._user_agent.clone());
9539
9540                if let Some(token) = token.as_ref() {
9541                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9542                }
9543
9544                let request = req_builder
9545                    .header(CONTENT_LENGTH, 0_u64)
9546                    .body(common::to_body::<String>(None));
9547
9548                client.request(request.unwrap()).await
9549            };
9550
9551            match req_result {
9552                Err(err) => {
9553                    if let common::Retry::After(d) = dlg.http_error(&err) {
9554                        sleep(d).await;
9555                        continue;
9556                    }
9557                    dlg.finished(false);
9558                    return Err(common::Error::HttpError(err));
9559                }
9560                Ok(res) => {
9561                    let (mut parts, body) = res.into_parts();
9562                    let mut body = common::Body::new(body);
9563                    if !parts.status.is_success() {
9564                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9565                        let error = serde_json::from_str(&common::to_string(&bytes));
9566                        let response = common::to_response(parts, bytes.into());
9567
9568                        if let common::Retry::After(d) =
9569                            dlg.http_failure(&response, error.as_ref().ok())
9570                        {
9571                            sleep(d).await;
9572                            continue;
9573                        }
9574
9575                        dlg.finished(false);
9576
9577                        return Err(match error {
9578                            Ok(value) => common::Error::BadRequest(value),
9579                            _ => common::Error::Failure(response),
9580                        });
9581                    }
9582                    let response = {
9583                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9584                        let encoded = common::to_string(&bytes);
9585                        match serde_json::from_str(&encoded) {
9586                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9587                            Err(error) => {
9588                                dlg.response_json_decode_error(&encoded, &error);
9589                                return Err(common::Error::JsonDecodeError(
9590                                    encoded.to_string(),
9591                                    error,
9592                                ));
9593                            }
9594                        }
9595                    };
9596
9597                    dlg.finished(true);
9598                    return Ok(response);
9599                }
9600            }
9601        }
9602    }
9603
9604    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
9605    ///
9606    /// Sets the *user id* path property to the given value.
9607    ///
9608    /// Even though the property as already been set when instantiating this call,
9609    /// we provide this method for API completeness.
9610    pub fn user_id(mut self, new_value: &str) -> UserMessageGetCall<'a, C> {
9611        self._user_id = new_value.to_string();
9612        self
9613    }
9614    /// The ID of the message to retrieve. This ID is usually retrieved using `messages.list`. The ID is also contained in the result when a message is inserted (`messages.insert`) or imported (`messages.import`).
9615    ///
9616    /// Sets the *id* path property to the given value.
9617    ///
9618    /// Even though the property as already been set when instantiating this call,
9619    /// we provide this method for API completeness.
9620    pub fn id(mut self, new_value: &str) -> UserMessageGetCall<'a, C> {
9621        self._id = new_value.to_string();
9622        self
9623    }
9624    /// When given and format is `METADATA`, only include headers specified.
9625    ///
9626    /// Append the given value to the *metadata headers* query property.
9627    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
9628    pub fn add_metadata_headers(mut self, new_value: &str) -> UserMessageGetCall<'a, C> {
9629        self._metadata_headers.push(new_value.to_string());
9630        self
9631    }
9632    /// The format to return the message in.
9633    ///
9634    /// Sets the *format* query property to the given value.
9635    pub fn format(mut self, new_value: &str) -> UserMessageGetCall<'a, C> {
9636        self._format = Some(new_value.to_string());
9637        self
9638    }
9639    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9640    /// while executing the actual API request.
9641    ///
9642    /// ````text
9643    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9644    /// ````
9645    ///
9646    /// Sets the *delegate* property to the given value.
9647    pub fn delegate(
9648        mut self,
9649        new_value: &'a mut dyn common::Delegate,
9650    ) -> UserMessageGetCall<'a, C> {
9651        self._delegate = Some(new_value);
9652        self
9653    }
9654
9655    /// Set any additional parameter of the query string used in the request.
9656    /// It should be used to set parameters which are not yet available through their own
9657    /// setters.
9658    ///
9659    /// Please note that this method must not be used to set any of the known parameters
9660    /// which have their own setter method. If done anyway, the request will fail.
9661    ///
9662    /// # Additional Parameters
9663    ///
9664    /// * *$.xgafv* (query-string) - V1 error format.
9665    /// * *access_token* (query-string) - OAuth access token.
9666    /// * *alt* (query-string) - Data format for response.
9667    /// * *callback* (query-string) - JSONP
9668    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9669    /// * *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.
9670    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9671    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9672    /// * *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.
9673    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9674    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9675    pub fn param<T>(mut self, name: T, value: T) -> UserMessageGetCall<'a, C>
9676    where
9677        T: AsRef<str>,
9678    {
9679        self._additional_params
9680            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9681        self
9682    }
9683
9684    /// Identifies the authorization scope for the method you are building.
9685    ///
9686    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9687    /// [`Scope::AddonCurrentMessageReadonly`].
9688    ///
9689    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9690    /// tokens for more than one scope.
9691    ///
9692    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9693    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9694    /// sufficient, a read-write scope will do as well.
9695    pub fn add_scope<St>(mut self, scope: St) -> UserMessageGetCall<'a, C>
9696    where
9697        St: AsRef<str>,
9698    {
9699        self._scopes.insert(String::from(scope.as_ref()));
9700        self
9701    }
9702    /// Identifies the authorization scope(s) for the method you are building.
9703    ///
9704    /// See [`Self::add_scope()`] for details.
9705    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageGetCall<'a, C>
9706    where
9707        I: IntoIterator<Item = St>,
9708        St: AsRef<str>,
9709    {
9710        self._scopes
9711            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9712        self
9713    }
9714
9715    /// Removes all scopes, and no default scope will be used either.
9716    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9717    /// for details).
9718    pub fn clear_scopes(mut self) -> UserMessageGetCall<'a, C> {
9719        self._scopes.clear();
9720        self
9721    }
9722}
9723
9724/// Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note that the maximum size of the message is 150MB.
9725///
9726/// A builder for the *messages.import* method supported by a *user* resource.
9727/// It is not used directly, but through a [`UserMethods`] instance.
9728///
9729/// # Example
9730///
9731/// Instantiate a resource method builder
9732///
9733/// ```test_harness,no_run
9734/// # extern crate hyper;
9735/// # extern crate hyper_rustls;
9736/// # extern crate google_gmail1 as gmail1;
9737/// use gmail1::api::Message;
9738/// use std::fs;
9739/// # async fn dox() {
9740/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9741///
9742/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9743/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9744/// #     .with_native_roots()
9745/// #     .unwrap()
9746/// #     .https_only()
9747/// #     .enable_http2()
9748/// #     .build();
9749///
9750/// # let executor = hyper_util::rt::TokioExecutor::new();
9751/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9752/// #     secret,
9753/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9754/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9755/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9756/// #     ),
9757/// # ).build().await.unwrap();
9758///
9759/// # let client = hyper_util::client::legacy::Client::builder(
9760/// #     hyper_util::rt::TokioExecutor::new()
9761/// # )
9762/// # .build(
9763/// #     hyper_rustls::HttpsConnectorBuilder::new()
9764/// #         .with_native_roots()
9765/// #         .unwrap()
9766/// #         .https_or_http()
9767/// #         .enable_http2()
9768/// #         .build()
9769/// # );
9770/// # let mut hub = Gmail::new(client, auth);
9771/// // As the method needs a request, you would usually fill it with the desired information
9772/// // into the respective structure. Some of the parts shown here might not be applicable !
9773/// // Values shown here are possibly random and not representative !
9774/// let mut req = Message::default();
9775///
9776/// // You can configure optional parameters by calling the respective setters at will, and
9777/// // execute the final call using `upload_resumable(...)`.
9778/// // Values shown here are possibly random and not representative !
9779/// let result = hub.users().messages_import(req, "userId")
9780///              .process_for_calendar(false)
9781///              .never_mark_spam(false)
9782///              .internal_date_source("Stet")
9783///              .deleted(false)
9784///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
9785/// # }
9786/// ```
9787pub struct UserMessageImportCall<'a, C>
9788where
9789    C: 'a,
9790{
9791    hub: &'a Gmail<C>,
9792    _request: Message,
9793    _user_id: String,
9794    _process_for_calendar: Option<bool>,
9795    _never_mark_spam: Option<bool>,
9796    _internal_date_source: Option<String>,
9797    _deleted: Option<bool>,
9798    _delegate: Option<&'a mut dyn common::Delegate>,
9799    _additional_params: HashMap<String, String>,
9800    _scopes: BTreeSet<String>,
9801}
9802
9803impl<'a, C> common::CallBuilder for UserMessageImportCall<'a, C> {}
9804
9805impl<'a, C> UserMessageImportCall<'a, C>
9806where
9807    C: common::Connector,
9808{
9809    /// Perform the operation you have build so far.
9810    async fn doit<RS>(
9811        mut self,
9812        mut reader: RS,
9813        reader_mime_type: mime::Mime,
9814        protocol: common::UploadProtocol,
9815    ) -> common::Result<(common::Response, Message)>
9816    where
9817        RS: common::ReadSeek,
9818    {
9819        use std::borrow::Cow;
9820        use std::io::{Read, Seek};
9821
9822        use common::{url::Params, ToParts};
9823        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9824
9825        let mut dd = common::DefaultDelegate;
9826        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9827        dlg.begin(common::MethodInfo {
9828            id: "gmail.users.messages.import",
9829            http_method: hyper::Method::POST,
9830        });
9831
9832        for &field in [
9833            "alt",
9834            "userId",
9835            "processForCalendar",
9836            "neverMarkSpam",
9837            "internalDateSource",
9838            "deleted",
9839        ]
9840        .iter()
9841        {
9842            if self._additional_params.contains_key(field) {
9843                dlg.finished(false);
9844                return Err(common::Error::FieldClash(field));
9845            }
9846        }
9847
9848        let mut params = Params::with_capacity(8 + self._additional_params.len());
9849        params.push("userId", self._user_id);
9850        if let Some(value) = self._process_for_calendar.as_ref() {
9851            params.push("processForCalendar", value.to_string());
9852        }
9853        if let Some(value) = self._never_mark_spam.as_ref() {
9854            params.push("neverMarkSpam", value.to_string());
9855        }
9856        if let Some(value) = self._internal_date_source.as_ref() {
9857            params.push("internalDateSource", value);
9858        }
9859        if let Some(value) = self._deleted.as_ref() {
9860            params.push("deleted", value.to_string());
9861        }
9862
9863        params.extend(self._additional_params.iter());
9864
9865        params.push("alt", "json");
9866        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
9867            (
9868                self.hub._root_url.clone()
9869                    + "resumable/upload/gmail/v1/users/{userId}/messages/import",
9870                "resumable",
9871            )
9872        } else if protocol == common::UploadProtocol::Simple {
9873            (
9874                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/messages/import",
9875                "multipart",
9876            )
9877        } else {
9878            unreachable!()
9879        };
9880        params.push("uploadType", upload_type);
9881        if self._scopes.is_empty() {
9882            self._scopes.insert(Scope::Gmai.as_ref().to_string());
9883        }
9884
9885        #[allow(clippy::single_element_loop)]
9886        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
9887            url = params.uri_replacement(url, param_name, find_this, false);
9888        }
9889        {
9890            let to_remove = ["userId"];
9891            params.remove_params(&to_remove);
9892        }
9893
9894        let url = params.parse_with_url(&url);
9895
9896        let mut json_mime_type = mime::APPLICATION_JSON;
9897        let mut request_value_reader = {
9898            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9899            common::remove_json_null_values(&mut value);
9900            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9901            serde_json::to_writer(&mut dst, &value).unwrap();
9902            dst
9903        };
9904        let request_size = request_value_reader
9905            .seek(std::io::SeekFrom::End(0))
9906            .unwrap();
9907        request_value_reader
9908            .seek(std::io::SeekFrom::Start(0))
9909            .unwrap();
9910
9911        let mut upload_url_from_server;
9912
9913        loop {
9914            let token = match self
9915                .hub
9916                .auth
9917                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9918                .await
9919            {
9920                Ok(token) => token,
9921                Err(e) => match dlg.token(e) {
9922                    Ok(token) => token,
9923                    Err(e) => {
9924                        dlg.finished(false);
9925                        return Err(common::Error::MissingToken(e));
9926                    }
9927                },
9928            };
9929            request_value_reader
9930                .seek(std::io::SeekFrom::Start(0))
9931                .unwrap();
9932            let mut req_result = {
9933                let mut mp_reader: common::MultiPartReader = Default::default();
9934                let (mut body_reader, content_type) = match protocol {
9935                    common::UploadProtocol::Simple => {
9936                        mp_reader.reserve_exact(2);
9937                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
9938                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
9939                        if size > 52428800 {
9940                            return Err(common::Error::UploadSizeLimitExceeded(size, 52428800));
9941                        }
9942                        mp_reader
9943                            .add_part(
9944                                &mut request_value_reader,
9945                                request_size,
9946                                json_mime_type.clone(),
9947                            )
9948                            .add_part(&mut reader, size, reader_mime_type.clone());
9949                        (
9950                            &mut mp_reader as &mut (dyn std::io::Read + Send),
9951                            common::MultiPartReader::mime_type(),
9952                        )
9953                    }
9954                    _ => (
9955                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
9956                        json_mime_type.clone(),
9957                    ),
9958                };
9959                let client = &self.hub.client;
9960                dlg.pre_request();
9961                let mut req_builder = hyper::Request::builder()
9962                    .method(hyper::Method::POST)
9963                    .uri(url.as_str())
9964                    .header(USER_AGENT, self.hub._user_agent.clone());
9965
9966                if let Some(token) = token.as_ref() {
9967                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9968                }
9969
9970                upload_url_from_server = true;
9971                if protocol == common::UploadProtocol::Resumable {
9972                    req_builder = req_builder
9973                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
9974                }
9975
9976                let mut body_reader_bytes = vec![];
9977                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
9978                let request = req_builder
9979                    .header(CONTENT_TYPE, content_type.to_string())
9980                    .body(common::to_body(body_reader_bytes.into()));
9981
9982                client.request(request.unwrap()).await
9983            };
9984
9985            match req_result {
9986                Err(err) => {
9987                    if let common::Retry::After(d) = dlg.http_error(&err) {
9988                        sleep(d).await;
9989                        continue;
9990                    }
9991                    dlg.finished(false);
9992                    return Err(common::Error::HttpError(err));
9993                }
9994                Ok(res) => {
9995                    let (mut parts, body) = res.into_parts();
9996                    let mut body = common::Body::new(body);
9997                    if !parts.status.is_success() {
9998                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9999                        let error = serde_json::from_str(&common::to_string(&bytes));
10000                        let response = common::to_response(parts, bytes.into());
10001
10002                        if let common::Retry::After(d) =
10003                            dlg.http_failure(&response, error.as_ref().ok())
10004                        {
10005                            sleep(d).await;
10006                            continue;
10007                        }
10008
10009                        dlg.finished(false);
10010
10011                        return Err(match error {
10012                            Ok(value) => common::Error::BadRequest(value),
10013                            _ => common::Error::Failure(response),
10014                        });
10015                    }
10016                    if protocol == common::UploadProtocol::Resumable {
10017                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
10018                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
10019                        if size > 52428800 {
10020                            return Err(common::Error::UploadSizeLimitExceeded(size, 52428800));
10021                        }
10022                        let upload_result = {
10023                            let url_str = &parts
10024                                .headers
10025                                .get("Location")
10026                                .expect("LOCATION header is part of protocol")
10027                                .to_str()
10028                                .unwrap();
10029                            if upload_url_from_server {
10030                                dlg.store_upload_url(Some(url_str));
10031                            }
10032
10033                            common::ResumableUploadHelper {
10034                                client: &self.hub.client,
10035                                delegate: dlg,
10036                                start_at: if upload_url_from_server {
10037                                    Some(0)
10038                                } else {
10039                                    None
10040                                },
10041                                auth: &self.hub.auth,
10042                                user_agent: &self.hub._user_agent,
10043                                // TODO: Check this assumption
10044                                auth_header: format!(
10045                                    "Bearer {}",
10046                                    token
10047                                        .ok_or_else(|| common::Error::MissingToken(
10048                                            "resumable upload requires token".into()
10049                                        ))?
10050                                        .as_str()
10051                                ),
10052                                url: url_str,
10053                                reader: &mut reader,
10054                                media_type: reader_mime_type.clone(),
10055                                content_length: size,
10056                            }
10057                            .upload()
10058                            .await
10059                        };
10060                        match upload_result {
10061                            None => {
10062                                dlg.finished(false);
10063                                return Err(common::Error::Cancelled);
10064                            }
10065                            Some(Err(err)) => {
10066                                dlg.finished(false);
10067                                return Err(common::Error::HttpError(err));
10068                            }
10069                            Some(Ok(response)) => {
10070                                (parts, body) = response.into_parts();
10071                                if !parts.status.is_success() {
10072                                    dlg.store_upload_url(None);
10073                                    dlg.finished(false);
10074                                    return Err(common::Error::Failure(
10075                                        common::Response::from_parts(parts, body),
10076                                    ));
10077                                }
10078                            }
10079                        }
10080                    }
10081                    let response = {
10082                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10083                        let encoded = common::to_string(&bytes);
10084                        match serde_json::from_str(&encoded) {
10085                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10086                            Err(error) => {
10087                                dlg.response_json_decode_error(&encoded, &error);
10088                                return Err(common::Error::JsonDecodeError(
10089                                    encoded.to_string(),
10090                                    error,
10091                                ));
10092                            }
10093                        }
10094                    };
10095
10096                    dlg.finished(true);
10097                    return Ok(response);
10098                }
10099            }
10100        }
10101    }
10102
10103    /// Upload media in a resumable fashion.
10104    /// Even if the upload fails or is interrupted, it can be resumed for a
10105    /// certain amount of time as the server maintains state temporarily.
10106    ///
10107    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
10108    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
10109    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
10110    /// `cancel_chunk_upload(...)`.
10111    ///
10112    /// * *multipart*: yes
10113    /// * *max size*: 52428800
10114    /// * *valid mime types*: 'message/*'
10115    pub async fn upload_resumable<RS>(
10116        self,
10117        resumeable_stream: RS,
10118        mime_type: mime::Mime,
10119    ) -> common::Result<(common::Response, Message)>
10120    where
10121        RS: common::ReadSeek,
10122    {
10123        self.doit(
10124            resumeable_stream,
10125            mime_type,
10126            common::UploadProtocol::Resumable,
10127        )
10128        .await
10129    }
10130    /// Upload media all at once.
10131    /// If the upload fails for whichever reason, all progress is lost.
10132    ///
10133    /// * *multipart*: yes
10134    /// * *max size*: 52428800
10135    /// * *valid mime types*: 'message/*'
10136    pub async fn upload<RS>(
10137        self,
10138        stream: RS,
10139        mime_type: mime::Mime,
10140    ) -> common::Result<(common::Response, Message)>
10141    where
10142        RS: common::ReadSeek,
10143    {
10144        self.doit(stream, mime_type, common::UploadProtocol::Simple)
10145            .await
10146    }
10147
10148    ///
10149    /// Sets the *request* property to the given value.
10150    ///
10151    /// Even though the property as already been set when instantiating this call,
10152    /// we provide this method for API completeness.
10153    pub fn request(mut self, new_value: Message) -> UserMessageImportCall<'a, C> {
10154        self._request = new_value;
10155        self
10156    }
10157    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
10158    ///
10159    /// Sets the *user id* path property to the given value.
10160    ///
10161    /// Even though the property as already been set when instantiating this call,
10162    /// we provide this method for API completeness.
10163    pub fn user_id(mut self, new_value: &str) -> UserMessageImportCall<'a, C> {
10164        self._user_id = new_value.to_string();
10165        self
10166    }
10167    /// Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.
10168    ///
10169    /// Sets the *process for calendar* query property to the given value.
10170    pub fn process_for_calendar(mut self, new_value: bool) -> UserMessageImportCall<'a, C> {
10171        self._process_for_calendar = Some(new_value);
10172        self
10173    }
10174    /// Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.
10175    ///
10176    /// Sets the *never mark spam* query property to the given value.
10177    pub fn never_mark_spam(mut self, new_value: bool) -> UserMessageImportCall<'a, C> {
10178        self._never_mark_spam = Some(new_value);
10179        self
10180    }
10181    /// Source for Gmail's internal date of the message.
10182    ///
10183    /// Sets the *internal date source* query property to the given value.
10184    pub fn internal_date_source(mut self, new_value: &str) -> UserMessageImportCall<'a, C> {
10185        self._internal_date_source = Some(new_value.to_string());
10186        self
10187    }
10188    /// Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.
10189    ///
10190    /// Sets the *deleted* query property to the given value.
10191    pub fn deleted(mut self, new_value: bool) -> UserMessageImportCall<'a, C> {
10192        self._deleted = Some(new_value);
10193        self
10194    }
10195    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10196    /// while executing the actual API request.
10197    ///
10198    /// ````text
10199    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10200    /// ````
10201    ///
10202    /// Sets the *delegate* property to the given value.
10203    pub fn delegate(
10204        mut self,
10205        new_value: &'a mut dyn common::Delegate,
10206    ) -> UserMessageImportCall<'a, C> {
10207        self._delegate = Some(new_value);
10208        self
10209    }
10210
10211    /// Set any additional parameter of the query string used in the request.
10212    /// It should be used to set parameters which are not yet available through their own
10213    /// setters.
10214    ///
10215    /// Please note that this method must not be used to set any of the known parameters
10216    /// which have their own setter method. If done anyway, the request will fail.
10217    ///
10218    /// # Additional Parameters
10219    ///
10220    /// * *$.xgafv* (query-string) - V1 error format.
10221    /// * *access_token* (query-string) - OAuth access token.
10222    /// * *alt* (query-string) - Data format for response.
10223    /// * *callback* (query-string) - JSONP
10224    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10225    /// * *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.
10226    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10227    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10228    /// * *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.
10229    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10230    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10231    pub fn param<T>(mut self, name: T, value: T) -> UserMessageImportCall<'a, C>
10232    where
10233        T: AsRef<str>,
10234    {
10235        self._additional_params
10236            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10237        self
10238    }
10239
10240    /// Identifies the authorization scope for the method you are building.
10241    ///
10242    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10243    /// [`Scope::Gmai`].
10244    ///
10245    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10246    /// tokens for more than one scope.
10247    ///
10248    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10249    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10250    /// sufficient, a read-write scope will do as well.
10251    pub fn add_scope<St>(mut self, scope: St) -> UserMessageImportCall<'a, C>
10252    where
10253        St: AsRef<str>,
10254    {
10255        self._scopes.insert(String::from(scope.as_ref()));
10256        self
10257    }
10258    /// Identifies the authorization scope(s) for the method you are building.
10259    ///
10260    /// See [`Self::add_scope()`] for details.
10261    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageImportCall<'a, C>
10262    where
10263        I: IntoIterator<Item = St>,
10264        St: AsRef<str>,
10265    {
10266        self._scopes
10267            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10268        self
10269    }
10270
10271    /// Removes all scopes, and no default scope will be used either.
10272    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10273    /// for details).
10274    pub fn clear_scopes(mut self) -> UserMessageImportCall<'a, C> {
10275        self._scopes.clear();
10276        self
10277    }
10278}
10279
10280/// Directly inserts a message into only this user's mailbox similar to `IMAP APPEND`, bypassing most scanning and classification. Does not send a message.
10281///
10282/// A builder for the *messages.insert* method supported by a *user* resource.
10283/// It is not used directly, but through a [`UserMethods`] instance.
10284///
10285/// # Example
10286///
10287/// Instantiate a resource method builder
10288///
10289/// ```test_harness,no_run
10290/// # extern crate hyper;
10291/// # extern crate hyper_rustls;
10292/// # extern crate google_gmail1 as gmail1;
10293/// use gmail1::api::Message;
10294/// use std::fs;
10295/// # async fn dox() {
10296/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10297///
10298/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10299/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10300/// #     .with_native_roots()
10301/// #     .unwrap()
10302/// #     .https_only()
10303/// #     .enable_http2()
10304/// #     .build();
10305///
10306/// # let executor = hyper_util::rt::TokioExecutor::new();
10307/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10308/// #     secret,
10309/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10310/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10311/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10312/// #     ),
10313/// # ).build().await.unwrap();
10314///
10315/// # let client = hyper_util::client::legacy::Client::builder(
10316/// #     hyper_util::rt::TokioExecutor::new()
10317/// # )
10318/// # .build(
10319/// #     hyper_rustls::HttpsConnectorBuilder::new()
10320/// #         .with_native_roots()
10321/// #         .unwrap()
10322/// #         .https_or_http()
10323/// #         .enable_http2()
10324/// #         .build()
10325/// # );
10326/// # let mut hub = Gmail::new(client, auth);
10327/// // As the method needs a request, you would usually fill it with the desired information
10328/// // into the respective structure. Some of the parts shown here might not be applicable !
10329/// // Values shown here are possibly random and not representative !
10330/// let mut req = Message::default();
10331///
10332/// // You can configure optional parameters by calling the respective setters at will, and
10333/// // execute the final call using `upload_resumable(...)`.
10334/// // Values shown here are possibly random and not representative !
10335/// let result = hub.users().messages_insert(req, "userId")
10336///              .internal_date_source("Lorem")
10337///              .deleted(true)
10338///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
10339/// # }
10340/// ```
10341pub struct UserMessageInsertCall<'a, C>
10342where
10343    C: 'a,
10344{
10345    hub: &'a Gmail<C>,
10346    _request: Message,
10347    _user_id: String,
10348    _internal_date_source: Option<String>,
10349    _deleted: Option<bool>,
10350    _delegate: Option<&'a mut dyn common::Delegate>,
10351    _additional_params: HashMap<String, String>,
10352    _scopes: BTreeSet<String>,
10353}
10354
10355impl<'a, C> common::CallBuilder for UserMessageInsertCall<'a, C> {}
10356
10357impl<'a, C> UserMessageInsertCall<'a, C>
10358where
10359    C: common::Connector,
10360{
10361    /// Perform the operation you have build so far.
10362    async fn doit<RS>(
10363        mut self,
10364        mut reader: RS,
10365        reader_mime_type: mime::Mime,
10366        protocol: common::UploadProtocol,
10367    ) -> common::Result<(common::Response, Message)>
10368    where
10369        RS: common::ReadSeek,
10370    {
10371        use std::borrow::Cow;
10372        use std::io::{Read, Seek};
10373
10374        use common::{url::Params, ToParts};
10375        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10376
10377        let mut dd = common::DefaultDelegate;
10378        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10379        dlg.begin(common::MethodInfo {
10380            id: "gmail.users.messages.insert",
10381            http_method: hyper::Method::POST,
10382        });
10383
10384        for &field in ["alt", "userId", "internalDateSource", "deleted"].iter() {
10385            if self._additional_params.contains_key(field) {
10386                dlg.finished(false);
10387                return Err(common::Error::FieldClash(field));
10388            }
10389        }
10390
10391        let mut params = Params::with_capacity(6 + self._additional_params.len());
10392        params.push("userId", self._user_id);
10393        if let Some(value) = self._internal_date_source.as_ref() {
10394            params.push("internalDateSource", value);
10395        }
10396        if let Some(value) = self._deleted.as_ref() {
10397            params.push("deleted", value.to_string());
10398        }
10399
10400        params.extend(self._additional_params.iter());
10401
10402        params.push("alt", "json");
10403        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
10404            (
10405                self.hub._root_url.clone() + "resumable/upload/gmail/v1/users/{userId}/messages",
10406                "resumable",
10407            )
10408        } else if protocol == common::UploadProtocol::Simple {
10409            (
10410                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/messages",
10411                "multipart",
10412            )
10413        } else {
10414            unreachable!()
10415        };
10416        params.push("uploadType", upload_type);
10417        if self._scopes.is_empty() {
10418            self._scopes.insert(Scope::Gmai.as_ref().to_string());
10419        }
10420
10421        #[allow(clippy::single_element_loop)]
10422        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
10423            url = params.uri_replacement(url, param_name, find_this, false);
10424        }
10425        {
10426            let to_remove = ["userId"];
10427            params.remove_params(&to_remove);
10428        }
10429
10430        let url = params.parse_with_url(&url);
10431
10432        let mut json_mime_type = mime::APPLICATION_JSON;
10433        let mut request_value_reader = {
10434            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10435            common::remove_json_null_values(&mut value);
10436            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10437            serde_json::to_writer(&mut dst, &value).unwrap();
10438            dst
10439        };
10440        let request_size = request_value_reader
10441            .seek(std::io::SeekFrom::End(0))
10442            .unwrap();
10443        request_value_reader
10444            .seek(std::io::SeekFrom::Start(0))
10445            .unwrap();
10446
10447        let mut upload_url_from_server;
10448
10449        loop {
10450            let token = match self
10451                .hub
10452                .auth
10453                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10454                .await
10455            {
10456                Ok(token) => token,
10457                Err(e) => match dlg.token(e) {
10458                    Ok(token) => token,
10459                    Err(e) => {
10460                        dlg.finished(false);
10461                        return Err(common::Error::MissingToken(e));
10462                    }
10463                },
10464            };
10465            request_value_reader
10466                .seek(std::io::SeekFrom::Start(0))
10467                .unwrap();
10468            let mut req_result = {
10469                let mut mp_reader: common::MultiPartReader = Default::default();
10470                let (mut body_reader, content_type) = match protocol {
10471                    common::UploadProtocol::Simple => {
10472                        mp_reader.reserve_exact(2);
10473                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
10474                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
10475                        if size > 52428800 {
10476                            return Err(common::Error::UploadSizeLimitExceeded(size, 52428800));
10477                        }
10478                        mp_reader
10479                            .add_part(
10480                                &mut request_value_reader,
10481                                request_size,
10482                                json_mime_type.clone(),
10483                            )
10484                            .add_part(&mut reader, size, reader_mime_type.clone());
10485                        (
10486                            &mut mp_reader as &mut (dyn std::io::Read + Send),
10487                            common::MultiPartReader::mime_type(),
10488                        )
10489                    }
10490                    _ => (
10491                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
10492                        json_mime_type.clone(),
10493                    ),
10494                };
10495                let client = &self.hub.client;
10496                dlg.pre_request();
10497                let mut req_builder = hyper::Request::builder()
10498                    .method(hyper::Method::POST)
10499                    .uri(url.as_str())
10500                    .header(USER_AGENT, self.hub._user_agent.clone());
10501
10502                if let Some(token) = token.as_ref() {
10503                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10504                }
10505
10506                upload_url_from_server = true;
10507                if protocol == common::UploadProtocol::Resumable {
10508                    req_builder = req_builder
10509                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
10510                }
10511
10512                let mut body_reader_bytes = vec![];
10513                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
10514                let request = req_builder
10515                    .header(CONTENT_TYPE, content_type.to_string())
10516                    .body(common::to_body(body_reader_bytes.into()));
10517
10518                client.request(request.unwrap()).await
10519            };
10520
10521            match req_result {
10522                Err(err) => {
10523                    if let common::Retry::After(d) = dlg.http_error(&err) {
10524                        sleep(d).await;
10525                        continue;
10526                    }
10527                    dlg.finished(false);
10528                    return Err(common::Error::HttpError(err));
10529                }
10530                Ok(res) => {
10531                    let (mut parts, body) = res.into_parts();
10532                    let mut body = common::Body::new(body);
10533                    if !parts.status.is_success() {
10534                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10535                        let error = serde_json::from_str(&common::to_string(&bytes));
10536                        let response = common::to_response(parts, bytes.into());
10537
10538                        if let common::Retry::After(d) =
10539                            dlg.http_failure(&response, error.as_ref().ok())
10540                        {
10541                            sleep(d).await;
10542                            continue;
10543                        }
10544
10545                        dlg.finished(false);
10546
10547                        return Err(match error {
10548                            Ok(value) => common::Error::BadRequest(value),
10549                            _ => common::Error::Failure(response),
10550                        });
10551                    }
10552                    if protocol == common::UploadProtocol::Resumable {
10553                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
10554                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
10555                        if size > 52428800 {
10556                            return Err(common::Error::UploadSizeLimitExceeded(size, 52428800));
10557                        }
10558                        let upload_result = {
10559                            let url_str = &parts
10560                                .headers
10561                                .get("Location")
10562                                .expect("LOCATION header is part of protocol")
10563                                .to_str()
10564                                .unwrap();
10565                            if upload_url_from_server {
10566                                dlg.store_upload_url(Some(url_str));
10567                            }
10568
10569                            common::ResumableUploadHelper {
10570                                client: &self.hub.client,
10571                                delegate: dlg,
10572                                start_at: if upload_url_from_server {
10573                                    Some(0)
10574                                } else {
10575                                    None
10576                                },
10577                                auth: &self.hub.auth,
10578                                user_agent: &self.hub._user_agent,
10579                                // TODO: Check this assumption
10580                                auth_header: format!(
10581                                    "Bearer {}",
10582                                    token
10583                                        .ok_or_else(|| common::Error::MissingToken(
10584                                            "resumable upload requires token".into()
10585                                        ))?
10586                                        .as_str()
10587                                ),
10588                                url: url_str,
10589                                reader: &mut reader,
10590                                media_type: reader_mime_type.clone(),
10591                                content_length: size,
10592                            }
10593                            .upload()
10594                            .await
10595                        };
10596                        match upload_result {
10597                            None => {
10598                                dlg.finished(false);
10599                                return Err(common::Error::Cancelled);
10600                            }
10601                            Some(Err(err)) => {
10602                                dlg.finished(false);
10603                                return Err(common::Error::HttpError(err));
10604                            }
10605                            Some(Ok(response)) => {
10606                                (parts, body) = response.into_parts();
10607                                if !parts.status.is_success() {
10608                                    dlg.store_upload_url(None);
10609                                    dlg.finished(false);
10610                                    return Err(common::Error::Failure(
10611                                        common::Response::from_parts(parts, body),
10612                                    ));
10613                                }
10614                            }
10615                        }
10616                    }
10617                    let response = {
10618                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10619                        let encoded = common::to_string(&bytes);
10620                        match serde_json::from_str(&encoded) {
10621                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10622                            Err(error) => {
10623                                dlg.response_json_decode_error(&encoded, &error);
10624                                return Err(common::Error::JsonDecodeError(
10625                                    encoded.to_string(),
10626                                    error,
10627                                ));
10628                            }
10629                        }
10630                    };
10631
10632                    dlg.finished(true);
10633                    return Ok(response);
10634                }
10635            }
10636        }
10637    }
10638
10639    /// Upload media in a resumable fashion.
10640    /// Even if the upload fails or is interrupted, it can be resumed for a
10641    /// certain amount of time as the server maintains state temporarily.
10642    ///
10643    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
10644    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
10645    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
10646    /// `cancel_chunk_upload(...)`.
10647    ///
10648    /// * *multipart*: yes
10649    /// * *max size*: 52428800
10650    /// * *valid mime types*: 'message/*'
10651    pub async fn upload_resumable<RS>(
10652        self,
10653        resumeable_stream: RS,
10654        mime_type: mime::Mime,
10655    ) -> common::Result<(common::Response, Message)>
10656    where
10657        RS: common::ReadSeek,
10658    {
10659        self.doit(
10660            resumeable_stream,
10661            mime_type,
10662            common::UploadProtocol::Resumable,
10663        )
10664        .await
10665    }
10666    /// Upload media all at once.
10667    /// If the upload fails for whichever reason, all progress is lost.
10668    ///
10669    /// * *multipart*: yes
10670    /// * *max size*: 52428800
10671    /// * *valid mime types*: 'message/*'
10672    pub async fn upload<RS>(
10673        self,
10674        stream: RS,
10675        mime_type: mime::Mime,
10676    ) -> common::Result<(common::Response, Message)>
10677    where
10678        RS: common::ReadSeek,
10679    {
10680        self.doit(stream, mime_type, common::UploadProtocol::Simple)
10681            .await
10682    }
10683
10684    ///
10685    /// Sets the *request* property to the given value.
10686    ///
10687    /// Even though the property as already been set when instantiating this call,
10688    /// we provide this method for API completeness.
10689    pub fn request(mut self, new_value: Message) -> UserMessageInsertCall<'a, C> {
10690        self._request = new_value;
10691        self
10692    }
10693    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
10694    ///
10695    /// Sets the *user id* path property to the given value.
10696    ///
10697    /// Even though the property as already been set when instantiating this call,
10698    /// we provide this method for API completeness.
10699    pub fn user_id(mut self, new_value: &str) -> UserMessageInsertCall<'a, C> {
10700        self._user_id = new_value.to_string();
10701        self
10702    }
10703    /// Source for Gmail's internal date of the message.
10704    ///
10705    /// Sets the *internal date source* query property to the given value.
10706    pub fn internal_date_source(mut self, new_value: &str) -> UserMessageInsertCall<'a, C> {
10707        self._internal_date_source = Some(new_value.to_string());
10708        self
10709    }
10710    /// Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.
10711    ///
10712    /// Sets the *deleted* query property to the given value.
10713    pub fn deleted(mut self, new_value: bool) -> UserMessageInsertCall<'a, C> {
10714        self._deleted = Some(new_value);
10715        self
10716    }
10717    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10718    /// while executing the actual API request.
10719    ///
10720    /// ````text
10721    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10722    /// ````
10723    ///
10724    /// Sets the *delegate* property to the given value.
10725    pub fn delegate(
10726        mut self,
10727        new_value: &'a mut dyn common::Delegate,
10728    ) -> UserMessageInsertCall<'a, C> {
10729        self._delegate = Some(new_value);
10730        self
10731    }
10732
10733    /// Set any additional parameter of the query string used in the request.
10734    /// It should be used to set parameters which are not yet available through their own
10735    /// setters.
10736    ///
10737    /// Please note that this method must not be used to set any of the known parameters
10738    /// which have their own setter method. If done anyway, the request will fail.
10739    ///
10740    /// # Additional Parameters
10741    ///
10742    /// * *$.xgafv* (query-string) - V1 error format.
10743    /// * *access_token* (query-string) - OAuth access token.
10744    /// * *alt* (query-string) - Data format for response.
10745    /// * *callback* (query-string) - JSONP
10746    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10747    /// * *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.
10748    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10749    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10750    /// * *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.
10751    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10752    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10753    pub fn param<T>(mut self, name: T, value: T) -> UserMessageInsertCall<'a, C>
10754    where
10755        T: AsRef<str>,
10756    {
10757        self._additional_params
10758            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10759        self
10760    }
10761
10762    /// Identifies the authorization scope for the method you are building.
10763    ///
10764    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10765    /// [`Scope::Gmai`].
10766    ///
10767    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10768    /// tokens for more than one scope.
10769    ///
10770    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10771    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10772    /// sufficient, a read-write scope will do as well.
10773    pub fn add_scope<St>(mut self, scope: St) -> UserMessageInsertCall<'a, C>
10774    where
10775        St: AsRef<str>,
10776    {
10777        self._scopes.insert(String::from(scope.as_ref()));
10778        self
10779    }
10780    /// Identifies the authorization scope(s) for the method you are building.
10781    ///
10782    /// See [`Self::add_scope()`] for details.
10783    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageInsertCall<'a, C>
10784    where
10785        I: IntoIterator<Item = St>,
10786        St: AsRef<str>,
10787    {
10788        self._scopes
10789            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10790        self
10791    }
10792
10793    /// Removes all scopes, and no default scope will be used either.
10794    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10795    /// for details).
10796    pub fn clear_scopes(mut self) -> UserMessageInsertCall<'a, C> {
10797        self._scopes.clear();
10798        self
10799    }
10800}
10801
10802/// Lists the messages in the user's mailbox. For example usage, see [List Gmail messages](https://developers.google.com/workspace/gmail/api/guides/list-messages).
10803///
10804/// A builder for the *messages.list* method supported by a *user* resource.
10805/// It is not used directly, but through a [`UserMethods`] instance.
10806///
10807/// # Example
10808///
10809/// Instantiate a resource method builder
10810///
10811/// ```test_harness,no_run
10812/// # extern crate hyper;
10813/// # extern crate hyper_rustls;
10814/// # extern crate google_gmail1 as gmail1;
10815/// # async fn dox() {
10816/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10817///
10818/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10819/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10820/// #     .with_native_roots()
10821/// #     .unwrap()
10822/// #     .https_only()
10823/// #     .enable_http2()
10824/// #     .build();
10825///
10826/// # let executor = hyper_util::rt::TokioExecutor::new();
10827/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10828/// #     secret,
10829/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10830/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10831/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10832/// #     ),
10833/// # ).build().await.unwrap();
10834///
10835/// # let client = hyper_util::client::legacy::Client::builder(
10836/// #     hyper_util::rt::TokioExecutor::new()
10837/// # )
10838/// # .build(
10839/// #     hyper_rustls::HttpsConnectorBuilder::new()
10840/// #         .with_native_roots()
10841/// #         .unwrap()
10842/// #         .https_or_http()
10843/// #         .enable_http2()
10844/// #         .build()
10845/// # );
10846/// # let mut hub = Gmail::new(client, auth);
10847/// // You can configure optional parameters by calling the respective setters at will, and
10848/// // execute the final call using `doit()`.
10849/// // Values shown here are possibly random and not representative !
10850/// let result = hub.users().messages_list("userId")
10851///              .q("accusam")
10852///              .page_token("takimata")
10853///              .max_results(55)
10854///              .add_label_ids("voluptua.")
10855///              .include_spam_trash(false)
10856///              .doit().await;
10857/// # }
10858/// ```
10859pub struct UserMessageListCall<'a, C>
10860where
10861    C: 'a,
10862{
10863    hub: &'a Gmail<C>,
10864    _user_id: String,
10865    _q: Option<String>,
10866    _page_token: Option<String>,
10867    _max_results: Option<u32>,
10868    _label_ids: Vec<String>,
10869    _include_spam_trash: Option<bool>,
10870    _delegate: Option<&'a mut dyn common::Delegate>,
10871    _additional_params: HashMap<String, String>,
10872    _scopes: BTreeSet<String>,
10873}
10874
10875impl<'a, C> common::CallBuilder for UserMessageListCall<'a, C> {}
10876
10877impl<'a, C> UserMessageListCall<'a, C>
10878where
10879    C: common::Connector,
10880{
10881    /// Perform the operation you have build so far.
10882    pub async fn doit(mut self) -> common::Result<(common::Response, ListMessagesResponse)> {
10883        use std::borrow::Cow;
10884        use std::io::{Read, Seek};
10885
10886        use common::{url::Params, ToParts};
10887        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10888
10889        let mut dd = common::DefaultDelegate;
10890        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10891        dlg.begin(common::MethodInfo {
10892            id: "gmail.users.messages.list",
10893            http_method: hyper::Method::GET,
10894        });
10895
10896        for &field in [
10897            "alt",
10898            "userId",
10899            "q",
10900            "pageToken",
10901            "maxResults",
10902            "labelIds",
10903            "includeSpamTrash",
10904        ]
10905        .iter()
10906        {
10907            if self._additional_params.contains_key(field) {
10908                dlg.finished(false);
10909                return Err(common::Error::FieldClash(field));
10910            }
10911        }
10912
10913        let mut params = Params::with_capacity(8 + self._additional_params.len());
10914        params.push("userId", self._user_id);
10915        if let Some(value) = self._q.as_ref() {
10916            params.push("q", value);
10917        }
10918        if let Some(value) = self._page_token.as_ref() {
10919            params.push("pageToken", value);
10920        }
10921        if let Some(value) = self._max_results.as_ref() {
10922            params.push("maxResults", value.to_string());
10923        }
10924        if !self._label_ids.is_empty() {
10925            for f in self._label_ids.iter() {
10926                params.push("labelIds", f);
10927            }
10928        }
10929        if let Some(value) = self._include_spam_trash.as_ref() {
10930            params.push("includeSpamTrash", value.to_string());
10931        }
10932
10933        params.extend(self._additional_params.iter());
10934
10935        params.push("alt", "json");
10936        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages";
10937        if self._scopes.is_empty() {
10938            self._scopes.insert(Scope::Readonly.as_ref().to_string());
10939        }
10940
10941        #[allow(clippy::single_element_loop)]
10942        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
10943            url = params.uri_replacement(url, param_name, find_this, false);
10944        }
10945        {
10946            let to_remove = ["userId"];
10947            params.remove_params(&to_remove);
10948        }
10949
10950        let url = params.parse_with_url(&url);
10951
10952        loop {
10953            let token = match self
10954                .hub
10955                .auth
10956                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10957                .await
10958            {
10959                Ok(token) => token,
10960                Err(e) => match dlg.token(e) {
10961                    Ok(token) => token,
10962                    Err(e) => {
10963                        dlg.finished(false);
10964                        return Err(common::Error::MissingToken(e));
10965                    }
10966                },
10967            };
10968            let mut req_result = {
10969                let client = &self.hub.client;
10970                dlg.pre_request();
10971                let mut req_builder = hyper::Request::builder()
10972                    .method(hyper::Method::GET)
10973                    .uri(url.as_str())
10974                    .header(USER_AGENT, self.hub._user_agent.clone());
10975
10976                if let Some(token) = token.as_ref() {
10977                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10978                }
10979
10980                let request = req_builder
10981                    .header(CONTENT_LENGTH, 0_u64)
10982                    .body(common::to_body::<String>(None));
10983
10984                client.request(request.unwrap()).await
10985            };
10986
10987            match req_result {
10988                Err(err) => {
10989                    if let common::Retry::After(d) = dlg.http_error(&err) {
10990                        sleep(d).await;
10991                        continue;
10992                    }
10993                    dlg.finished(false);
10994                    return Err(common::Error::HttpError(err));
10995                }
10996                Ok(res) => {
10997                    let (mut parts, body) = res.into_parts();
10998                    let mut body = common::Body::new(body);
10999                    if !parts.status.is_success() {
11000                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11001                        let error = serde_json::from_str(&common::to_string(&bytes));
11002                        let response = common::to_response(parts, bytes.into());
11003
11004                        if let common::Retry::After(d) =
11005                            dlg.http_failure(&response, error.as_ref().ok())
11006                        {
11007                            sleep(d).await;
11008                            continue;
11009                        }
11010
11011                        dlg.finished(false);
11012
11013                        return Err(match error {
11014                            Ok(value) => common::Error::BadRequest(value),
11015                            _ => common::Error::Failure(response),
11016                        });
11017                    }
11018                    let response = {
11019                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11020                        let encoded = common::to_string(&bytes);
11021                        match serde_json::from_str(&encoded) {
11022                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11023                            Err(error) => {
11024                                dlg.response_json_decode_error(&encoded, &error);
11025                                return Err(common::Error::JsonDecodeError(
11026                                    encoded.to_string(),
11027                                    error,
11028                                ));
11029                            }
11030                        }
11031                    };
11032
11033                    dlg.finished(true);
11034                    return Ok(response);
11035                }
11036            }
11037        }
11038    }
11039
11040    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
11041    ///
11042    /// Sets the *user id* path property to the given value.
11043    ///
11044    /// Even though the property as already been set when instantiating this call,
11045    /// we provide this method for API completeness.
11046    pub fn user_id(mut self, new_value: &str) -> UserMessageListCall<'a, C> {
11047        self._user_id = new_value.to_string();
11048        self
11049    }
11050    /// Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, `"from:someuser@example.com rfc822msgid: is:unread"`. Parameter cannot be used when accessing the api using the gmail.metadata scope.
11051    ///
11052    /// Sets the *q* query property to the given value.
11053    pub fn q(mut self, new_value: &str) -> UserMessageListCall<'a, C> {
11054        self._q = Some(new_value.to_string());
11055        self
11056    }
11057    /// Page token to retrieve a specific page of results in the list.
11058    ///
11059    /// Sets the *page token* query property to the given value.
11060    pub fn page_token(mut self, new_value: &str) -> UserMessageListCall<'a, C> {
11061        self._page_token = Some(new_value.to_string());
11062        self
11063    }
11064    /// Maximum number of messages to return. This field defaults to 100. The maximum allowed value for this field is 500.
11065    ///
11066    /// Sets the *max results* query property to the given value.
11067    pub fn max_results(mut self, new_value: u32) -> UserMessageListCall<'a, C> {
11068        self._max_results = Some(new_value);
11069        self
11070    }
11071    /// Only return messages with labels that match all of the specified label IDs. Messages in a thread might have labels that other messages in the same thread don't have. To learn more, see [Manage labels on messages and threads](https://developers.google.com/workspace/gmail/api/guides/labels#manage_labels_on_messages_threads).
11072    ///
11073    /// Append the given value to the *label ids* query property.
11074    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11075    pub fn add_label_ids(mut self, new_value: &str) -> UserMessageListCall<'a, C> {
11076        self._label_ids.push(new_value.to_string());
11077        self
11078    }
11079    /// Include messages from `SPAM` and `TRASH` in the results.
11080    ///
11081    /// Sets the *include spam trash* query property to the given value.
11082    pub fn include_spam_trash(mut self, new_value: bool) -> UserMessageListCall<'a, C> {
11083        self._include_spam_trash = Some(new_value);
11084        self
11085    }
11086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11087    /// while executing the actual API request.
11088    ///
11089    /// ````text
11090    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11091    /// ````
11092    ///
11093    /// Sets the *delegate* property to the given value.
11094    pub fn delegate(
11095        mut self,
11096        new_value: &'a mut dyn common::Delegate,
11097    ) -> UserMessageListCall<'a, C> {
11098        self._delegate = Some(new_value);
11099        self
11100    }
11101
11102    /// Set any additional parameter of the query string used in the request.
11103    /// It should be used to set parameters which are not yet available through their own
11104    /// setters.
11105    ///
11106    /// Please note that this method must not be used to set any of the known parameters
11107    /// which have their own setter method. If done anyway, the request will fail.
11108    ///
11109    /// # Additional Parameters
11110    ///
11111    /// * *$.xgafv* (query-string) - V1 error format.
11112    /// * *access_token* (query-string) - OAuth access token.
11113    /// * *alt* (query-string) - Data format for response.
11114    /// * *callback* (query-string) - JSONP
11115    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11116    /// * *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.
11117    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11118    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11119    /// * *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.
11120    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11121    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11122    pub fn param<T>(mut self, name: T, value: T) -> UserMessageListCall<'a, C>
11123    where
11124        T: AsRef<str>,
11125    {
11126        self._additional_params
11127            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11128        self
11129    }
11130
11131    /// Identifies the authorization scope for the method you are building.
11132    ///
11133    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11134    /// [`Scope::Readonly`].
11135    ///
11136    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11137    /// tokens for more than one scope.
11138    ///
11139    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11140    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11141    /// sufficient, a read-write scope will do as well.
11142    pub fn add_scope<St>(mut self, scope: St) -> UserMessageListCall<'a, C>
11143    where
11144        St: AsRef<str>,
11145    {
11146        self._scopes.insert(String::from(scope.as_ref()));
11147        self
11148    }
11149    /// Identifies the authorization scope(s) for the method you are building.
11150    ///
11151    /// See [`Self::add_scope()`] for details.
11152    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageListCall<'a, C>
11153    where
11154        I: IntoIterator<Item = St>,
11155        St: AsRef<str>,
11156    {
11157        self._scopes
11158            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11159        self
11160    }
11161
11162    /// Removes all scopes, and no default scope will be used either.
11163    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11164    /// for details).
11165    pub fn clear_scopes(mut self) -> UserMessageListCall<'a, C> {
11166        self._scopes.clear();
11167        self
11168    }
11169}
11170
11171/// Modifies the labels on the specified message.
11172///
11173/// A builder for the *messages.modify* method supported by a *user* resource.
11174/// It is not used directly, but through a [`UserMethods`] instance.
11175///
11176/// # Example
11177///
11178/// Instantiate a resource method builder
11179///
11180/// ```test_harness,no_run
11181/// # extern crate hyper;
11182/// # extern crate hyper_rustls;
11183/// # extern crate google_gmail1 as gmail1;
11184/// use gmail1::api::ModifyMessageRequest;
11185/// # async fn dox() {
11186/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11187///
11188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11189/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11190/// #     .with_native_roots()
11191/// #     .unwrap()
11192/// #     .https_only()
11193/// #     .enable_http2()
11194/// #     .build();
11195///
11196/// # let executor = hyper_util::rt::TokioExecutor::new();
11197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11198/// #     secret,
11199/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11200/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11201/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11202/// #     ),
11203/// # ).build().await.unwrap();
11204///
11205/// # let client = hyper_util::client::legacy::Client::builder(
11206/// #     hyper_util::rt::TokioExecutor::new()
11207/// # )
11208/// # .build(
11209/// #     hyper_rustls::HttpsConnectorBuilder::new()
11210/// #         .with_native_roots()
11211/// #         .unwrap()
11212/// #         .https_or_http()
11213/// #         .enable_http2()
11214/// #         .build()
11215/// # );
11216/// # let mut hub = Gmail::new(client, auth);
11217/// // As the method needs a request, you would usually fill it with the desired information
11218/// // into the respective structure. Some of the parts shown here might not be applicable !
11219/// // Values shown here are possibly random and not representative !
11220/// let mut req = ModifyMessageRequest::default();
11221///
11222/// // You can configure optional parameters by calling the respective setters at will, and
11223/// // execute the final call using `doit()`.
11224/// // Values shown here are possibly random and not representative !
11225/// let result = hub.users().messages_modify(req, "userId", "id")
11226///              .doit().await;
11227/// # }
11228/// ```
11229pub struct UserMessageModifyCall<'a, C>
11230where
11231    C: 'a,
11232{
11233    hub: &'a Gmail<C>,
11234    _request: ModifyMessageRequest,
11235    _user_id: String,
11236    _id: String,
11237    _delegate: Option<&'a mut dyn common::Delegate>,
11238    _additional_params: HashMap<String, String>,
11239    _scopes: BTreeSet<String>,
11240}
11241
11242impl<'a, C> common::CallBuilder for UserMessageModifyCall<'a, C> {}
11243
11244impl<'a, C> UserMessageModifyCall<'a, C>
11245where
11246    C: common::Connector,
11247{
11248    /// Perform the operation you have build so far.
11249    pub async fn doit(mut self) -> common::Result<(common::Response, Message)> {
11250        use std::borrow::Cow;
11251        use std::io::{Read, Seek};
11252
11253        use common::{url::Params, ToParts};
11254        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11255
11256        let mut dd = common::DefaultDelegate;
11257        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11258        dlg.begin(common::MethodInfo {
11259            id: "gmail.users.messages.modify",
11260            http_method: hyper::Method::POST,
11261        });
11262
11263        for &field in ["alt", "userId", "id"].iter() {
11264            if self._additional_params.contains_key(field) {
11265                dlg.finished(false);
11266                return Err(common::Error::FieldClash(field));
11267            }
11268        }
11269
11270        let mut params = Params::with_capacity(5 + self._additional_params.len());
11271        params.push("userId", self._user_id);
11272        params.push("id", self._id);
11273
11274        params.extend(self._additional_params.iter());
11275
11276        params.push("alt", "json");
11277        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/{id}/modify";
11278        if self._scopes.is_empty() {
11279            self._scopes.insert(Scope::Gmai.as_ref().to_string());
11280        }
11281
11282        #[allow(clippy::single_element_loop)]
11283        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
11284            url = params.uri_replacement(url, param_name, find_this, false);
11285        }
11286        {
11287            let to_remove = ["id", "userId"];
11288            params.remove_params(&to_remove);
11289        }
11290
11291        let url = params.parse_with_url(&url);
11292
11293        let mut json_mime_type = mime::APPLICATION_JSON;
11294        let mut request_value_reader = {
11295            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11296            common::remove_json_null_values(&mut value);
11297            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11298            serde_json::to_writer(&mut dst, &value).unwrap();
11299            dst
11300        };
11301        let request_size = request_value_reader
11302            .seek(std::io::SeekFrom::End(0))
11303            .unwrap();
11304        request_value_reader
11305            .seek(std::io::SeekFrom::Start(0))
11306            .unwrap();
11307
11308        loop {
11309            let token = match self
11310                .hub
11311                .auth
11312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11313                .await
11314            {
11315                Ok(token) => token,
11316                Err(e) => match dlg.token(e) {
11317                    Ok(token) => token,
11318                    Err(e) => {
11319                        dlg.finished(false);
11320                        return Err(common::Error::MissingToken(e));
11321                    }
11322                },
11323            };
11324            request_value_reader
11325                .seek(std::io::SeekFrom::Start(0))
11326                .unwrap();
11327            let mut req_result = {
11328                let client = &self.hub.client;
11329                dlg.pre_request();
11330                let mut req_builder = hyper::Request::builder()
11331                    .method(hyper::Method::POST)
11332                    .uri(url.as_str())
11333                    .header(USER_AGENT, self.hub._user_agent.clone());
11334
11335                if let Some(token) = token.as_ref() {
11336                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11337                }
11338
11339                let request = req_builder
11340                    .header(CONTENT_TYPE, json_mime_type.to_string())
11341                    .header(CONTENT_LENGTH, request_size as u64)
11342                    .body(common::to_body(
11343                        request_value_reader.get_ref().clone().into(),
11344                    ));
11345
11346                client.request(request.unwrap()).await
11347            };
11348
11349            match req_result {
11350                Err(err) => {
11351                    if let common::Retry::After(d) = dlg.http_error(&err) {
11352                        sleep(d).await;
11353                        continue;
11354                    }
11355                    dlg.finished(false);
11356                    return Err(common::Error::HttpError(err));
11357                }
11358                Ok(res) => {
11359                    let (mut parts, body) = res.into_parts();
11360                    let mut body = common::Body::new(body);
11361                    if !parts.status.is_success() {
11362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11363                        let error = serde_json::from_str(&common::to_string(&bytes));
11364                        let response = common::to_response(parts, bytes.into());
11365
11366                        if let common::Retry::After(d) =
11367                            dlg.http_failure(&response, error.as_ref().ok())
11368                        {
11369                            sleep(d).await;
11370                            continue;
11371                        }
11372
11373                        dlg.finished(false);
11374
11375                        return Err(match error {
11376                            Ok(value) => common::Error::BadRequest(value),
11377                            _ => common::Error::Failure(response),
11378                        });
11379                    }
11380                    let response = {
11381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11382                        let encoded = common::to_string(&bytes);
11383                        match serde_json::from_str(&encoded) {
11384                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11385                            Err(error) => {
11386                                dlg.response_json_decode_error(&encoded, &error);
11387                                return Err(common::Error::JsonDecodeError(
11388                                    encoded.to_string(),
11389                                    error,
11390                                ));
11391                            }
11392                        }
11393                    };
11394
11395                    dlg.finished(true);
11396                    return Ok(response);
11397                }
11398            }
11399        }
11400    }
11401
11402    ///
11403    /// Sets the *request* property to the given value.
11404    ///
11405    /// Even though the property as already been set when instantiating this call,
11406    /// we provide this method for API completeness.
11407    pub fn request(mut self, new_value: ModifyMessageRequest) -> UserMessageModifyCall<'a, C> {
11408        self._request = new_value;
11409        self
11410    }
11411    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
11412    ///
11413    /// Sets the *user id* path property to the given value.
11414    ///
11415    /// Even though the property as already been set when instantiating this call,
11416    /// we provide this method for API completeness.
11417    pub fn user_id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C> {
11418        self._user_id = new_value.to_string();
11419        self
11420    }
11421    /// The ID of the message to modify.
11422    ///
11423    /// Sets the *id* path property to the given value.
11424    ///
11425    /// Even though the property as already been set when instantiating this call,
11426    /// we provide this method for API completeness.
11427    pub fn id(mut self, new_value: &str) -> UserMessageModifyCall<'a, C> {
11428        self._id = new_value.to_string();
11429        self
11430    }
11431    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11432    /// while executing the actual API request.
11433    ///
11434    /// ````text
11435    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11436    /// ````
11437    ///
11438    /// Sets the *delegate* property to the given value.
11439    pub fn delegate(
11440        mut self,
11441        new_value: &'a mut dyn common::Delegate,
11442    ) -> UserMessageModifyCall<'a, C> {
11443        self._delegate = Some(new_value);
11444        self
11445    }
11446
11447    /// Set any additional parameter of the query string used in the request.
11448    /// It should be used to set parameters which are not yet available through their own
11449    /// setters.
11450    ///
11451    /// Please note that this method must not be used to set any of the known parameters
11452    /// which have their own setter method. If done anyway, the request will fail.
11453    ///
11454    /// # Additional Parameters
11455    ///
11456    /// * *$.xgafv* (query-string) - V1 error format.
11457    /// * *access_token* (query-string) - OAuth access token.
11458    /// * *alt* (query-string) - Data format for response.
11459    /// * *callback* (query-string) - JSONP
11460    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11461    /// * *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.
11462    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11463    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11464    /// * *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.
11465    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11466    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11467    pub fn param<T>(mut self, name: T, value: T) -> UserMessageModifyCall<'a, C>
11468    where
11469        T: AsRef<str>,
11470    {
11471        self._additional_params
11472            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11473        self
11474    }
11475
11476    /// Identifies the authorization scope for the method you are building.
11477    ///
11478    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11479    /// [`Scope::Gmai`].
11480    ///
11481    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11482    /// tokens for more than one scope.
11483    ///
11484    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11485    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11486    /// sufficient, a read-write scope will do as well.
11487    pub fn add_scope<St>(mut self, scope: St) -> UserMessageModifyCall<'a, C>
11488    where
11489        St: AsRef<str>,
11490    {
11491        self._scopes.insert(String::from(scope.as_ref()));
11492        self
11493    }
11494    /// Identifies the authorization scope(s) for the method you are building.
11495    ///
11496    /// See [`Self::add_scope()`] for details.
11497    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageModifyCall<'a, C>
11498    where
11499        I: IntoIterator<Item = St>,
11500        St: AsRef<str>,
11501    {
11502        self._scopes
11503            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11504        self
11505    }
11506
11507    /// Removes all scopes, and no default scope will be used either.
11508    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11509    /// for details).
11510    pub fn clear_scopes(mut self) -> UserMessageModifyCall<'a, C> {
11511        self._scopes.clear();
11512        self
11513    }
11514}
11515
11516/// Sends the specified message to the recipients in the `To`, `Cc`, and `Bcc` headers. For example usage, see [Sending email](https://developers.google.com/workspace/gmail/api/guides/sending).
11517///
11518/// A builder for the *messages.send* method supported by a *user* resource.
11519/// It is not used directly, but through a [`UserMethods`] instance.
11520///
11521/// # Example
11522///
11523/// Instantiate a resource method builder
11524///
11525/// ```test_harness,no_run
11526/// # extern crate hyper;
11527/// # extern crate hyper_rustls;
11528/// # extern crate google_gmail1 as gmail1;
11529/// use gmail1::api::Message;
11530/// use std::fs;
11531/// # async fn dox() {
11532/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11533///
11534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11536/// #     .with_native_roots()
11537/// #     .unwrap()
11538/// #     .https_only()
11539/// #     .enable_http2()
11540/// #     .build();
11541///
11542/// # let executor = hyper_util::rt::TokioExecutor::new();
11543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11544/// #     secret,
11545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11546/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11547/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11548/// #     ),
11549/// # ).build().await.unwrap();
11550///
11551/// # let client = hyper_util::client::legacy::Client::builder(
11552/// #     hyper_util::rt::TokioExecutor::new()
11553/// # )
11554/// # .build(
11555/// #     hyper_rustls::HttpsConnectorBuilder::new()
11556/// #         .with_native_roots()
11557/// #         .unwrap()
11558/// #         .https_or_http()
11559/// #         .enable_http2()
11560/// #         .build()
11561/// # );
11562/// # let mut hub = Gmail::new(client, auth);
11563/// // As the method needs a request, you would usually fill it with the desired information
11564/// // into the respective structure. Some of the parts shown here might not be applicable !
11565/// // Values shown here are possibly random and not representative !
11566/// let mut req = Message::default();
11567///
11568/// // You can configure optional parameters by calling the respective setters at will, and
11569/// // execute the final call using `upload_resumable(...)`.
11570/// // Values shown here are possibly random and not representative !
11571/// let result = hub.users().messages_send(req, "userId")
11572///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
11573/// # }
11574/// ```
11575pub struct UserMessageSendCall<'a, C>
11576where
11577    C: 'a,
11578{
11579    hub: &'a Gmail<C>,
11580    _request: Message,
11581    _user_id: String,
11582    _delegate: Option<&'a mut dyn common::Delegate>,
11583    _additional_params: HashMap<String, String>,
11584    _scopes: BTreeSet<String>,
11585}
11586
11587impl<'a, C> common::CallBuilder for UserMessageSendCall<'a, C> {}
11588
11589impl<'a, C> UserMessageSendCall<'a, C>
11590where
11591    C: common::Connector,
11592{
11593    /// Perform the operation you have build so far.
11594    async fn doit<RS>(
11595        mut self,
11596        mut reader: RS,
11597        reader_mime_type: mime::Mime,
11598        protocol: common::UploadProtocol,
11599    ) -> common::Result<(common::Response, Message)>
11600    where
11601        RS: common::ReadSeek,
11602    {
11603        use std::borrow::Cow;
11604        use std::io::{Read, Seek};
11605
11606        use common::{url::Params, ToParts};
11607        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11608
11609        let mut dd = common::DefaultDelegate;
11610        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11611        dlg.begin(common::MethodInfo {
11612            id: "gmail.users.messages.send",
11613            http_method: hyper::Method::POST,
11614        });
11615
11616        for &field in ["alt", "userId"].iter() {
11617            if self._additional_params.contains_key(field) {
11618                dlg.finished(false);
11619                return Err(common::Error::FieldClash(field));
11620            }
11621        }
11622
11623        let mut params = Params::with_capacity(4 + self._additional_params.len());
11624        params.push("userId", self._user_id);
11625
11626        params.extend(self._additional_params.iter());
11627
11628        params.push("alt", "json");
11629        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
11630            (
11631                self.hub._root_url.clone()
11632                    + "resumable/upload/gmail/v1/users/{userId}/messages/send",
11633                "resumable",
11634            )
11635        } else if protocol == common::UploadProtocol::Simple {
11636            (
11637                self.hub._root_url.clone() + "upload/gmail/v1/users/{userId}/messages/send",
11638                "multipart",
11639            )
11640        } else {
11641            unreachable!()
11642        };
11643        params.push("uploadType", upload_type);
11644        if self._scopes.is_empty() {
11645            self._scopes.insert(Scope::Gmai.as_ref().to_string());
11646        }
11647
11648        #[allow(clippy::single_element_loop)]
11649        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
11650            url = params.uri_replacement(url, param_name, find_this, false);
11651        }
11652        {
11653            let to_remove = ["userId"];
11654            params.remove_params(&to_remove);
11655        }
11656
11657        let url = params.parse_with_url(&url);
11658
11659        let mut json_mime_type = mime::APPLICATION_JSON;
11660        let mut request_value_reader = {
11661            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11662            common::remove_json_null_values(&mut value);
11663            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11664            serde_json::to_writer(&mut dst, &value).unwrap();
11665            dst
11666        };
11667        let request_size = request_value_reader
11668            .seek(std::io::SeekFrom::End(0))
11669            .unwrap();
11670        request_value_reader
11671            .seek(std::io::SeekFrom::Start(0))
11672            .unwrap();
11673
11674        let mut upload_url_from_server;
11675
11676        loop {
11677            let token = match self
11678                .hub
11679                .auth
11680                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11681                .await
11682            {
11683                Ok(token) => token,
11684                Err(e) => match dlg.token(e) {
11685                    Ok(token) => token,
11686                    Err(e) => {
11687                        dlg.finished(false);
11688                        return Err(common::Error::MissingToken(e));
11689                    }
11690                },
11691            };
11692            request_value_reader
11693                .seek(std::io::SeekFrom::Start(0))
11694                .unwrap();
11695            let mut req_result = {
11696                let mut mp_reader: common::MultiPartReader = Default::default();
11697                let (mut body_reader, content_type) = match protocol {
11698                    common::UploadProtocol::Simple => {
11699                        mp_reader.reserve_exact(2);
11700                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
11701                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
11702                        if size > 36700160 {
11703                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
11704                        }
11705                        mp_reader
11706                            .add_part(
11707                                &mut request_value_reader,
11708                                request_size,
11709                                json_mime_type.clone(),
11710                            )
11711                            .add_part(&mut reader, size, reader_mime_type.clone());
11712                        (
11713                            &mut mp_reader as &mut (dyn std::io::Read + Send),
11714                            common::MultiPartReader::mime_type(),
11715                        )
11716                    }
11717                    _ => (
11718                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
11719                        json_mime_type.clone(),
11720                    ),
11721                };
11722                let client = &self.hub.client;
11723                dlg.pre_request();
11724                let mut req_builder = hyper::Request::builder()
11725                    .method(hyper::Method::POST)
11726                    .uri(url.as_str())
11727                    .header(USER_AGENT, self.hub._user_agent.clone());
11728
11729                if let Some(token) = token.as_ref() {
11730                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11731                }
11732
11733                upload_url_from_server = true;
11734                if protocol == common::UploadProtocol::Resumable {
11735                    req_builder = req_builder
11736                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
11737                }
11738
11739                let mut body_reader_bytes = vec![];
11740                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
11741                let request = req_builder
11742                    .header(CONTENT_TYPE, content_type.to_string())
11743                    .body(common::to_body(body_reader_bytes.into()));
11744
11745                client.request(request.unwrap()).await
11746            };
11747
11748            match req_result {
11749                Err(err) => {
11750                    if let common::Retry::After(d) = dlg.http_error(&err) {
11751                        sleep(d).await;
11752                        continue;
11753                    }
11754                    dlg.finished(false);
11755                    return Err(common::Error::HttpError(err));
11756                }
11757                Ok(res) => {
11758                    let (mut parts, body) = res.into_parts();
11759                    let mut body = common::Body::new(body);
11760                    if !parts.status.is_success() {
11761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11762                        let error = serde_json::from_str(&common::to_string(&bytes));
11763                        let response = common::to_response(parts, bytes.into());
11764
11765                        if let common::Retry::After(d) =
11766                            dlg.http_failure(&response, error.as_ref().ok())
11767                        {
11768                            sleep(d).await;
11769                            continue;
11770                        }
11771
11772                        dlg.finished(false);
11773
11774                        return Err(match error {
11775                            Ok(value) => common::Error::BadRequest(value),
11776                            _ => common::Error::Failure(response),
11777                        });
11778                    }
11779                    if protocol == common::UploadProtocol::Resumable {
11780                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
11781                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
11782                        if size > 36700160 {
11783                            return Err(common::Error::UploadSizeLimitExceeded(size, 36700160));
11784                        }
11785                        let upload_result = {
11786                            let url_str = &parts
11787                                .headers
11788                                .get("Location")
11789                                .expect("LOCATION header is part of protocol")
11790                                .to_str()
11791                                .unwrap();
11792                            if upload_url_from_server {
11793                                dlg.store_upload_url(Some(url_str));
11794                            }
11795
11796                            common::ResumableUploadHelper {
11797                                client: &self.hub.client,
11798                                delegate: dlg,
11799                                start_at: if upload_url_from_server {
11800                                    Some(0)
11801                                } else {
11802                                    None
11803                                },
11804                                auth: &self.hub.auth,
11805                                user_agent: &self.hub._user_agent,
11806                                // TODO: Check this assumption
11807                                auth_header: format!(
11808                                    "Bearer {}",
11809                                    token
11810                                        .ok_or_else(|| common::Error::MissingToken(
11811                                            "resumable upload requires token".into()
11812                                        ))?
11813                                        .as_str()
11814                                ),
11815                                url: url_str,
11816                                reader: &mut reader,
11817                                media_type: reader_mime_type.clone(),
11818                                content_length: size,
11819                            }
11820                            .upload()
11821                            .await
11822                        };
11823                        match upload_result {
11824                            None => {
11825                                dlg.finished(false);
11826                                return Err(common::Error::Cancelled);
11827                            }
11828                            Some(Err(err)) => {
11829                                dlg.finished(false);
11830                                return Err(common::Error::HttpError(err));
11831                            }
11832                            Some(Ok(response)) => {
11833                                (parts, body) = response.into_parts();
11834                                if !parts.status.is_success() {
11835                                    dlg.store_upload_url(None);
11836                                    dlg.finished(false);
11837                                    return Err(common::Error::Failure(
11838                                        common::Response::from_parts(parts, body),
11839                                    ));
11840                                }
11841                            }
11842                        }
11843                    }
11844                    let response = {
11845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11846                        let encoded = common::to_string(&bytes);
11847                        match serde_json::from_str(&encoded) {
11848                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11849                            Err(error) => {
11850                                dlg.response_json_decode_error(&encoded, &error);
11851                                return Err(common::Error::JsonDecodeError(
11852                                    encoded.to_string(),
11853                                    error,
11854                                ));
11855                            }
11856                        }
11857                    };
11858
11859                    dlg.finished(true);
11860                    return Ok(response);
11861                }
11862            }
11863        }
11864    }
11865
11866    /// Upload media in a resumable fashion.
11867    /// Even if the upload fails or is interrupted, it can be resumed for a
11868    /// certain amount of time as the server maintains state temporarily.
11869    ///
11870    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
11871    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
11872    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
11873    /// `cancel_chunk_upload(...)`.
11874    ///
11875    /// * *multipart*: yes
11876    /// * *max size*: 36700160
11877    /// * *valid mime types*: 'message/*'
11878    pub async fn upload_resumable<RS>(
11879        self,
11880        resumeable_stream: RS,
11881        mime_type: mime::Mime,
11882    ) -> common::Result<(common::Response, Message)>
11883    where
11884        RS: common::ReadSeek,
11885    {
11886        self.doit(
11887            resumeable_stream,
11888            mime_type,
11889            common::UploadProtocol::Resumable,
11890        )
11891        .await
11892    }
11893    /// Upload media all at once.
11894    /// If the upload fails for whichever reason, all progress is lost.
11895    ///
11896    /// * *multipart*: yes
11897    /// * *max size*: 36700160
11898    /// * *valid mime types*: 'message/*'
11899    pub async fn upload<RS>(
11900        self,
11901        stream: RS,
11902        mime_type: mime::Mime,
11903    ) -> common::Result<(common::Response, Message)>
11904    where
11905        RS: common::ReadSeek,
11906    {
11907        self.doit(stream, mime_type, common::UploadProtocol::Simple)
11908            .await
11909    }
11910
11911    ///
11912    /// Sets the *request* property to the given value.
11913    ///
11914    /// Even though the property as already been set when instantiating this call,
11915    /// we provide this method for API completeness.
11916    pub fn request(mut self, new_value: Message) -> UserMessageSendCall<'a, C> {
11917        self._request = new_value;
11918        self
11919    }
11920    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
11921    ///
11922    /// Sets the *user id* path property to the given value.
11923    ///
11924    /// Even though the property as already been set when instantiating this call,
11925    /// we provide this method for API completeness.
11926    pub fn user_id(mut self, new_value: &str) -> UserMessageSendCall<'a, C> {
11927        self._user_id = new_value.to_string();
11928        self
11929    }
11930    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11931    /// while executing the actual API request.
11932    ///
11933    /// ````text
11934    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11935    /// ````
11936    ///
11937    /// Sets the *delegate* property to the given value.
11938    pub fn delegate(
11939        mut self,
11940        new_value: &'a mut dyn common::Delegate,
11941    ) -> UserMessageSendCall<'a, C> {
11942        self._delegate = Some(new_value);
11943        self
11944    }
11945
11946    /// Set any additional parameter of the query string used in the request.
11947    /// It should be used to set parameters which are not yet available through their own
11948    /// setters.
11949    ///
11950    /// Please note that this method must not be used to set any of the known parameters
11951    /// which have their own setter method. If done anyway, the request will fail.
11952    ///
11953    /// # Additional Parameters
11954    ///
11955    /// * *$.xgafv* (query-string) - V1 error format.
11956    /// * *access_token* (query-string) - OAuth access token.
11957    /// * *alt* (query-string) - Data format for response.
11958    /// * *callback* (query-string) - JSONP
11959    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11960    /// * *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.
11961    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11962    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11963    /// * *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.
11964    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11965    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11966    pub fn param<T>(mut self, name: T, value: T) -> UserMessageSendCall<'a, C>
11967    where
11968        T: AsRef<str>,
11969    {
11970        self._additional_params
11971            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11972        self
11973    }
11974
11975    /// Identifies the authorization scope for the method you are building.
11976    ///
11977    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11978    /// [`Scope::Gmai`].
11979    ///
11980    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11981    /// tokens for more than one scope.
11982    ///
11983    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11984    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11985    /// sufficient, a read-write scope will do as well.
11986    pub fn add_scope<St>(mut self, scope: St) -> UserMessageSendCall<'a, C>
11987    where
11988        St: AsRef<str>,
11989    {
11990        self._scopes.insert(String::from(scope.as_ref()));
11991        self
11992    }
11993    /// Identifies the authorization scope(s) for the method you are building.
11994    ///
11995    /// See [`Self::add_scope()`] for details.
11996    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageSendCall<'a, C>
11997    where
11998        I: IntoIterator<Item = St>,
11999        St: AsRef<str>,
12000    {
12001        self._scopes
12002            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12003        self
12004    }
12005
12006    /// Removes all scopes, and no default scope will be used either.
12007    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12008    /// for details).
12009    pub fn clear_scopes(mut self) -> UserMessageSendCall<'a, C> {
12010        self._scopes.clear();
12011        self
12012    }
12013}
12014
12015/// Moves the specified message to the trash.
12016///
12017/// A builder for the *messages.trash* method supported by a *user* resource.
12018/// It is not used directly, but through a [`UserMethods`] instance.
12019///
12020/// # Example
12021///
12022/// Instantiate a resource method builder
12023///
12024/// ```test_harness,no_run
12025/// # extern crate hyper;
12026/// # extern crate hyper_rustls;
12027/// # extern crate google_gmail1 as gmail1;
12028/// # async fn dox() {
12029/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12030///
12031/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12032/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12033/// #     .with_native_roots()
12034/// #     .unwrap()
12035/// #     .https_only()
12036/// #     .enable_http2()
12037/// #     .build();
12038///
12039/// # let executor = hyper_util::rt::TokioExecutor::new();
12040/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12041/// #     secret,
12042/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12043/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12044/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12045/// #     ),
12046/// # ).build().await.unwrap();
12047///
12048/// # let client = hyper_util::client::legacy::Client::builder(
12049/// #     hyper_util::rt::TokioExecutor::new()
12050/// # )
12051/// # .build(
12052/// #     hyper_rustls::HttpsConnectorBuilder::new()
12053/// #         .with_native_roots()
12054/// #         .unwrap()
12055/// #         .https_or_http()
12056/// #         .enable_http2()
12057/// #         .build()
12058/// # );
12059/// # let mut hub = Gmail::new(client, auth);
12060/// // You can configure optional parameters by calling the respective setters at will, and
12061/// // execute the final call using `doit()`.
12062/// // Values shown here are possibly random and not representative !
12063/// let result = hub.users().messages_trash("userId", "id")
12064///              .doit().await;
12065/// # }
12066/// ```
12067pub struct UserMessageTrashCall<'a, C>
12068where
12069    C: 'a,
12070{
12071    hub: &'a Gmail<C>,
12072    _user_id: String,
12073    _id: String,
12074    _delegate: Option<&'a mut dyn common::Delegate>,
12075    _additional_params: HashMap<String, String>,
12076    _scopes: BTreeSet<String>,
12077}
12078
12079impl<'a, C> common::CallBuilder for UserMessageTrashCall<'a, C> {}
12080
12081impl<'a, C> UserMessageTrashCall<'a, C>
12082where
12083    C: common::Connector,
12084{
12085    /// Perform the operation you have build so far.
12086    pub async fn doit(mut self) -> common::Result<(common::Response, Message)> {
12087        use std::borrow::Cow;
12088        use std::io::{Read, Seek};
12089
12090        use common::{url::Params, ToParts};
12091        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12092
12093        let mut dd = common::DefaultDelegate;
12094        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12095        dlg.begin(common::MethodInfo {
12096            id: "gmail.users.messages.trash",
12097            http_method: hyper::Method::POST,
12098        });
12099
12100        for &field in ["alt", "userId", "id"].iter() {
12101            if self._additional_params.contains_key(field) {
12102                dlg.finished(false);
12103                return Err(common::Error::FieldClash(field));
12104            }
12105        }
12106
12107        let mut params = Params::with_capacity(4 + self._additional_params.len());
12108        params.push("userId", self._user_id);
12109        params.push("id", self._id);
12110
12111        params.extend(self._additional_params.iter());
12112
12113        params.push("alt", "json");
12114        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/{id}/trash";
12115        if self._scopes.is_empty() {
12116            self._scopes.insert(Scope::Gmai.as_ref().to_string());
12117        }
12118
12119        #[allow(clippy::single_element_loop)]
12120        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
12121            url = params.uri_replacement(url, param_name, find_this, false);
12122        }
12123        {
12124            let to_remove = ["id", "userId"];
12125            params.remove_params(&to_remove);
12126        }
12127
12128        let url = params.parse_with_url(&url);
12129
12130        loop {
12131            let token = match self
12132                .hub
12133                .auth
12134                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12135                .await
12136            {
12137                Ok(token) => token,
12138                Err(e) => match dlg.token(e) {
12139                    Ok(token) => token,
12140                    Err(e) => {
12141                        dlg.finished(false);
12142                        return Err(common::Error::MissingToken(e));
12143                    }
12144                },
12145            };
12146            let mut req_result = {
12147                let client = &self.hub.client;
12148                dlg.pre_request();
12149                let mut req_builder = hyper::Request::builder()
12150                    .method(hyper::Method::POST)
12151                    .uri(url.as_str())
12152                    .header(USER_AGENT, self.hub._user_agent.clone());
12153
12154                if let Some(token) = token.as_ref() {
12155                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12156                }
12157
12158                let request = req_builder
12159                    .header(CONTENT_LENGTH, 0_u64)
12160                    .body(common::to_body::<String>(None));
12161
12162                client.request(request.unwrap()).await
12163            };
12164
12165            match req_result {
12166                Err(err) => {
12167                    if let common::Retry::After(d) = dlg.http_error(&err) {
12168                        sleep(d).await;
12169                        continue;
12170                    }
12171                    dlg.finished(false);
12172                    return Err(common::Error::HttpError(err));
12173                }
12174                Ok(res) => {
12175                    let (mut parts, body) = res.into_parts();
12176                    let mut body = common::Body::new(body);
12177                    if !parts.status.is_success() {
12178                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12179                        let error = serde_json::from_str(&common::to_string(&bytes));
12180                        let response = common::to_response(parts, bytes.into());
12181
12182                        if let common::Retry::After(d) =
12183                            dlg.http_failure(&response, error.as_ref().ok())
12184                        {
12185                            sleep(d).await;
12186                            continue;
12187                        }
12188
12189                        dlg.finished(false);
12190
12191                        return Err(match error {
12192                            Ok(value) => common::Error::BadRequest(value),
12193                            _ => common::Error::Failure(response),
12194                        });
12195                    }
12196                    let response = {
12197                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12198                        let encoded = common::to_string(&bytes);
12199                        match serde_json::from_str(&encoded) {
12200                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12201                            Err(error) => {
12202                                dlg.response_json_decode_error(&encoded, &error);
12203                                return Err(common::Error::JsonDecodeError(
12204                                    encoded.to_string(),
12205                                    error,
12206                                ));
12207                            }
12208                        }
12209                    };
12210
12211                    dlg.finished(true);
12212                    return Ok(response);
12213                }
12214            }
12215        }
12216    }
12217
12218    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
12219    ///
12220    /// Sets the *user id* path property to the given value.
12221    ///
12222    /// Even though the property as already been set when instantiating this call,
12223    /// we provide this method for API completeness.
12224    pub fn user_id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C> {
12225        self._user_id = new_value.to_string();
12226        self
12227    }
12228    /// The ID of the message to Trash.
12229    ///
12230    /// Sets the *id* path property to the given value.
12231    ///
12232    /// Even though the property as already been set when instantiating this call,
12233    /// we provide this method for API completeness.
12234    pub fn id(mut self, new_value: &str) -> UserMessageTrashCall<'a, C> {
12235        self._id = new_value.to_string();
12236        self
12237    }
12238    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12239    /// while executing the actual API request.
12240    ///
12241    /// ````text
12242    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12243    /// ````
12244    ///
12245    /// Sets the *delegate* property to the given value.
12246    pub fn delegate(
12247        mut self,
12248        new_value: &'a mut dyn common::Delegate,
12249    ) -> UserMessageTrashCall<'a, C> {
12250        self._delegate = Some(new_value);
12251        self
12252    }
12253
12254    /// Set any additional parameter of the query string used in the request.
12255    /// It should be used to set parameters which are not yet available through their own
12256    /// setters.
12257    ///
12258    /// Please note that this method must not be used to set any of the known parameters
12259    /// which have their own setter method. If done anyway, the request will fail.
12260    ///
12261    /// # Additional Parameters
12262    ///
12263    /// * *$.xgafv* (query-string) - V1 error format.
12264    /// * *access_token* (query-string) - OAuth access token.
12265    /// * *alt* (query-string) - Data format for response.
12266    /// * *callback* (query-string) - JSONP
12267    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12268    /// * *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.
12269    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12270    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12271    /// * *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.
12272    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12273    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12274    pub fn param<T>(mut self, name: T, value: T) -> UserMessageTrashCall<'a, C>
12275    where
12276        T: AsRef<str>,
12277    {
12278        self._additional_params
12279            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12280        self
12281    }
12282
12283    /// Identifies the authorization scope for the method you are building.
12284    ///
12285    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12286    /// [`Scope::Gmai`].
12287    ///
12288    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12289    /// tokens for more than one scope.
12290    ///
12291    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12292    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12293    /// sufficient, a read-write scope will do as well.
12294    pub fn add_scope<St>(mut self, scope: St) -> UserMessageTrashCall<'a, C>
12295    where
12296        St: AsRef<str>,
12297    {
12298        self._scopes.insert(String::from(scope.as_ref()));
12299        self
12300    }
12301    /// Identifies the authorization scope(s) for the method you are building.
12302    ///
12303    /// See [`Self::add_scope()`] for details.
12304    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageTrashCall<'a, C>
12305    where
12306        I: IntoIterator<Item = St>,
12307        St: AsRef<str>,
12308    {
12309        self._scopes
12310            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12311        self
12312    }
12313
12314    /// Removes all scopes, and no default scope will be used either.
12315    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12316    /// for details).
12317    pub fn clear_scopes(mut self) -> UserMessageTrashCall<'a, C> {
12318        self._scopes.clear();
12319        self
12320    }
12321}
12322
12323/// Removes the specified message from the trash.
12324///
12325/// A builder for the *messages.untrash* method supported by a *user* resource.
12326/// It is not used directly, but through a [`UserMethods`] instance.
12327///
12328/// # Example
12329///
12330/// Instantiate a resource method builder
12331///
12332/// ```test_harness,no_run
12333/// # extern crate hyper;
12334/// # extern crate hyper_rustls;
12335/// # extern crate google_gmail1 as gmail1;
12336/// # async fn dox() {
12337/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12338///
12339/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12340/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12341/// #     .with_native_roots()
12342/// #     .unwrap()
12343/// #     .https_only()
12344/// #     .enable_http2()
12345/// #     .build();
12346///
12347/// # let executor = hyper_util::rt::TokioExecutor::new();
12348/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12349/// #     secret,
12350/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12351/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12352/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12353/// #     ),
12354/// # ).build().await.unwrap();
12355///
12356/// # let client = hyper_util::client::legacy::Client::builder(
12357/// #     hyper_util::rt::TokioExecutor::new()
12358/// # )
12359/// # .build(
12360/// #     hyper_rustls::HttpsConnectorBuilder::new()
12361/// #         .with_native_roots()
12362/// #         .unwrap()
12363/// #         .https_or_http()
12364/// #         .enable_http2()
12365/// #         .build()
12366/// # );
12367/// # let mut hub = Gmail::new(client, auth);
12368/// // You can configure optional parameters by calling the respective setters at will, and
12369/// // execute the final call using `doit()`.
12370/// // Values shown here are possibly random and not representative !
12371/// let result = hub.users().messages_untrash("userId", "id")
12372///              .doit().await;
12373/// # }
12374/// ```
12375pub struct UserMessageUntrashCall<'a, C>
12376where
12377    C: 'a,
12378{
12379    hub: &'a Gmail<C>,
12380    _user_id: String,
12381    _id: String,
12382    _delegate: Option<&'a mut dyn common::Delegate>,
12383    _additional_params: HashMap<String, String>,
12384    _scopes: BTreeSet<String>,
12385}
12386
12387impl<'a, C> common::CallBuilder for UserMessageUntrashCall<'a, C> {}
12388
12389impl<'a, C> UserMessageUntrashCall<'a, C>
12390where
12391    C: common::Connector,
12392{
12393    /// Perform the operation you have build so far.
12394    pub async fn doit(mut self) -> common::Result<(common::Response, Message)> {
12395        use std::borrow::Cow;
12396        use std::io::{Read, Seek};
12397
12398        use common::{url::Params, ToParts};
12399        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12400
12401        let mut dd = common::DefaultDelegate;
12402        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12403        dlg.begin(common::MethodInfo {
12404            id: "gmail.users.messages.untrash",
12405            http_method: hyper::Method::POST,
12406        });
12407
12408        for &field in ["alt", "userId", "id"].iter() {
12409            if self._additional_params.contains_key(field) {
12410                dlg.finished(false);
12411                return Err(common::Error::FieldClash(field));
12412            }
12413        }
12414
12415        let mut params = Params::with_capacity(4 + self._additional_params.len());
12416        params.push("userId", self._user_id);
12417        params.push("id", self._id);
12418
12419        params.extend(self._additional_params.iter());
12420
12421        params.push("alt", "json");
12422        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/messages/{id}/untrash";
12423        if self._scopes.is_empty() {
12424            self._scopes.insert(Scope::Gmai.as_ref().to_string());
12425        }
12426
12427        #[allow(clippy::single_element_loop)]
12428        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
12429            url = params.uri_replacement(url, param_name, find_this, false);
12430        }
12431        {
12432            let to_remove = ["id", "userId"];
12433            params.remove_params(&to_remove);
12434        }
12435
12436        let url = params.parse_with_url(&url);
12437
12438        loop {
12439            let token = match self
12440                .hub
12441                .auth
12442                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12443                .await
12444            {
12445                Ok(token) => token,
12446                Err(e) => match dlg.token(e) {
12447                    Ok(token) => token,
12448                    Err(e) => {
12449                        dlg.finished(false);
12450                        return Err(common::Error::MissingToken(e));
12451                    }
12452                },
12453            };
12454            let mut req_result = {
12455                let client = &self.hub.client;
12456                dlg.pre_request();
12457                let mut req_builder = hyper::Request::builder()
12458                    .method(hyper::Method::POST)
12459                    .uri(url.as_str())
12460                    .header(USER_AGENT, self.hub._user_agent.clone());
12461
12462                if let Some(token) = token.as_ref() {
12463                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12464                }
12465
12466                let request = req_builder
12467                    .header(CONTENT_LENGTH, 0_u64)
12468                    .body(common::to_body::<String>(None));
12469
12470                client.request(request.unwrap()).await
12471            };
12472
12473            match req_result {
12474                Err(err) => {
12475                    if let common::Retry::After(d) = dlg.http_error(&err) {
12476                        sleep(d).await;
12477                        continue;
12478                    }
12479                    dlg.finished(false);
12480                    return Err(common::Error::HttpError(err));
12481                }
12482                Ok(res) => {
12483                    let (mut parts, body) = res.into_parts();
12484                    let mut body = common::Body::new(body);
12485                    if !parts.status.is_success() {
12486                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12487                        let error = serde_json::from_str(&common::to_string(&bytes));
12488                        let response = common::to_response(parts, bytes.into());
12489
12490                        if let common::Retry::After(d) =
12491                            dlg.http_failure(&response, error.as_ref().ok())
12492                        {
12493                            sleep(d).await;
12494                            continue;
12495                        }
12496
12497                        dlg.finished(false);
12498
12499                        return Err(match error {
12500                            Ok(value) => common::Error::BadRequest(value),
12501                            _ => common::Error::Failure(response),
12502                        });
12503                    }
12504                    let response = {
12505                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12506                        let encoded = common::to_string(&bytes);
12507                        match serde_json::from_str(&encoded) {
12508                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12509                            Err(error) => {
12510                                dlg.response_json_decode_error(&encoded, &error);
12511                                return Err(common::Error::JsonDecodeError(
12512                                    encoded.to_string(),
12513                                    error,
12514                                ));
12515                            }
12516                        }
12517                    };
12518
12519                    dlg.finished(true);
12520                    return Ok(response);
12521                }
12522            }
12523        }
12524    }
12525
12526    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
12527    ///
12528    /// Sets the *user id* path property to the given value.
12529    ///
12530    /// Even though the property as already been set when instantiating this call,
12531    /// we provide this method for API completeness.
12532    pub fn user_id(mut self, new_value: &str) -> UserMessageUntrashCall<'a, C> {
12533        self._user_id = new_value.to_string();
12534        self
12535    }
12536    /// The ID of the message to remove from Trash.
12537    ///
12538    /// Sets the *id* path property to the given value.
12539    ///
12540    /// Even though the property as already been set when instantiating this call,
12541    /// we provide this method for API completeness.
12542    pub fn id(mut self, new_value: &str) -> UserMessageUntrashCall<'a, C> {
12543        self._id = new_value.to_string();
12544        self
12545    }
12546    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12547    /// while executing the actual API request.
12548    ///
12549    /// ````text
12550    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12551    /// ````
12552    ///
12553    /// Sets the *delegate* property to the given value.
12554    pub fn delegate(
12555        mut self,
12556        new_value: &'a mut dyn common::Delegate,
12557    ) -> UserMessageUntrashCall<'a, C> {
12558        self._delegate = Some(new_value);
12559        self
12560    }
12561
12562    /// Set any additional parameter of the query string used in the request.
12563    /// It should be used to set parameters which are not yet available through their own
12564    /// setters.
12565    ///
12566    /// Please note that this method must not be used to set any of the known parameters
12567    /// which have their own setter method. If done anyway, the request will fail.
12568    ///
12569    /// # Additional Parameters
12570    ///
12571    /// * *$.xgafv* (query-string) - V1 error format.
12572    /// * *access_token* (query-string) - OAuth access token.
12573    /// * *alt* (query-string) - Data format for response.
12574    /// * *callback* (query-string) - JSONP
12575    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12576    /// * *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.
12577    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12578    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12579    /// * *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.
12580    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12581    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12582    pub fn param<T>(mut self, name: T, value: T) -> UserMessageUntrashCall<'a, C>
12583    where
12584        T: AsRef<str>,
12585    {
12586        self._additional_params
12587            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12588        self
12589    }
12590
12591    /// Identifies the authorization scope for the method you are building.
12592    ///
12593    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12594    /// [`Scope::Gmai`].
12595    ///
12596    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12597    /// tokens for more than one scope.
12598    ///
12599    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12600    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12601    /// sufficient, a read-write scope will do as well.
12602    pub fn add_scope<St>(mut self, scope: St) -> UserMessageUntrashCall<'a, C>
12603    where
12604        St: AsRef<str>,
12605    {
12606        self._scopes.insert(String::from(scope.as_ref()));
12607        self
12608    }
12609    /// Identifies the authorization scope(s) for the method you are building.
12610    ///
12611    /// See [`Self::add_scope()`] for details.
12612    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserMessageUntrashCall<'a, C>
12613    where
12614        I: IntoIterator<Item = St>,
12615        St: AsRef<str>,
12616    {
12617        self._scopes
12618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12619        self
12620    }
12621
12622    /// Removes all scopes, and no default scope will be used either.
12623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12624    /// for details).
12625    pub fn clear_scopes(mut self) -> UserMessageUntrashCall<'a, C> {
12626        self._scopes.clear();
12627        self
12628    }
12629}
12630
12631/// Creates and configures a client-side encryption identity that's authorized to send mail from the user account. Google publishes the S/MIME certificate to a shared domain-wide directory so that people within a Google Workspace organization can encrypt and send mail to the identity. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
12632///
12633/// A builder for the *settings.cse.identities.create* method supported by a *user* resource.
12634/// It is not used directly, but through a [`UserMethods`] instance.
12635///
12636/// # Example
12637///
12638/// Instantiate a resource method builder
12639///
12640/// ```test_harness,no_run
12641/// # extern crate hyper;
12642/// # extern crate hyper_rustls;
12643/// # extern crate google_gmail1 as gmail1;
12644/// use gmail1::api::CseIdentity;
12645/// # async fn dox() {
12646/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12647///
12648/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12649/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12650/// #     .with_native_roots()
12651/// #     .unwrap()
12652/// #     .https_only()
12653/// #     .enable_http2()
12654/// #     .build();
12655///
12656/// # let executor = hyper_util::rt::TokioExecutor::new();
12657/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12658/// #     secret,
12659/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12660/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12661/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12662/// #     ),
12663/// # ).build().await.unwrap();
12664///
12665/// # let client = hyper_util::client::legacy::Client::builder(
12666/// #     hyper_util::rt::TokioExecutor::new()
12667/// # )
12668/// # .build(
12669/// #     hyper_rustls::HttpsConnectorBuilder::new()
12670/// #         .with_native_roots()
12671/// #         .unwrap()
12672/// #         .https_or_http()
12673/// #         .enable_http2()
12674/// #         .build()
12675/// # );
12676/// # let mut hub = Gmail::new(client, auth);
12677/// // As the method needs a request, you would usually fill it with the desired information
12678/// // into the respective structure. Some of the parts shown here might not be applicable !
12679/// // Values shown here are possibly random and not representative !
12680/// let mut req = CseIdentity::default();
12681///
12682/// // You can configure optional parameters by calling the respective setters at will, and
12683/// // execute the final call using `doit()`.
12684/// // Values shown here are possibly random and not representative !
12685/// let result = hub.users().settings_cse_identities_create(req, "userId")
12686///              .doit().await;
12687/// # }
12688/// ```
12689pub struct UserSettingCseIdentityCreateCall<'a, C>
12690where
12691    C: 'a,
12692{
12693    hub: &'a Gmail<C>,
12694    _request: CseIdentity,
12695    _user_id: String,
12696    _delegate: Option<&'a mut dyn common::Delegate>,
12697    _additional_params: HashMap<String, String>,
12698    _scopes: BTreeSet<String>,
12699}
12700
12701impl<'a, C> common::CallBuilder for UserSettingCseIdentityCreateCall<'a, C> {}
12702
12703impl<'a, C> UserSettingCseIdentityCreateCall<'a, C>
12704where
12705    C: common::Connector,
12706{
12707    /// Perform the operation you have build so far.
12708    pub async fn doit(mut self) -> common::Result<(common::Response, CseIdentity)> {
12709        use std::borrow::Cow;
12710        use std::io::{Read, Seek};
12711
12712        use common::{url::Params, ToParts};
12713        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12714
12715        let mut dd = common::DefaultDelegate;
12716        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12717        dlg.begin(common::MethodInfo {
12718            id: "gmail.users.settings.cse.identities.create",
12719            http_method: hyper::Method::POST,
12720        });
12721
12722        for &field in ["alt", "userId"].iter() {
12723            if self._additional_params.contains_key(field) {
12724                dlg.finished(false);
12725                return Err(common::Error::FieldClash(field));
12726            }
12727        }
12728
12729        let mut params = Params::with_capacity(4 + self._additional_params.len());
12730        params.push("userId", self._user_id);
12731
12732        params.extend(self._additional_params.iter());
12733
12734        params.push("alt", "json");
12735        let mut url =
12736            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/cse/identities";
12737        if self._scopes.is_empty() {
12738            self._scopes
12739                .insert(Scope::SettingBasic.as_ref().to_string());
12740        }
12741
12742        #[allow(clippy::single_element_loop)]
12743        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
12744            url = params.uri_replacement(url, param_name, find_this, false);
12745        }
12746        {
12747            let to_remove = ["userId"];
12748            params.remove_params(&to_remove);
12749        }
12750
12751        let url = params.parse_with_url(&url);
12752
12753        let mut json_mime_type = mime::APPLICATION_JSON;
12754        let mut request_value_reader = {
12755            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12756            common::remove_json_null_values(&mut value);
12757            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12758            serde_json::to_writer(&mut dst, &value).unwrap();
12759            dst
12760        };
12761        let request_size = request_value_reader
12762            .seek(std::io::SeekFrom::End(0))
12763            .unwrap();
12764        request_value_reader
12765            .seek(std::io::SeekFrom::Start(0))
12766            .unwrap();
12767
12768        loop {
12769            let token = match self
12770                .hub
12771                .auth
12772                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12773                .await
12774            {
12775                Ok(token) => token,
12776                Err(e) => match dlg.token(e) {
12777                    Ok(token) => token,
12778                    Err(e) => {
12779                        dlg.finished(false);
12780                        return Err(common::Error::MissingToken(e));
12781                    }
12782                },
12783            };
12784            request_value_reader
12785                .seek(std::io::SeekFrom::Start(0))
12786                .unwrap();
12787            let mut req_result = {
12788                let client = &self.hub.client;
12789                dlg.pre_request();
12790                let mut req_builder = hyper::Request::builder()
12791                    .method(hyper::Method::POST)
12792                    .uri(url.as_str())
12793                    .header(USER_AGENT, self.hub._user_agent.clone());
12794
12795                if let Some(token) = token.as_ref() {
12796                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12797                }
12798
12799                let request = req_builder
12800                    .header(CONTENT_TYPE, json_mime_type.to_string())
12801                    .header(CONTENT_LENGTH, request_size as u64)
12802                    .body(common::to_body(
12803                        request_value_reader.get_ref().clone().into(),
12804                    ));
12805
12806                client.request(request.unwrap()).await
12807            };
12808
12809            match req_result {
12810                Err(err) => {
12811                    if let common::Retry::After(d) = dlg.http_error(&err) {
12812                        sleep(d).await;
12813                        continue;
12814                    }
12815                    dlg.finished(false);
12816                    return Err(common::Error::HttpError(err));
12817                }
12818                Ok(res) => {
12819                    let (mut parts, body) = res.into_parts();
12820                    let mut body = common::Body::new(body);
12821                    if !parts.status.is_success() {
12822                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12823                        let error = serde_json::from_str(&common::to_string(&bytes));
12824                        let response = common::to_response(parts, bytes.into());
12825
12826                        if let common::Retry::After(d) =
12827                            dlg.http_failure(&response, error.as_ref().ok())
12828                        {
12829                            sleep(d).await;
12830                            continue;
12831                        }
12832
12833                        dlg.finished(false);
12834
12835                        return Err(match error {
12836                            Ok(value) => common::Error::BadRequest(value),
12837                            _ => common::Error::Failure(response),
12838                        });
12839                    }
12840                    let response = {
12841                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12842                        let encoded = common::to_string(&bytes);
12843                        match serde_json::from_str(&encoded) {
12844                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12845                            Err(error) => {
12846                                dlg.response_json_decode_error(&encoded, &error);
12847                                return Err(common::Error::JsonDecodeError(
12848                                    encoded.to_string(),
12849                                    error,
12850                                ));
12851                            }
12852                        }
12853                    };
12854
12855                    dlg.finished(true);
12856                    return Ok(response);
12857                }
12858            }
12859        }
12860    }
12861
12862    ///
12863    /// Sets the *request* property to the given value.
12864    ///
12865    /// Even though the property as already been set when instantiating this call,
12866    /// we provide this method for API completeness.
12867    pub fn request(mut self, new_value: CseIdentity) -> UserSettingCseIdentityCreateCall<'a, C> {
12868        self._request = new_value;
12869        self
12870    }
12871    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
12872    ///
12873    /// Sets the *user id* path property to the given value.
12874    ///
12875    /// Even though the property as already been set when instantiating this call,
12876    /// we provide this method for API completeness.
12877    pub fn user_id(mut self, new_value: &str) -> UserSettingCseIdentityCreateCall<'a, C> {
12878        self._user_id = new_value.to_string();
12879        self
12880    }
12881    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12882    /// while executing the actual API request.
12883    ///
12884    /// ````text
12885    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12886    /// ````
12887    ///
12888    /// Sets the *delegate* property to the given value.
12889    pub fn delegate(
12890        mut self,
12891        new_value: &'a mut dyn common::Delegate,
12892    ) -> UserSettingCseIdentityCreateCall<'a, C> {
12893        self._delegate = Some(new_value);
12894        self
12895    }
12896
12897    /// Set any additional parameter of the query string used in the request.
12898    /// It should be used to set parameters which are not yet available through their own
12899    /// setters.
12900    ///
12901    /// Please note that this method must not be used to set any of the known parameters
12902    /// which have their own setter method. If done anyway, the request will fail.
12903    ///
12904    /// # Additional Parameters
12905    ///
12906    /// * *$.xgafv* (query-string) - V1 error format.
12907    /// * *access_token* (query-string) - OAuth access token.
12908    /// * *alt* (query-string) - Data format for response.
12909    /// * *callback* (query-string) - JSONP
12910    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12911    /// * *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.
12912    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12913    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12914    /// * *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.
12915    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12916    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12917    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseIdentityCreateCall<'a, C>
12918    where
12919        T: AsRef<str>,
12920    {
12921        self._additional_params
12922            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12923        self
12924    }
12925
12926    /// Identifies the authorization scope for the method you are building.
12927    ///
12928    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12929    /// [`Scope::SettingBasic`].
12930    ///
12931    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12932    /// tokens for more than one scope.
12933    ///
12934    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12935    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12936    /// sufficient, a read-write scope will do as well.
12937    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseIdentityCreateCall<'a, C>
12938    where
12939        St: AsRef<str>,
12940    {
12941        self._scopes.insert(String::from(scope.as_ref()));
12942        self
12943    }
12944    /// Identifies the authorization scope(s) for the method you are building.
12945    ///
12946    /// See [`Self::add_scope()`] for details.
12947    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseIdentityCreateCall<'a, C>
12948    where
12949        I: IntoIterator<Item = St>,
12950        St: AsRef<str>,
12951    {
12952        self._scopes
12953            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12954        self
12955    }
12956
12957    /// Removes all scopes, and no default scope will be used either.
12958    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12959    /// for details).
12960    pub fn clear_scopes(mut self) -> UserSettingCseIdentityCreateCall<'a, C> {
12961        self._scopes.clear();
12962        self
12963    }
12964}
12965
12966/// Deletes a client-side encryption identity. The authenticated user can no longer use the identity to send encrypted messages. You cannot restore the identity after you delete it. Instead, use the CreateCseIdentity method to create another identity with the same configuration. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
12967///
12968/// A builder for the *settings.cse.identities.delete* method supported by a *user* resource.
12969/// It is not used directly, but through a [`UserMethods`] instance.
12970///
12971/// # Example
12972///
12973/// Instantiate a resource method builder
12974///
12975/// ```test_harness,no_run
12976/// # extern crate hyper;
12977/// # extern crate hyper_rustls;
12978/// # extern crate google_gmail1 as gmail1;
12979/// # async fn dox() {
12980/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12981///
12982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12983/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12984/// #     .with_native_roots()
12985/// #     .unwrap()
12986/// #     .https_only()
12987/// #     .enable_http2()
12988/// #     .build();
12989///
12990/// # let executor = hyper_util::rt::TokioExecutor::new();
12991/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12992/// #     secret,
12993/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12994/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12995/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12996/// #     ),
12997/// # ).build().await.unwrap();
12998///
12999/// # let client = hyper_util::client::legacy::Client::builder(
13000/// #     hyper_util::rt::TokioExecutor::new()
13001/// # )
13002/// # .build(
13003/// #     hyper_rustls::HttpsConnectorBuilder::new()
13004/// #         .with_native_roots()
13005/// #         .unwrap()
13006/// #         .https_or_http()
13007/// #         .enable_http2()
13008/// #         .build()
13009/// # );
13010/// # let mut hub = Gmail::new(client, auth);
13011/// // You can configure optional parameters by calling the respective setters at will, and
13012/// // execute the final call using `doit()`.
13013/// // Values shown here are possibly random and not representative !
13014/// let result = hub.users().settings_cse_identities_delete("userId", "cseEmailAddress")
13015///              .doit().await;
13016/// # }
13017/// ```
13018pub struct UserSettingCseIdentityDeleteCall<'a, C>
13019where
13020    C: 'a,
13021{
13022    hub: &'a Gmail<C>,
13023    _user_id: String,
13024    _cse_email_address: String,
13025    _delegate: Option<&'a mut dyn common::Delegate>,
13026    _additional_params: HashMap<String, String>,
13027    _scopes: BTreeSet<String>,
13028}
13029
13030impl<'a, C> common::CallBuilder for UserSettingCseIdentityDeleteCall<'a, C> {}
13031
13032impl<'a, C> UserSettingCseIdentityDeleteCall<'a, C>
13033where
13034    C: common::Connector,
13035{
13036    /// Perform the operation you have build so far.
13037    pub async fn doit(mut self) -> common::Result<common::Response> {
13038        use std::borrow::Cow;
13039        use std::io::{Read, Seek};
13040
13041        use common::{url::Params, ToParts};
13042        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13043
13044        let mut dd = common::DefaultDelegate;
13045        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13046        dlg.begin(common::MethodInfo {
13047            id: "gmail.users.settings.cse.identities.delete",
13048            http_method: hyper::Method::DELETE,
13049        });
13050
13051        for &field in ["userId", "cseEmailAddress"].iter() {
13052            if self._additional_params.contains_key(field) {
13053                dlg.finished(false);
13054                return Err(common::Error::FieldClash(field));
13055            }
13056        }
13057
13058        let mut params = Params::with_capacity(3 + self._additional_params.len());
13059        params.push("userId", self._user_id);
13060        params.push("cseEmailAddress", self._cse_email_address);
13061
13062        params.extend(self._additional_params.iter());
13063
13064        let mut url = self.hub._base_url.clone()
13065            + "gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}";
13066        if self._scopes.is_empty() {
13067            self._scopes
13068                .insert(Scope::SettingBasic.as_ref().to_string());
13069        }
13070
13071        #[allow(clippy::single_element_loop)]
13072        for &(find_this, param_name) in [
13073            ("{userId}", "userId"),
13074            ("{cseEmailAddress}", "cseEmailAddress"),
13075        ]
13076        .iter()
13077        {
13078            url = params.uri_replacement(url, param_name, find_this, false);
13079        }
13080        {
13081            let to_remove = ["cseEmailAddress", "userId"];
13082            params.remove_params(&to_remove);
13083        }
13084
13085        let url = params.parse_with_url(&url);
13086
13087        loop {
13088            let token = match self
13089                .hub
13090                .auth
13091                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13092                .await
13093            {
13094                Ok(token) => token,
13095                Err(e) => match dlg.token(e) {
13096                    Ok(token) => token,
13097                    Err(e) => {
13098                        dlg.finished(false);
13099                        return Err(common::Error::MissingToken(e));
13100                    }
13101                },
13102            };
13103            let mut req_result = {
13104                let client = &self.hub.client;
13105                dlg.pre_request();
13106                let mut req_builder = hyper::Request::builder()
13107                    .method(hyper::Method::DELETE)
13108                    .uri(url.as_str())
13109                    .header(USER_AGENT, self.hub._user_agent.clone());
13110
13111                if let Some(token) = token.as_ref() {
13112                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13113                }
13114
13115                let request = req_builder
13116                    .header(CONTENT_LENGTH, 0_u64)
13117                    .body(common::to_body::<String>(None));
13118
13119                client.request(request.unwrap()).await
13120            };
13121
13122            match req_result {
13123                Err(err) => {
13124                    if let common::Retry::After(d) = dlg.http_error(&err) {
13125                        sleep(d).await;
13126                        continue;
13127                    }
13128                    dlg.finished(false);
13129                    return Err(common::Error::HttpError(err));
13130                }
13131                Ok(res) => {
13132                    let (mut parts, body) = res.into_parts();
13133                    let mut body = common::Body::new(body);
13134                    if !parts.status.is_success() {
13135                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13136                        let error = serde_json::from_str(&common::to_string(&bytes));
13137                        let response = common::to_response(parts, bytes.into());
13138
13139                        if let common::Retry::After(d) =
13140                            dlg.http_failure(&response, error.as_ref().ok())
13141                        {
13142                            sleep(d).await;
13143                            continue;
13144                        }
13145
13146                        dlg.finished(false);
13147
13148                        return Err(match error {
13149                            Ok(value) => common::Error::BadRequest(value),
13150                            _ => common::Error::Failure(response),
13151                        });
13152                    }
13153                    let response = common::Response::from_parts(parts, body);
13154
13155                    dlg.finished(true);
13156                    return Ok(response);
13157                }
13158            }
13159        }
13160    }
13161
13162    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
13163    ///
13164    /// Sets the *user id* path property to the given value.
13165    ///
13166    /// Even though the property as already been set when instantiating this call,
13167    /// we provide this method for API completeness.
13168    pub fn user_id(mut self, new_value: &str) -> UserSettingCseIdentityDeleteCall<'a, C> {
13169        self._user_id = new_value.to_string();
13170        self
13171    }
13172    /// The primary email address associated with the client-side encryption identity configuration that's removed.
13173    ///
13174    /// Sets the *cse email address* path property to the given value.
13175    ///
13176    /// Even though the property as already been set when instantiating this call,
13177    /// we provide this method for API completeness.
13178    pub fn cse_email_address(mut self, new_value: &str) -> UserSettingCseIdentityDeleteCall<'a, C> {
13179        self._cse_email_address = new_value.to_string();
13180        self
13181    }
13182    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13183    /// while executing the actual API request.
13184    ///
13185    /// ````text
13186    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13187    /// ````
13188    ///
13189    /// Sets the *delegate* property to the given value.
13190    pub fn delegate(
13191        mut self,
13192        new_value: &'a mut dyn common::Delegate,
13193    ) -> UserSettingCseIdentityDeleteCall<'a, C> {
13194        self._delegate = Some(new_value);
13195        self
13196    }
13197
13198    /// Set any additional parameter of the query string used in the request.
13199    /// It should be used to set parameters which are not yet available through their own
13200    /// setters.
13201    ///
13202    /// Please note that this method must not be used to set any of the known parameters
13203    /// which have their own setter method. If done anyway, the request will fail.
13204    ///
13205    /// # Additional Parameters
13206    ///
13207    /// * *$.xgafv* (query-string) - V1 error format.
13208    /// * *access_token* (query-string) - OAuth access token.
13209    /// * *alt* (query-string) - Data format for response.
13210    /// * *callback* (query-string) - JSONP
13211    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13212    /// * *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.
13213    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13214    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13215    /// * *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.
13216    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13217    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13218    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseIdentityDeleteCall<'a, C>
13219    where
13220        T: AsRef<str>,
13221    {
13222        self._additional_params
13223            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13224        self
13225    }
13226
13227    /// Identifies the authorization scope for the method you are building.
13228    ///
13229    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13230    /// [`Scope::SettingBasic`].
13231    ///
13232    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13233    /// tokens for more than one scope.
13234    ///
13235    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13236    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13237    /// sufficient, a read-write scope will do as well.
13238    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseIdentityDeleteCall<'a, C>
13239    where
13240        St: AsRef<str>,
13241    {
13242        self._scopes.insert(String::from(scope.as_ref()));
13243        self
13244    }
13245    /// Identifies the authorization scope(s) for the method you are building.
13246    ///
13247    /// See [`Self::add_scope()`] for details.
13248    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseIdentityDeleteCall<'a, C>
13249    where
13250        I: IntoIterator<Item = St>,
13251        St: AsRef<str>,
13252    {
13253        self._scopes
13254            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13255        self
13256    }
13257
13258    /// Removes all scopes, and no default scope will be used either.
13259    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13260    /// for details).
13261    pub fn clear_scopes(mut self) -> UserSettingCseIdentityDeleteCall<'a, C> {
13262        self._scopes.clear();
13263        self
13264    }
13265}
13266
13267/// Retrieves a client-side encryption identity configuration. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
13268///
13269/// A builder for the *settings.cse.identities.get* method supported by a *user* resource.
13270/// It is not used directly, but through a [`UserMethods`] instance.
13271///
13272/// # Example
13273///
13274/// Instantiate a resource method builder
13275///
13276/// ```test_harness,no_run
13277/// # extern crate hyper;
13278/// # extern crate hyper_rustls;
13279/// # extern crate google_gmail1 as gmail1;
13280/// # async fn dox() {
13281/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13282///
13283/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13284/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13285/// #     .with_native_roots()
13286/// #     .unwrap()
13287/// #     .https_only()
13288/// #     .enable_http2()
13289/// #     .build();
13290///
13291/// # let executor = hyper_util::rt::TokioExecutor::new();
13292/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13293/// #     secret,
13294/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13295/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13296/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13297/// #     ),
13298/// # ).build().await.unwrap();
13299///
13300/// # let client = hyper_util::client::legacy::Client::builder(
13301/// #     hyper_util::rt::TokioExecutor::new()
13302/// # )
13303/// # .build(
13304/// #     hyper_rustls::HttpsConnectorBuilder::new()
13305/// #         .with_native_roots()
13306/// #         .unwrap()
13307/// #         .https_or_http()
13308/// #         .enable_http2()
13309/// #         .build()
13310/// # );
13311/// # let mut hub = Gmail::new(client, auth);
13312/// // You can configure optional parameters by calling the respective setters at will, and
13313/// // execute the final call using `doit()`.
13314/// // Values shown here are possibly random and not representative !
13315/// let result = hub.users().settings_cse_identities_get("userId", "cseEmailAddress")
13316///              .doit().await;
13317/// # }
13318/// ```
13319pub struct UserSettingCseIdentityGetCall<'a, C>
13320where
13321    C: 'a,
13322{
13323    hub: &'a Gmail<C>,
13324    _user_id: String,
13325    _cse_email_address: String,
13326    _delegate: Option<&'a mut dyn common::Delegate>,
13327    _additional_params: HashMap<String, String>,
13328    _scopes: BTreeSet<String>,
13329}
13330
13331impl<'a, C> common::CallBuilder for UserSettingCseIdentityGetCall<'a, C> {}
13332
13333impl<'a, C> UserSettingCseIdentityGetCall<'a, C>
13334where
13335    C: common::Connector,
13336{
13337    /// Perform the operation you have build so far.
13338    pub async fn doit(mut self) -> common::Result<(common::Response, CseIdentity)> {
13339        use std::borrow::Cow;
13340        use std::io::{Read, Seek};
13341
13342        use common::{url::Params, ToParts};
13343        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13344
13345        let mut dd = common::DefaultDelegate;
13346        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13347        dlg.begin(common::MethodInfo {
13348            id: "gmail.users.settings.cse.identities.get",
13349            http_method: hyper::Method::GET,
13350        });
13351
13352        for &field in ["alt", "userId", "cseEmailAddress"].iter() {
13353            if self._additional_params.contains_key(field) {
13354                dlg.finished(false);
13355                return Err(common::Error::FieldClash(field));
13356            }
13357        }
13358
13359        let mut params = Params::with_capacity(4 + self._additional_params.len());
13360        params.push("userId", self._user_id);
13361        params.push("cseEmailAddress", self._cse_email_address);
13362
13363        params.extend(self._additional_params.iter());
13364
13365        params.push("alt", "json");
13366        let mut url = self.hub._base_url.clone()
13367            + "gmail/v1/users/{userId}/settings/cse/identities/{cseEmailAddress}";
13368        if self._scopes.is_empty() {
13369            self._scopes.insert(Scope::Readonly.as_ref().to_string());
13370        }
13371
13372        #[allow(clippy::single_element_loop)]
13373        for &(find_this, param_name) in [
13374            ("{userId}", "userId"),
13375            ("{cseEmailAddress}", "cseEmailAddress"),
13376        ]
13377        .iter()
13378        {
13379            url = params.uri_replacement(url, param_name, find_this, false);
13380        }
13381        {
13382            let to_remove = ["cseEmailAddress", "userId"];
13383            params.remove_params(&to_remove);
13384        }
13385
13386        let url = params.parse_with_url(&url);
13387
13388        loop {
13389            let token = match self
13390                .hub
13391                .auth
13392                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13393                .await
13394            {
13395                Ok(token) => token,
13396                Err(e) => match dlg.token(e) {
13397                    Ok(token) => token,
13398                    Err(e) => {
13399                        dlg.finished(false);
13400                        return Err(common::Error::MissingToken(e));
13401                    }
13402                },
13403            };
13404            let mut req_result = {
13405                let client = &self.hub.client;
13406                dlg.pre_request();
13407                let mut req_builder = hyper::Request::builder()
13408                    .method(hyper::Method::GET)
13409                    .uri(url.as_str())
13410                    .header(USER_AGENT, self.hub._user_agent.clone());
13411
13412                if let Some(token) = token.as_ref() {
13413                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13414                }
13415
13416                let request = req_builder
13417                    .header(CONTENT_LENGTH, 0_u64)
13418                    .body(common::to_body::<String>(None));
13419
13420                client.request(request.unwrap()).await
13421            };
13422
13423            match req_result {
13424                Err(err) => {
13425                    if let common::Retry::After(d) = dlg.http_error(&err) {
13426                        sleep(d).await;
13427                        continue;
13428                    }
13429                    dlg.finished(false);
13430                    return Err(common::Error::HttpError(err));
13431                }
13432                Ok(res) => {
13433                    let (mut parts, body) = res.into_parts();
13434                    let mut body = common::Body::new(body);
13435                    if !parts.status.is_success() {
13436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13437                        let error = serde_json::from_str(&common::to_string(&bytes));
13438                        let response = common::to_response(parts, bytes.into());
13439
13440                        if let common::Retry::After(d) =
13441                            dlg.http_failure(&response, error.as_ref().ok())
13442                        {
13443                            sleep(d).await;
13444                            continue;
13445                        }
13446
13447                        dlg.finished(false);
13448
13449                        return Err(match error {
13450                            Ok(value) => common::Error::BadRequest(value),
13451                            _ => common::Error::Failure(response),
13452                        });
13453                    }
13454                    let response = {
13455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13456                        let encoded = common::to_string(&bytes);
13457                        match serde_json::from_str(&encoded) {
13458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13459                            Err(error) => {
13460                                dlg.response_json_decode_error(&encoded, &error);
13461                                return Err(common::Error::JsonDecodeError(
13462                                    encoded.to_string(),
13463                                    error,
13464                                ));
13465                            }
13466                        }
13467                    };
13468
13469                    dlg.finished(true);
13470                    return Ok(response);
13471                }
13472            }
13473        }
13474    }
13475
13476    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
13477    ///
13478    /// Sets the *user id* path property to the given value.
13479    ///
13480    /// Even though the property as already been set when instantiating this call,
13481    /// we provide this method for API completeness.
13482    pub fn user_id(mut self, new_value: &str) -> UserSettingCseIdentityGetCall<'a, C> {
13483        self._user_id = new_value.to_string();
13484        self
13485    }
13486    /// The primary email address associated with the client-side encryption identity configuration that's retrieved.
13487    ///
13488    /// Sets the *cse email address* path property to the given value.
13489    ///
13490    /// Even though the property as already been set when instantiating this call,
13491    /// we provide this method for API completeness.
13492    pub fn cse_email_address(mut self, new_value: &str) -> UserSettingCseIdentityGetCall<'a, C> {
13493        self._cse_email_address = new_value.to_string();
13494        self
13495    }
13496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13497    /// while executing the actual API request.
13498    ///
13499    /// ````text
13500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13501    /// ````
13502    ///
13503    /// Sets the *delegate* property to the given value.
13504    pub fn delegate(
13505        mut self,
13506        new_value: &'a mut dyn common::Delegate,
13507    ) -> UserSettingCseIdentityGetCall<'a, C> {
13508        self._delegate = Some(new_value);
13509        self
13510    }
13511
13512    /// Set any additional parameter of the query string used in the request.
13513    /// It should be used to set parameters which are not yet available through their own
13514    /// setters.
13515    ///
13516    /// Please note that this method must not be used to set any of the known parameters
13517    /// which have their own setter method. If done anyway, the request will fail.
13518    ///
13519    /// # Additional Parameters
13520    ///
13521    /// * *$.xgafv* (query-string) - V1 error format.
13522    /// * *access_token* (query-string) - OAuth access token.
13523    /// * *alt* (query-string) - Data format for response.
13524    /// * *callback* (query-string) - JSONP
13525    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13526    /// * *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.
13527    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13529    /// * *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.
13530    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13531    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13532    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseIdentityGetCall<'a, C>
13533    where
13534        T: AsRef<str>,
13535    {
13536        self._additional_params
13537            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13538        self
13539    }
13540
13541    /// Identifies the authorization scope for the method you are building.
13542    ///
13543    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13544    /// [`Scope::Readonly`].
13545    ///
13546    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13547    /// tokens for more than one scope.
13548    ///
13549    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13550    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13551    /// sufficient, a read-write scope will do as well.
13552    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseIdentityGetCall<'a, C>
13553    where
13554        St: AsRef<str>,
13555    {
13556        self._scopes.insert(String::from(scope.as_ref()));
13557        self
13558    }
13559    /// Identifies the authorization scope(s) for the method you are building.
13560    ///
13561    /// See [`Self::add_scope()`] for details.
13562    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseIdentityGetCall<'a, C>
13563    where
13564        I: IntoIterator<Item = St>,
13565        St: AsRef<str>,
13566    {
13567        self._scopes
13568            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13569        self
13570    }
13571
13572    /// Removes all scopes, and no default scope will be used either.
13573    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13574    /// for details).
13575    pub fn clear_scopes(mut self) -> UserSettingCseIdentityGetCall<'a, C> {
13576        self._scopes.clear();
13577        self
13578    }
13579}
13580
13581/// Lists the client-side encrypted identities for an authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
13582///
13583/// A builder for the *settings.cse.identities.list* method supported by a *user* resource.
13584/// It is not used directly, but through a [`UserMethods`] instance.
13585///
13586/// # Example
13587///
13588/// Instantiate a resource method builder
13589///
13590/// ```test_harness,no_run
13591/// # extern crate hyper;
13592/// # extern crate hyper_rustls;
13593/// # extern crate google_gmail1 as gmail1;
13594/// # async fn dox() {
13595/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13596///
13597/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13598/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13599/// #     .with_native_roots()
13600/// #     .unwrap()
13601/// #     .https_only()
13602/// #     .enable_http2()
13603/// #     .build();
13604///
13605/// # let executor = hyper_util::rt::TokioExecutor::new();
13606/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13607/// #     secret,
13608/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13609/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13610/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13611/// #     ),
13612/// # ).build().await.unwrap();
13613///
13614/// # let client = hyper_util::client::legacy::Client::builder(
13615/// #     hyper_util::rt::TokioExecutor::new()
13616/// # )
13617/// # .build(
13618/// #     hyper_rustls::HttpsConnectorBuilder::new()
13619/// #         .with_native_roots()
13620/// #         .unwrap()
13621/// #         .https_or_http()
13622/// #         .enable_http2()
13623/// #         .build()
13624/// # );
13625/// # let mut hub = Gmail::new(client, auth);
13626/// // You can configure optional parameters by calling the respective setters at will, and
13627/// // execute the final call using `doit()`.
13628/// // Values shown here are possibly random and not representative !
13629/// let result = hub.users().settings_cse_identities_list("userId")
13630///              .page_token("voluptua.")
13631///              .page_size(-2)
13632///              .doit().await;
13633/// # }
13634/// ```
13635pub struct UserSettingCseIdentityListCall<'a, C>
13636where
13637    C: 'a,
13638{
13639    hub: &'a Gmail<C>,
13640    _user_id: String,
13641    _page_token: Option<String>,
13642    _page_size: Option<i32>,
13643    _delegate: Option<&'a mut dyn common::Delegate>,
13644    _additional_params: HashMap<String, String>,
13645    _scopes: BTreeSet<String>,
13646}
13647
13648impl<'a, C> common::CallBuilder for UserSettingCseIdentityListCall<'a, C> {}
13649
13650impl<'a, C> UserSettingCseIdentityListCall<'a, C>
13651where
13652    C: common::Connector,
13653{
13654    /// Perform the operation you have build so far.
13655    pub async fn doit(mut self) -> common::Result<(common::Response, ListCseIdentitiesResponse)> {
13656        use std::borrow::Cow;
13657        use std::io::{Read, Seek};
13658
13659        use common::{url::Params, ToParts};
13660        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13661
13662        let mut dd = common::DefaultDelegate;
13663        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13664        dlg.begin(common::MethodInfo {
13665            id: "gmail.users.settings.cse.identities.list",
13666            http_method: hyper::Method::GET,
13667        });
13668
13669        for &field in ["alt", "userId", "pageToken", "pageSize"].iter() {
13670            if self._additional_params.contains_key(field) {
13671                dlg.finished(false);
13672                return Err(common::Error::FieldClash(field));
13673            }
13674        }
13675
13676        let mut params = Params::with_capacity(5 + self._additional_params.len());
13677        params.push("userId", self._user_id);
13678        if let Some(value) = self._page_token.as_ref() {
13679            params.push("pageToken", value);
13680        }
13681        if let Some(value) = self._page_size.as_ref() {
13682            params.push("pageSize", value.to_string());
13683        }
13684
13685        params.extend(self._additional_params.iter());
13686
13687        params.push("alt", "json");
13688        let mut url =
13689            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/cse/identities";
13690        if self._scopes.is_empty() {
13691            self._scopes.insert(Scope::Readonly.as_ref().to_string());
13692        }
13693
13694        #[allow(clippy::single_element_loop)]
13695        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
13696            url = params.uri_replacement(url, param_name, find_this, false);
13697        }
13698        {
13699            let to_remove = ["userId"];
13700            params.remove_params(&to_remove);
13701        }
13702
13703        let url = params.parse_with_url(&url);
13704
13705        loop {
13706            let token = match self
13707                .hub
13708                .auth
13709                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13710                .await
13711            {
13712                Ok(token) => token,
13713                Err(e) => match dlg.token(e) {
13714                    Ok(token) => token,
13715                    Err(e) => {
13716                        dlg.finished(false);
13717                        return Err(common::Error::MissingToken(e));
13718                    }
13719                },
13720            };
13721            let mut req_result = {
13722                let client = &self.hub.client;
13723                dlg.pre_request();
13724                let mut req_builder = hyper::Request::builder()
13725                    .method(hyper::Method::GET)
13726                    .uri(url.as_str())
13727                    .header(USER_AGENT, self.hub._user_agent.clone());
13728
13729                if let Some(token) = token.as_ref() {
13730                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13731                }
13732
13733                let request = req_builder
13734                    .header(CONTENT_LENGTH, 0_u64)
13735                    .body(common::to_body::<String>(None));
13736
13737                client.request(request.unwrap()).await
13738            };
13739
13740            match req_result {
13741                Err(err) => {
13742                    if let common::Retry::After(d) = dlg.http_error(&err) {
13743                        sleep(d).await;
13744                        continue;
13745                    }
13746                    dlg.finished(false);
13747                    return Err(common::Error::HttpError(err));
13748                }
13749                Ok(res) => {
13750                    let (mut parts, body) = res.into_parts();
13751                    let mut body = common::Body::new(body);
13752                    if !parts.status.is_success() {
13753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13754                        let error = serde_json::from_str(&common::to_string(&bytes));
13755                        let response = common::to_response(parts, bytes.into());
13756
13757                        if let common::Retry::After(d) =
13758                            dlg.http_failure(&response, error.as_ref().ok())
13759                        {
13760                            sleep(d).await;
13761                            continue;
13762                        }
13763
13764                        dlg.finished(false);
13765
13766                        return Err(match error {
13767                            Ok(value) => common::Error::BadRequest(value),
13768                            _ => common::Error::Failure(response),
13769                        });
13770                    }
13771                    let response = {
13772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13773                        let encoded = common::to_string(&bytes);
13774                        match serde_json::from_str(&encoded) {
13775                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13776                            Err(error) => {
13777                                dlg.response_json_decode_error(&encoded, &error);
13778                                return Err(common::Error::JsonDecodeError(
13779                                    encoded.to_string(),
13780                                    error,
13781                                ));
13782                            }
13783                        }
13784                    };
13785
13786                    dlg.finished(true);
13787                    return Ok(response);
13788                }
13789            }
13790        }
13791    }
13792
13793    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
13794    ///
13795    /// Sets the *user id* path property to the given value.
13796    ///
13797    /// Even though the property as already been set when instantiating this call,
13798    /// we provide this method for API completeness.
13799    pub fn user_id(mut self, new_value: &str) -> UserSettingCseIdentityListCall<'a, C> {
13800        self._user_id = new_value.to_string();
13801        self
13802    }
13803    /// Pagination token indicating which page of identities to return. If the token is not supplied, then the API will return the first page of results.
13804    ///
13805    /// Sets the *page token* query property to the given value.
13806    pub fn page_token(mut self, new_value: &str) -> UserSettingCseIdentityListCall<'a, C> {
13807        self._page_token = Some(new_value.to_string());
13808        self
13809    }
13810    /// The number of identities to return. If not provided, the page size will default to 20 entries.
13811    ///
13812    /// Sets the *page size* query property to the given value.
13813    pub fn page_size(mut self, new_value: i32) -> UserSettingCseIdentityListCall<'a, C> {
13814        self._page_size = Some(new_value);
13815        self
13816    }
13817    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13818    /// while executing the actual API request.
13819    ///
13820    /// ````text
13821    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13822    /// ````
13823    ///
13824    /// Sets the *delegate* property to the given value.
13825    pub fn delegate(
13826        mut self,
13827        new_value: &'a mut dyn common::Delegate,
13828    ) -> UserSettingCseIdentityListCall<'a, C> {
13829        self._delegate = Some(new_value);
13830        self
13831    }
13832
13833    /// Set any additional parameter of the query string used in the request.
13834    /// It should be used to set parameters which are not yet available through their own
13835    /// setters.
13836    ///
13837    /// Please note that this method must not be used to set any of the known parameters
13838    /// which have their own setter method. If done anyway, the request will fail.
13839    ///
13840    /// # Additional Parameters
13841    ///
13842    /// * *$.xgafv* (query-string) - V1 error format.
13843    /// * *access_token* (query-string) - OAuth access token.
13844    /// * *alt* (query-string) - Data format for response.
13845    /// * *callback* (query-string) - JSONP
13846    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13847    /// * *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.
13848    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13849    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13850    /// * *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.
13851    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13852    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13853    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseIdentityListCall<'a, C>
13854    where
13855        T: AsRef<str>,
13856    {
13857        self._additional_params
13858            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13859        self
13860    }
13861
13862    /// Identifies the authorization scope for the method you are building.
13863    ///
13864    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13865    /// [`Scope::Readonly`].
13866    ///
13867    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13868    /// tokens for more than one scope.
13869    ///
13870    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13871    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13872    /// sufficient, a read-write scope will do as well.
13873    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseIdentityListCall<'a, C>
13874    where
13875        St: AsRef<str>,
13876    {
13877        self._scopes.insert(String::from(scope.as_ref()));
13878        self
13879    }
13880    /// Identifies the authorization scope(s) for the method you are building.
13881    ///
13882    /// See [`Self::add_scope()`] for details.
13883    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseIdentityListCall<'a, C>
13884    where
13885        I: IntoIterator<Item = St>,
13886        St: AsRef<str>,
13887    {
13888        self._scopes
13889            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13890        self
13891    }
13892
13893    /// Removes all scopes, and no default scope will be used either.
13894    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13895    /// for details).
13896    pub fn clear_scopes(mut self) -> UserSettingCseIdentityListCall<'a, C> {
13897        self._scopes.clear();
13898        self
13899    }
13900}
13901
13902/// Associates a different key pair with an existing client-side encryption identity. The updated key pair must validate against Google's [S/MIME certificate profiles](https://support.google.com/a/answer/7300887). For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
13903///
13904/// A builder for the *settings.cse.identities.patch* method supported by a *user* resource.
13905/// It is not used directly, but through a [`UserMethods`] instance.
13906///
13907/// # Example
13908///
13909/// Instantiate a resource method builder
13910///
13911/// ```test_harness,no_run
13912/// # extern crate hyper;
13913/// # extern crate hyper_rustls;
13914/// # extern crate google_gmail1 as gmail1;
13915/// use gmail1::api::CseIdentity;
13916/// # async fn dox() {
13917/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13918///
13919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13920/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13921/// #     .with_native_roots()
13922/// #     .unwrap()
13923/// #     .https_only()
13924/// #     .enable_http2()
13925/// #     .build();
13926///
13927/// # let executor = hyper_util::rt::TokioExecutor::new();
13928/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13929/// #     secret,
13930/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13931/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13932/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13933/// #     ),
13934/// # ).build().await.unwrap();
13935///
13936/// # let client = hyper_util::client::legacy::Client::builder(
13937/// #     hyper_util::rt::TokioExecutor::new()
13938/// # )
13939/// # .build(
13940/// #     hyper_rustls::HttpsConnectorBuilder::new()
13941/// #         .with_native_roots()
13942/// #         .unwrap()
13943/// #         .https_or_http()
13944/// #         .enable_http2()
13945/// #         .build()
13946/// # );
13947/// # let mut hub = Gmail::new(client, auth);
13948/// // As the method needs a request, you would usually fill it with the desired information
13949/// // into the respective structure. Some of the parts shown here might not be applicable !
13950/// // Values shown here are possibly random and not representative !
13951/// let mut req = CseIdentity::default();
13952///
13953/// // You can configure optional parameters by calling the respective setters at will, and
13954/// // execute the final call using `doit()`.
13955/// // Values shown here are possibly random and not representative !
13956/// let result = hub.users().settings_cse_identities_patch(req, "userId", "emailAddress")
13957///              .doit().await;
13958/// # }
13959/// ```
13960pub struct UserSettingCseIdentityPatchCall<'a, C>
13961where
13962    C: 'a,
13963{
13964    hub: &'a Gmail<C>,
13965    _request: CseIdentity,
13966    _user_id: String,
13967    _email_address: String,
13968    _delegate: Option<&'a mut dyn common::Delegate>,
13969    _additional_params: HashMap<String, String>,
13970    _scopes: BTreeSet<String>,
13971}
13972
13973impl<'a, C> common::CallBuilder for UserSettingCseIdentityPatchCall<'a, C> {}
13974
13975impl<'a, C> UserSettingCseIdentityPatchCall<'a, C>
13976where
13977    C: common::Connector,
13978{
13979    /// Perform the operation you have build so far.
13980    pub async fn doit(mut self) -> common::Result<(common::Response, CseIdentity)> {
13981        use std::borrow::Cow;
13982        use std::io::{Read, Seek};
13983
13984        use common::{url::Params, ToParts};
13985        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13986
13987        let mut dd = common::DefaultDelegate;
13988        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13989        dlg.begin(common::MethodInfo {
13990            id: "gmail.users.settings.cse.identities.patch",
13991            http_method: hyper::Method::PATCH,
13992        });
13993
13994        for &field in ["alt", "userId", "emailAddress"].iter() {
13995            if self._additional_params.contains_key(field) {
13996                dlg.finished(false);
13997                return Err(common::Error::FieldClash(field));
13998            }
13999        }
14000
14001        let mut params = Params::with_capacity(5 + self._additional_params.len());
14002        params.push("userId", self._user_id);
14003        params.push("emailAddress", self._email_address);
14004
14005        params.extend(self._additional_params.iter());
14006
14007        params.push("alt", "json");
14008        let mut url = self.hub._base_url.clone()
14009            + "gmail/v1/users/{userId}/settings/cse/identities/{emailAddress}";
14010        if self._scopes.is_empty() {
14011            self._scopes
14012                .insert(Scope::SettingBasic.as_ref().to_string());
14013        }
14014
14015        #[allow(clippy::single_element_loop)]
14016        for &(find_this, param_name) in
14017            [("{userId}", "userId"), ("{emailAddress}", "emailAddress")].iter()
14018        {
14019            url = params.uri_replacement(url, param_name, find_this, false);
14020        }
14021        {
14022            let to_remove = ["emailAddress", "userId"];
14023            params.remove_params(&to_remove);
14024        }
14025
14026        let url = params.parse_with_url(&url);
14027
14028        let mut json_mime_type = mime::APPLICATION_JSON;
14029        let mut request_value_reader = {
14030            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14031            common::remove_json_null_values(&mut value);
14032            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14033            serde_json::to_writer(&mut dst, &value).unwrap();
14034            dst
14035        };
14036        let request_size = request_value_reader
14037            .seek(std::io::SeekFrom::End(0))
14038            .unwrap();
14039        request_value_reader
14040            .seek(std::io::SeekFrom::Start(0))
14041            .unwrap();
14042
14043        loop {
14044            let token = match self
14045                .hub
14046                .auth
14047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14048                .await
14049            {
14050                Ok(token) => token,
14051                Err(e) => match dlg.token(e) {
14052                    Ok(token) => token,
14053                    Err(e) => {
14054                        dlg.finished(false);
14055                        return Err(common::Error::MissingToken(e));
14056                    }
14057                },
14058            };
14059            request_value_reader
14060                .seek(std::io::SeekFrom::Start(0))
14061                .unwrap();
14062            let mut req_result = {
14063                let client = &self.hub.client;
14064                dlg.pre_request();
14065                let mut req_builder = hyper::Request::builder()
14066                    .method(hyper::Method::PATCH)
14067                    .uri(url.as_str())
14068                    .header(USER_AGENT, self.hub._user_agent.clone());
14069
14070                if let Some(token) = token.as_ref() {
14071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14072                }
14073
14074                let request = req_builder
14075                    .header(CONTENT_TYPE, json_mime_type.to_string())
14076                    .header(CONTENT_LENGTH, request_size as u64)
14077                    .body(common::to_body(
14078                        request_value_reader.get_ref().clone().into(),
14079                    ));
14080
14081                client.request(request.unwrap()).await
14082            };
14083
14084            match req_result {
14085                Err(err) => {
14086                    if let common::Retry::After(d) = dlg.http_error(&err) {
14087                        sleep(d).await;
14088                        continue;
14089                    }
14090                    dlg.finished(false);
14091                    return Err(common::Error::HttpError(err));
14092                }
14093                Ok(res) => {
14094                    let (mut parts, body) = res.into_parts();
14095                    let mut body = common::Body::new(body);
14096                    if !parts.status.is_success() {
14097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14098                        let error = serde_json::from_str(&common::to_string(&bytes));
14099                        let response = common::to_response(parts, bytes.into());
14100
14101                        if let common::Retry::After(d) =
14102                            dlg.http_failure(&response, error.as_ref().ok())
14103                        {
14104                            sleep(d).await;
14105                            continue;
14106                        }
14107
14108                        dlg.finished(false);
14109
14110                        return Err(match error {
14111                            Ok(value) => common::Error::BadRequest(value),
14112                            _ => common::Error::Failure(response),
14113                        });
14114                    }
14115                    let response = {
14116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14117                        let encoded = common::to_string(&bytes);
14118                        match serde_json::from_str(&encoded) {
14119                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14120                            Err(error) => {
14121                                dlg.response_json_decode_error(&encoded, &error);
14122                                return Err(common::Error::JsonDecodeError(
14123                                    encoded.to_string(),
14124                                    error,
14125                                ));
14126                            }
14127                        }
14128                    };
14129
14130                    dlg.finished(true);
14131                    return Ok(response);
14132                }
14133            }
14134        }
14135    }
14136
14137    ///
14138    /// Sets the *request* property to the given value.
14139    ///
14140    /// Even though the property as already been set when instantiating this call,
14141    /// we provide this method for API completeness.
14142    pub fn request(mut self, new_value: CseIdentity) -> UserSettingCseIdentityPatchCall<'a, C> {
14143        self._request = new_value;
14144        self
14145    }
14146    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
14147    ///
14148    /// Sets the *user id* path property to the given value.
14149    ///
14150    /// Even though the property as already been set when instantiating this call,
14151    /// we provide this method for API completeness.
14152    pub fn user_id(mut self, new_value: &str) -> UserSettingCseIdentityPatchCall<'a, C> {
14153        self._user_id = new_value.to_string();
14154        self
14155    }
14156    /// The email address of the client-side encryption identity to update.
14157    ///
14158    /// Sets the *email address* path property to the given value.
14159    ///
14160    /// Even though the property as already been set when instantiating this call,
14161    /// we provide this method for API completeness.
14162    pub fn email_address(mut self, new_value: &str) -> UserSettingCseIdentityPatchCall<'a, C> {
14163        self._email_address = new_value.to_string();
14164        self
14165    }
14166    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14167    /// while executing the actual API request.
14168    ///
14169    /// ````text
14170    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14171    /// ````
14172    ///
14173    /// Sets the *delegate* property to the given value.
14174    pub fn delegate(
14175        mut self,
14176        new_value: &'a mut dyn common::Delegate,
14177    ) -> UserSettingCseIdentityPatchCall<'a, C> {
14178        self._delegate = Some(new_value);
14179        self
14180    }
14181
14182    /// Set any additional parameter of the query string used in the request.
14183    /// It should be used to set parameters which are not yet available through their own
14184    /// setters.
14185    ///
14186    /// Please note that this method must not be used to set any of the known parameters
14187    /// which have their own setter method. If done anyway, the request will fail.
14188    ///
14189    /// # Additional Parameters
14190    ///
14191    /// * *$.xgafv* (query-string) - V1 error format.
14192    /// * *access_token* (query-string) - OAuth access token.
14193    /// * *alt* (query-string) - Data format for response.
14194    /// * *callback* (query-string) - JSONP
14195    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14196    /// * *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.
14197    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14198    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14199    /// * *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.
14200    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14201    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14202    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseIdentityPatchCall<'a, C>
14203    where
14204        T: AsRef<str>,
14205    {
14206        self._additional_params
14207            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14208        self
14209    }
14210
14211    /// Identifies the authorization scope for the method you are building.
14212    ///
14213    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14214    /// [`Scope::SettingBasic`].
14215    ///
14216    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14217    /// tokens for more than one scope.
14218    ///
14219    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14220    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14221    /// sufficient, a read-write scope will do as well.
14222    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseIdentityPatchCall<'a, C>
14223    where
14224        St: AsRef<str>,
14225    {
14226        self._scopes.insert(String::from(scope.as_ref()));
14227        self
14228    }
14229    /// Identifies the authorization scope(s) for the method you are building.
14230    ///
14231    /// See [`Self::add_scope()`] for details.
14232    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseIdentityPatchCall<'a, C>
14233    where
14234        I: IntoIterator<Item = St>,
14235        St: AsRef<str>,
14236    {
14237        self._scopes
14238            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14239        self
14240    }
14241
14242    /// Removes all scopes, and no default scope will be used either.
14243    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14244    /// for details).
14245    pub fn clear_scopes(mut self) -> UserSettingCseIdentityPatchCall<'a, C> {
14246        self._scopes.clear();
14247        self
14248    }
14249}
14250
14251/// Creates and uploads a client-side encryption S/MIME public key certificate chain and private key metadata for the authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
14252///
14253/// A builder for the *settings.cse.keypairs.create* method supported by a *user* resource.
14254/// It is not used directly, but through a [`UserMethods`] instance.
14255///
14256/// # Example
14257///
14258/// Instantiate a resource method builder
14259///
14260/// ```test_harness,no_run
14261/// # extern crate hyper;
14262/// # extern crate hyper_rustls;
14263/// # extern crate google_gmail1 as gmail1;
14264/// use gmail1::api::CseKeyPair;
14265/// # async fn dox() {
14266/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14267///
14268/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14269/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14270/// #     .with_native_roots()
14271/// #     .unwrap()
14272/// #     .https_only()
14273/// #     .enable_http2()
14274/// #     .build();
14275///
14276/// # let executor = hyper_util::rt::TokioExecutor::new();
14277/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14278/// #     secret,
14279/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14280/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14281/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14282/// #     ),
14283/// # ).build().await.unwrap();
14284///
14285/// # let client = hyper_util::client::legacy::Client::builder(
14286/// #     hyper_util::rt::TokioExecutor::new()
14287/// # )
14288/// # .build(
14289/// #     hyper_rustls::HttpsConnectorBuilder::new()
14290/// #         .with_native_roots()
14291/// #         .unwrap()
14292/// #         .https_or_http()
14293/// #         .enable_http2()
14294/// #         .build()
14295/// # );
14296/// # let mut hub = Gmail::new(client, auth);
14297/// // As the method needs a request, you would usually fill it with the desired information
14298/// // into the respective structure. Some of the parts shown here might not be applicable !
14299/// // Values shown here are possibly random and not representative !
14300/// let mut req = CseKeyPair::default();
14301///
14302/// // You can configure optional parameters by calling the respective setters at will, and
14303/// // execute the final call using `doit()`.
14304/// // Values shown here are possibly random and not representative !
14305/// let result = hub.users().settings_cse_keypairs_create(req, "userId")
14306///              .doit().await;
14307/// # }
14308/// ```
14309pub struct UserSettingCseKeypairCreateCall<'a, C>
14310where
14311    C: 'a,
14312{
14313    hub: &'a Gmail<C>,
14314    _request: CseKeyPair,
14315    _user_id: String,
14316    _delegate: Option<&'a mut dyn common::Delegate>,
14317    _additional_params: HashMap<String, String>,
14318    _scopes: BTreeSet<String>,
14319}
14320
14321impl<'a, C> common::CallBuilder for UserSettingCseKeypairCreateCall<'a, C> {}
14322
14323impl<'a, C> UserSettingCseKeypairCreateCall<'a, C>
14324where
14325    C: common::Connector,
14326{
14327    /// Perform the operation you have build so far.
14328    pub async fn doit(mut self) -> common::Result<(common::Response, CseKeyPair)> {
14329        use std::borrow::Cow;
14330        use std::io::{Read, Seek};
14331
14332        use common::{url::Params, ToParts};
14333        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14334
14335        let mut dd = common::DefaultDelegate;
14336        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14337        dlg.begin(common::MethodInfo {
14338            id: "gmail.users.settings.cse.keypairs.create",
14339            http_method: hyper::Method::POST,
14340        });
14341
14342        for &field in ["alt", "userId"].iter() {
14343            if self._additional_params.contains_key(field) {
14344                dlg.finished(false);
14345                return Err(common::Error::FieldClash(field));
14346            }
14347        }
14348
14349        let mut params = Params::with_capacity(4 + self._additional_params.len());
14350        params.push("userId", self._user_id);
14351
14352        params.extend(self._additional_params.iter());
14353
14354        params.push("alt", "json");
14355        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/cse/keypairs";
14356        if self._scopes.is_empty() {
14357            self._scopes
14358                .insert(Scope::SettingBasic.as_ref().to_string());
14359        }
14360
14361        #[allow(clippy::single_element_loop)]
14362        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
14363            url = params.uri_replacement(url, param_name, find_this, false);
14364        }
14365        {
14366            let to_remove = ["userId"];
14367            params.remove_params(&to_remove);
14368        }
14369
14370        let url = params.parse_with_url(&url);
14371
14372        let mut json_mime_type = mime::APPLICATION_JSON;
14373        let mut request_value_reader = {
14374            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14375            common::remove_json_null_values(&mut value);
14376            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14377            serde_json::to_writer(&mut dst, &value).unwrap();
14378            dst
14379        };
14380        let request_size = request_value_reader
14381            .seek(std::io::SeekFrom::End(0))
14382            .unwrap();
14383        request_value_reader
14384            .seek(std::io::SeekFrom::Start(0))
14385            .unwrap();
14386
14387        loop {
14388            let token = match self
14389                .hub
14390                .auth
14391                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14392                .await
14393            {
14394                Ok(token) => token,
14395                Err(e) => match dlg.token(e) {
14396                    Ok(token) => token,
14397                    Err(e) => {
14398                        dlg.finished(false);
14399                        return Err(common::Error::MissingToken(e));
14400                    }
14401                },
14402            };
14403            request_value_reader
14404                .seek(std::io::SeekFrom::Start(0))
14405                .unwrap();
14406            let mut req_result = {
14407                let client = &self.hub.client;
14408                dlg.pre_request();
14409                let mut req_builder = hyper::Request::builder()
14410                    .method(hyper::Method::POST)
14411                    .uri(url.as_str())
14412                    .header(USER_AGENT, self.hub._user_agent.clone());
14413
14414                if let Some(token) = token.as_ref() {
14415                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14416                }
14417
14418                let request = req_builder
14419                    .header(CONTENT_TYPE, json_mime_type.to_string())
14420                    .header(CONTENT_LENGTH, request_size as u64)
14421                    .body(common::to_body(
14422                        request_value_reader.get_ref().clone().into(),
14423                    ));
14424
14425                client.request(request.unwrap()).await
14426            };
14427
14428            match req_result {
14429                Err(err) => {
14430                    if let common::Retry::After(d) = dlg.http_error(&err) {
14431                        sleep(d).await;
14432                        continue;
14433                    }
14434                    dlg.finished(false);
14435                    return Err(common::Error::HttpError(err));
14436                }
14437                Ok(res) => {
14438                    let (mut parts, body) = res.into_parts();
14439                    let mut body = common::Body::new(body);
14440                    if !parts.status.is_success() {
14441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14442                        let error = serde_json::from_str(&common::to_string(&bytes));
14443                        let response = common::to_response(parts, bytes.into());
14444
14445                        if let common::Retry::After(d) =
14446                            dlg.http_failure(&response, error.as_ref().ok())
14447                        {
14448                            sleep(d).await;
14449                            continue;
14450                        }
14451
14452                        dlg.finished(false);
14453
14454                        return Err(match error {
14455                            Ok(value) => common::Error::BadRequest(value),
14456                            _ => common::Error::Failure(response),
14457                        });
14458                    }
14459                    let response = {
14460                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14461                        let encoded = common::to_string(&bytes);
14462                        match serde_json::from_str(&encoded) {
14463                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14464                            Err(error) => {
14465                                dlg.response_json_decode_error(&encoded, &error);
14466                                return Err(common::Error::JsonDecodeError(
14467                                    encoded.to_string(),
14468                                    error,
14469                                ));
14470                            }
14471                        }
14472                    };
14473
14474                    dlg.finished(true);
14475                    return Ok(response);
14476                }
14477            }
14478        }
14479    }
14480
14481    ///
14482    /// Sets the *request* property to the given value.
14483    ///
14484    /// Even though the property as already been set when instantiating this call,
14485    /// we provide this method for API completeness.
14486    pub fn request(mut self, new_value: CseKeyPair) -> UserSettingCseKeypairCreateCall<'a, C> {
14487        self._request = new_value;
14488        self
14489    }
14490    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
14491    ///
14492    /// Sets the *user id* path property to the given value.
14493    ///
14494    /// Even though the property as already been set when instantiating this call,
14495    /// we provide this method for API completeness.
14496    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairCreateCall<'a, C> {
14497        self._user_id = new_value.to_string();
14498        self
14499    }
14500    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14501    /// while executing the actual API request.
14502    ///
14503    /// ````text
14504    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14505    /// ````
14506    ///
14507    /// Sets the *delegate* property to the given value.
14508    pub fn delegate(
14509        mut self,
14510        new_value: &'a mut dyn common::Delegate,
14511    ) -> UserSettingCseKeypairCreateCall<'a, C> {
14512        self._delegate = Some(new_value);
14513        self
14514    }
14515
14516    /// Set any additional parameter of the query string used in the request.
14517    /// It should be used to set parameters which are not yet available through their own
14518    /// setters.
14519    ///
14520    /// Please note that this method must not be used to set any of the known parameters
14521    /// which have their own setter method. If done anyway, the request will fail.
14522    ///
14523    /// # Additional Parameters
14524    ///
14525    /// * *$.xgafv* (query-string) - V1 error format.
14526    /// * *access_token* (query-string) - OAuth access token.
14527    /// * *alt* (query-string) - Data format for response.
14528    /// * *callback* (query-string) - JSONP
14529    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14530    /// * *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.
14531    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14532    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14533    /// * *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.
14534    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14535    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14536    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairCreateCall<'a, C>
14537    where
14538        T: AsRef<str>,
14539    {
14540        self._additional_params
14541            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14542        self
14543    }
14544
14545    /// Identifies the authorization scope for the method you are building.
14546    ///
14547    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14548    /// [`Scope::SettingBasic`].
14549    ///
14550    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14551    /// tokens for more than one scope.
14552    ///
14553    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14554    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14555    /// sufficient, a read-write scope will do as well.
14556    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairCreateCall<'a, C>
14557    where
14558        St: AsRef<str>,
14559    {
14560        self._scopes.insert(String::from(scope.as_ref()));
14561        self
14562    }
14563    /// Identifies the authorization scope(s) for the method you are building.
14564    ///
14565    /// See [`Self::add_scope()`] for details.
14566    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairCreateCall<'a, C>
14567    where
14568        I: IntoIterator<Item = St>,
14569        St: AsRef<str>,
14570    {
14571        self._scopes
14572            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14573        self
14574    }
14575
14576    /// Removes all scopes, and no default scope will be used either.
14577    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14578    /// for details).
14579    pub fn clear_scopes(mut self) -> UserSettingCseKeypairCreateCall<'a, C> {
14580        self._scopes.clear();
14581        self
14582    }
14583}
14584
14585/// Turns off a client-side encryption key pair. The authenticated user can no longer use the key pair to decrypt incoming CSE message texts or sign outgoing CSE mail. To regain access, use the EnableCseKeyPair to turn on the key pair. After 30 days, you can permanently delete the key pair by using the ObliterateCseKeyPair method. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
14586///
14587/// A builder for the *settings.cse.keypairs.disable* method supported by a *user* resource.
14588/// It is not used directly, but through a [`UserMethods`] instance.
14589///
14590/// # Example
14591///
14592/// Instantiate a resource method builder
14593///
14594/// ```test_harness,no_run
14595/// # extern crate hyper;
14596/// # extern crate hyper_rustls;
14597/// # extern crate google_gmail1 as gmail1;
14598/// use gmail1::api::DisableCseKeyPairRequest;
14599/// # async fn dox() {
14600/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14601///
14602/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14603/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14604/// #     .with_native_roots()
14605/// #     .unwrap()
14606/// #     .https_only()
14607/// #     .enable_http2()
14608/// #     .build();
14609///
14610/// # let executor = hyper_util::rt::TokioExecutor::new();
14611/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14612/// #     secret,
14613/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14614/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14615/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14616/// #     ),
14617/// # ).build().await.unwrap();
14618///
14619/// # let client = hyper_util::client::legacy::Client::builder(
14620/// #     hyper_util::rt::TokioExecutor::new()
14621/// # )
14622/// # .build(
14623/// #     hyper_rustls::HttpsConnectorBuilder::new()
14624/// #         .with_native_roots()
14625/// #         .unwrap()
14626/// #         .https_or_http()
14627/// #         .enable_http2()
14628/// #         .build()
14629/// # );
14630/// # let mut hub = Gmail::new(client, auth);
14631/// // As the method needs a request, you would usually fill it with the desired information
14632/// // into the respective structure. Some of the parts shown here might not be applicable !
14633/// // Values shown here are possibly random and not representative !
14634/// let mut req = DisableCseKeyPairRequest::default();
14635///
14636/// // You can configure optional parameters by calling the respective setters at will, and
14637/// // execute the final call using `doit()`.
14638/// // Values shown here are possibly random and not representative !
14639/// let result = hub.users().settings_cse_keypairs_disable(req, "userId", "keyPairId")
14640///              .doit().await;
14641/// # }
14642/// ```
14643pub struct UserSettingCseKeypairDisableCall<'a, C>
14644where
14645    C: 'a,
14646{
14647    hub: &'a Gmail<C>,
14648    _request: DisableCseKeyPairRequest,
14649    _user_id: String,
14650    _key_pair_id: String,
14651    _delegate: Option<&'a mut dyn common::Delegate>,
14652    _additional_params: HashMap<String, String>,
14653    _scopes: BTreeSet<String>,
14654}
14655
14656impl<'a, C> common::CallBuilder for UserSettingCseKeypairDisableCall<'a, C> {}
14657
14658impl<'a, C> UserSettingCseKeypairDisableCall<'a, C>
14659where
14660    C: common::Connector,
14661{
14662    /// Perform the operation you have build so far.
14663    pub async fn doit(mut self) -> common::Result<(common::Response, CseKeyPair)> {
14664        use std::borrow::Cow;
14665        use std::io::{Read, Seek};
14666
14667        use common::{url::Params, ToParts};
14668        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14669
14670        let mut dd = common::DefaultDelegate;
14671        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14672        dlg.begin(common::MethodInfo {
14673            id: "gmail.users.settings.cse.keypairs.disable",
14674            http_method: hyper::Method::POST,
14675        });
14676
14677        for &field in ["alt", "userId", "keyPairId"].iter() {
14678            if self._additional_params.contains_key(field) {
14679                dlg.finished(false);
14680                return Err(common::Error::FieldClash(field));
14681            }
14682        }
14683
14684        let mut params = Params::with_capacity(5 + self._additional_params.len());
14685        params.push("userId", self._user_id);
14686        params.push("keyPairId", self._key_pair_id);
14687
14688        params.extend(self._additional_params.iter());
14689
14690        params.push("alt", "json");
14691        let mut url = self.hub._base_url.clone()
14692            + "gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:disable";
14693        if self._scopes.is_empty() {
14694            self._scopes
14695                .insert(Scope::SettingBasic.as_ref().to_string());
14696        }
14697
14698        #[allow(clippy::single_element_loop)]
14699        for &(find_this, param_name) in
14700            [("{userId}", "userId"), ("{keyPairId}", "keyPairId")].iter()
14701        {
14702            url = params.uri_replacement(url, param_name, find_this, false);
14703        }
14704        {
14705            let to_remove = ["keyPairId", "userId"];
14706            params.remove_params(&to_remove);
14707        }
14708
14709        let url = params.parse_with_url(&url);
14710
14711        let mut json_mime_type = mime::APPLICATION_JSON;
14712        let mut request_value_reader = {
14713            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14714            common::remove_json_null_values(&mut value);
14715            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14716            serde_json::to_writer(&mut dst, &value).unwrap();
14717            dst
14718        };
14719        let request_size = request_value_reader
14720            .seek(std::io::SeekFrom::End(0))
14721            .unwrap();
14722        request_value_reader
14723            .seek(std::io::SeekFrom::Start(0))
14724            .unwrap();
14725
14726        loop {
14727            let token = match self
14728                .hub
14729                .auth
14730                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14731                .await
14732            {
14733                Ok(token) => token,
14734                Err(e) => match dlg.token(e) {
14735                    Ok(token) => token,
14736                    Err(e) => {
14737                        dlg.finished(false);
14738                        return Err(common::Error::MissingToken(e));
14739                    }
14740                },
14741            };
14742            request_value_reader
14743                .seek(std::io::SeekFrom::Start(0))
14744                .unwrap();
14745            let mut req_result = {
14746                let client = &self.hub.client;
14747                dlg.pre_request();
14748                let mut req_builder = hyper::Request::builder()
14749                    .method(hyper::Method::POST)
14750                    .uri(url.as_str())
14751                    .header(USER_AGENT, self.hub._user_agent.clone());
14752
14753                if let Some(token) = token.as_ref() {
14754                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14755                }
14756
14757                let request = req_builder
14758                    .header(CONTENT_TYPE, json_mime_type.to_string())
14759                    .header(CONTENT_LENGTH, request_size as u64)
14760                    .body(common::to_body(
14761                        request_value_reader.get_ref().clone().into(),
14762                    ));
14763
14764                client.request(request.unwrap()).await
14765            };
14766
14767            match req_result {
14768                Err(err) => {
14769                    if let common::Retry::After(d) = dlg.http_error(&err) {
14770                        sleep(d).await;
14771                        continue;
14772                    }
14773                    dlg.finished(false);
14774                    return Err(common::Error::HttpError(err));
14775                }
14776                Ok(res) => {
14777                    let (mut parts, body) = res.into_parts();
14778                    let mut body = common::Body::new(body);
14779                    if !parts.status.is_success() {
14780                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14781                        let error = serde_json::from_str(&common::to_string(&bytes));
14782                        let response = common::to_response(parts, bytes.into());
14783
14784                        if let common::Retry::After(d) =
14785                            dlg.http_failure(&response, error.as_ref().ok())
14786                        {
14787                            sleep(d).await;
14788                            continue;
14789                        }
14790
14791                        dlg.finished(false);
14792
14793                        return Err(match error {
14794                            Ok(value) => common::Error::BadRequest(value),
14795                            _ => common::Error::Failure(response),
14796                        });
14797                    }
14798                    let response = {
14799                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14800                        let encoded = common::to_string(&bytes);
14801                        match serde_json::from_str(&encoded) {
14802                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14803                            Err(error) => {
14804                                dlg.response_json_decode_error(&encoded, &error);
14805                                return Err(common::Error::JsonDecodeError(
14806                                    encoded.to_string(),
14807                                    error,
14808                                ));
14809                            }
14810                        }
14811                    };
14812
14813                    dlg.finished(true);
14814                    return Ok(response);
14815                }
14816            }
14817        }
14818    }
14819
14820    ///
14821    /// Sets the *request* property to the given value.
14822    ///
14823    /// Even though the property as already been set when instantiating this call,
14824    /// we provide this method for API completeness.
14825    pub fn request(
14826        mut self,
14827        new_value: DisableCseKeyPairRequest,
14828    ) -> UserSettingCseKeypairDisableCall<'a, C> {
14829        self._request = new_value;
14830        self
14831    }
14832    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
14833    ///
14834    /// Sets the *user id* path property to the given value.
14835    ///
14836    /// Even though the property as already been set when instantiating this call,
14837    /// we provide this method for API completeness.
14838    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairDisableCall<'a, C> {
14839        self._user_id = new_value.to_string();
14840        self
14841    }
14842    /// The identifier of the key pair to turn off.
14843    ///
14844    /// Sets the *key pair id* path property to the given value.
14845    ///
14846    /// Even though the property as already been set when instantiating this call,
14847    /// we provide this method for API completeness.
14848    pub fn key_pair_id(mut self, new_value: &str) -> UserSettingCseKeypairDisableCall<'a, C> {
14849        self._key_pair_id = new_value.to_string();
14850        self
14851    }
14852    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14853    /// while executing the actual API request.
14854    ///
14855    /// ````text
14856    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14857    /// ````
14858    ///
14859    /// Sets the *delegate* property to the given value.
14860    pub fn delegate(
14861        mut self,
14862        new_value: &'a mut dyn common::Delegate,
14863    ) -> UserSettingCseKeypairDisableCall<'a, C> {
14864        self._delegate = Some(new_value);
14865        self
14866    }
14867
14868    /// Set any additional parameter of the query string used in the request.
14869    /// It should be used to set parameters which are not yet available through their own
14870    /// setters.
14871    ///
14872    /// Please note that this method must not be used to set any of the known parameters
14873    /// which have their own setter method. If done anyway, the request will fail.
14874    ///
14875    /// # Additional Parameters
14876    ///
14877    /// * *$.xgafv* (query-string) - V1 error format.
14878    /// * *access_token* (query-string) - OAuth access token.
14879    /// * *alt* (query-string) - Data format for response.
14880    /// * *callback* (query-string) - JSONP
14881    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14882    /// * *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.
14883    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14884    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14885    /// * *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.
14886    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14887    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14888    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairDisableCall<'a, C>
14889    where
14890        T: AsRef<str>,
14891    {
14892        self._additional_params
14893            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14894        self
14895    }
14896
14897    /// Identifies the authorization scope for the method you are building.
14898    ///
14899    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14900    /// [`Scope::SettingBasic`].
14901    ///
14902    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14903    /// tokens for more than one scope.
14904    ///
14905    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14906    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14907    /// sufficient, a read-write scope will do as well.
14908    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairDisableCall<'a, C>
14909    where
14910        St: AsRef<str>,
14911    {
14912        self._scopes.insert(String::from(scope.as_ref()));
14913        self
14914    }
14915    /// Identifies the authorization scope(s) for the method you are building.
14916    ///
14917    /// See [`Self::add_scope()`] for details.
14918    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairDisableCall<'a, C>
14919    where
14920        I: IntoIterator<Item = St>,
14921        St: AsRef<str>,
14922    {
14923        self._scopes
14924            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14925        self
14926    }
14927
14928    /// Removes all scopes, and no default scope will be used either.
14929    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14930    /// for details).
14931    pub fn clear_scopes(mut self) -> UserSettingCseKeypairDisableCall<'a, C> {
14932        self._scopes.clear();
14933        self
14934    }
14935}
14936
14937/// Turns on a client-side encryption key pair that was turned off. The key pair becomes active again for any associated client-side encryption identities. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
14938///
14939/// A builder for the *settings.cse.keypairs.enable* method supported by a *user* resource.
14940/// It is not used directly, but through a [`UserMethods`] instance.
14941///
14942/// # Example
14943///
14944/// Instantiate a resource method builder
14945///
14946/// ```test_harness,no_run
14947/// # extern crate hyper;
14948/// # extern crate hyper_rustls;
14949/// # extern crate google_gmail1 as gmail1;
14950/// use gmail1::api::EnableCseKeyPairRequest;
14951/// # async fn dox() {
14952/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14953///
14954/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14955/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14956/// #     .with_native_roots()
14957/// #     .unwrap()
14958/// #     .https_only()
14959/// #     .enable_http2()
14960/// #     .build();
14961///
14962/// # let executor = hyper_util::rt::TokioExecutor::new();
14963/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14964/// #     secret,
14965/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14966/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14967/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14968/// #     ),
14969/// # ).build().await.unwrap();
14970///
14971/// # let client = hyper_util::client::legacy::Client::builder(
14972/// #     hyper_util::rt::TokioExecutor::new()
14973/// # )
14974/// # .build(
14975/// #     hyper_rustls::HttpsConnectorBuilder::new()
14976/// #         .with_native_roots()
14977/// #         .unwrap()
14978/// #         .https_or_http()
14979/// #         .enable_http2()
14980/// #         .build()
14981/// # );
14982/// # let mut hub = Gmail::new(client, auth);
14983/// // As the method needs a request, you would usually fill it with the desired information
14984/// // into the respective structure. Some of the parts shown here might not be applicable !
14985/// // Values shown here are possibly random and not representative !
14986/// let mut req = EnableCseKeyPairRequest::default();
14987///
14988/// // You can configure optional parameters by calling the respective setters at will, and
14989/// // execute the final call using `doit()`.
14990/// // Values shown here are possibly random and not representative !
14991/// let result = hub.users().settings_cse_keypairs_enable(req, "userId", "keyPairId")
14992///              .doit().await;
14993/// # }
14994/// ```
14995pub struct UserSettingCseKeypairEnableCall<'a, C>
14996where
14997    C: 'a,
14998{
14999    hub: &'a Gmail<C>,
15000    _request: EnableCseKeyPairRequest,
15001    _user_id: String,
15002    _key_pair_id: String,
15003    _delegate: Option<&'a mut dyn common::Delegate>,
15004    _additional_params: HashMap<String, String>,
15005    _scopes: BTreeSet<String>,
15006}
15007
15008impl<'a, C> common::CallBuilder for UserSettingCseKeypairEnableCall<'a, C> {}
15009
15010impl<'a, C> UserSettingCseKeypairEnableCall<'a, C>
15011where
15012    C: common::Connector,
15013{
15014    /// Perform the operation you have build so far.
15015    pub async fn doit(mut self) -> common::Result<(common::Response, CseKeyPair)> {
15016        use std::borrow::Cow;
15017        use std::io::{Read, Seek};
15018
15019        use common::{url::Params, ToParts};
15020        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15021
15022        let mut dd = common::DefaultDelegate;
15023        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15024        dlg.begin(common::MethodInfo {
15025            id: "gmail.users.settings.cse.keypairs.enable",
15026            http_method: hyper::Method::POST,
15027        });
15028
15029        for &field in ["alt", "userId", "keyPairId"].iter() {
15030            if self._additional_params.contains_key(field) {
15031                dlg.finished(false);
15032                return Err(common::Error::FieldClash(field));
15033            }
15034        }
15035
15036        let mut params = Params::with_capacity(5 + self._additional_params.len());
15037        params.push("userId", self._user_id);
15038        params.push("keyPairId", self._key_pair_id);
15039
15040        params.extend(self._additional_params.iter());
15041
15042        params.push("alt", "json");
15043        let mut url = self.hub._base_url.clone()
15044            + "gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:enable";
15045        if self._scopes.is_empty() {
15046            self._scopes
15047                .insert(Scope::SettingBasic.as_ref().to_string());
15048        }
15049
15050        #[allow(clippy::single_element_loop)]
15051        for &(find_this, param_name) in
15052            [("{userId}", "userId"), ("{keyPairId}", "keyPairId")].iter()
15053        {
15054            url = params.uri_replacement(url, param_name, find_this, false);
15055        }
15056        {
15057            let to_remove = ["keyPairId", "userId"];
15058            params.remove_params(&to_remove);
15059        }
15060
15061        let url = params.parse_with_url(&url);
15062
15063        let mut json_mime_type = mime::APPLICATION_JSON;
15064        let mut request_value_reader = {
15065            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15066            common::remove_json_null_values(&mut value);
15067            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15068            serde_json::to_writer(&mut dst, &value).unwrap();
15069            dst
15070        };
15071        let request_size = request_value_reader
15072            .seek(std::io::SeekFrom::End(0))
15073            .unwrap();
15074        request_value_reader
15075            .seek(std::io::SeekFrom::Start(0))
15076            .unwrap();
15077
15078        loop {
15079            let token = match self
15080                .hub
15081                .auth
15082                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15083                .await
15084            {
15085                Ok(token) => token,
15086                Err(e) => match dlg.token(e) {
15087                    Ok(token) => token,
15088                    Err(e) => {
15089                        dlg.finished(false);
15090                        return Err(common::Error::MissingToken(e));
15091                    }
15092                },
15093            };
15094            request_value_reader
15095                .seek(std::io::SeekFrom::Start(0))
15096                .unwrap();
15097            let mut req_result = {
15098                let client = &self.hub.client;
15099                dlg.pre_request();
15100                let mut req_builder = hyper::Request::builder()
15101                    .method(hyper::Method::POST)
15102                    .uri(url.as_str())
15103                    .header(USER_AGENT, self.hub._user_agent.clone());
15104
15105                if let Some(token) = token.as_ref() {
15106                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15107                }
15108
15109                let request = req_builder
15110                    .header(CONTENT_TYPE, json_mime_type.to_string())
15111                    .header(CONTENT_LENGTH, request_size as u64)
15112                    .body(common::to_body(
15113                        request_value_reader.get_ref().clone().into(),
15114                    ));
15115
15116                client.request(request.unwrap()).await
15117            };
15118
15119            match req_result {
15120                Err(err) => {
15121                    if let common::Retry::After(d) = dlg.http_error(&err) {
15122                        sleep(d).await;
15123                        continue;
15124                    }
15125                    dlg.finished(false);
15126                    return Err(common::Error::HttpError(err));
15127                }
15128                Ok(res) => {
15129                    let (mut parts, body) = res.into_parts();
15130                    let mut body = common::Body::new(body);
15131                    if !parts.status.is_success() {
15132                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15133                        let error = serde_json::from_str(&common::to_string(&bytes));
15134                        let response = common::to_response(parts, bytes.into());
15135
15136                        if let common::Retry::After(d) =
15137                            dlg.http_failure(&response, error.as_ref().ok())
15138                        {
15139                            sleep(d).await;
15140                            continue;
15141                        }
15142
15143                        dlg.finished(false);
15144
15145                        return Err(match error {
15146                            Ok(value) => common::Error::BadRequest(value),
15147                            _ => common::Error::Failure(response),
15148                        });
15149                    }
15150                    let response = {
15151                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15152                        let encoded = common::to_string(&bytes);
15153                        match serde_json::from_str(&encoded) {
15154                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15155                            Err(error) => {
15156                                dlg.response_json_decode_error(&encoded, &error);
15157                                return Err(common::Error::JsonDecodeError(
15158                                    encoded.to_string(),
15159                                    error,
15160                                ));
15161                            }
15162                        }
15163                    };
15164
15165                    dlg.finished(true);
15166                    return Ok(response);
15167                }
15168            }
15169        }
15170    }
15171
15172    ///
15173    /// Sets the *request* property to the given value.
15174    ///
15175    /// Even though the property as already been set when instantiating this call,
15176    /// we provide this method for API completeness.
15177    pub fn request(
15178        mut self,
15179        new_value: EnableCseKeyPairRequest,
15180    ) -> UserSettingCseKeypairEnableCall<'a, C> {
15181        self._request = new_value;
15182        self
15183    }
15184    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
15185    ///
15186    /// Sets the *user id* path property to the given value.
15187    ///
15188    /// Even though the property as already been set when instantiating this call,
15189    /// we provide this method for API completeness.
15190    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairEnableCall<'a, C> {
15191        self._user_id = new_value.to_string();
15192        self
15193    }
15194    /// The identifier of the key pair to turn on.
15195    ///
15196    /// Sets the *key pair id* path property to the given value.
15197    ///
15198    /// Even though the property as already been set when instantiating this call,
15199    /// we provide this method for API completeness.
15200    pub fn key_pair_id(mut self, new_value: &str) -> UserSettingCseKeypairEnableCall<'a, C> {
15201        self._key_pair_id = new_value.to_string();
15202        self
15203    }
15204    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15205    /// while executing the actual API request.
15206    ///
15207    /// ````text
15208    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15209    /// ````
15210    ///
15211    /// Sets the *delegate* property to the given value.
15212    pub fn delegate(
15213        mut self,
15214        new_value: &'a mut dyn common::Delegate,
15215    ) -> UserSettingCseKeypairEnableCall<'a, C> {
15216        self._delegate = Some(new_value);
15217        self
15218    }
15219
15220    /// Set any additional parameter of the query string used in the request.
15221    /// It should be used to set parameters which are not yet available through their own
15222    /// setters.
15223    ///
15224    /// Please note that this method must not be used to set any of the known parameters
15225    /// which have their own setter method. If done anyway, the request will fail.
15226    ///
15227    /// # Additional Parameters
15228    ///
15229    /// * *$.xgafv* (query-string) - V1 error format.
15230    /// * *access_token* (query-string) - OAuth access token.
15231    /// * *alt* (query-string) - Data format for response.
15232    /// * *callback* (query-string) - JSONP
15233    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15234    /// * *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.
15235    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15236    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15237    /// * *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.
15238    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15239    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15240    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairEnableCall<'a, C>
15241    where
15242        T: AsRef<str>,
15243    {
15244        self._additional_params
15245            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15246        self
15247    }
15248
15249    /// Identifies the authorization scope for the method you are building.
15250    ///
15251    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15252    /// [`Scope::SettingBasic`].
15253    ///
15254    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15255    /// tokens for more than one scope.
15256    ///
15257    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15258    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15259    /// sufficient, a read-write scope will do as well.
15260    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairEnableCall<'a, C>
15261    where
15262        St: AsRef<str>,
15263    {
15264        self._scopes.insert(String::from(scope.as_ref()));
15265        self
15266    }
15267    /// Identifies the authorization scope(s) for the method you are building.
15268    ///
15269    /// See [`Self::add_scope()`] for details.
15270    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairEnableCall<'a, C>
15271    where
15272        I: IntoIterator<Item = St>,
15273        St: AsRef<str>,
15274    {
15275        self._scopes
15276            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15277        self
15278    }
15279
15280    /// Removes all scopes, and no default scope will be used either.
15281    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15282    /// for details).
15283    pub fn clear_scopes(mut self) -> UserSettingCseKeypairEnableCall<'a, C> {
15284        self._scopes.clear();
15285        self
15286    }
15287}
15288
15289/// Retrieves an existing client-side encryption key pair. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
15290///
15291/// A builder for the *settings.cse.keypairs.get* method supported by a *user* resource.
15292/// It is not used directly, but through a [`UserMethods`] instance.
15293///
15294/// # Example
15295///
15296/// Instantiate a resource method builder
15297///
15298/// ```test_harness,no_run
15299/// # extern crate hyper;
15300/// # extern crate hyper_rustls;
15301/// # extern crate google_gmail1 as gmail1;
15302/// # async fn dox() {
15303/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15304///
15305/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15306/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15307/// #     .with_native_roots()
15308/// #     .unwrap()
15309/// #     .https_only()
15310/// #     .enable_http2()
15311/// #     .build();
15312///
15313/// # let executor = hyper_util::rt::TokioExecutor::new();
15314/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15315/// #     secret,
15316/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15317/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15318/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15319/// #     ),
15320/// # ).build().await.unwrap();
15321///
15322/// # let client = hyper_util::client::legacy::Client::builder(
15323/// #     hyper_util::rt::TokioExecutor::new()
15324/// # )
15325/// # .build(
15326/// #     hyper_rustls::HttpsConnectorBuilder::new()
15327/// #         .with_native_roots()
15328/// #         .unwrap()
15329/// #         .https_or_http()
15330/// #         .enable_http2()
15331/// #         .build()
15332/// # );
15333/// # let mut hub = Gmail::new(client, auth);
15334/// // You can configure optional parameters by calling the respective setters at will, and
15335/// // execute the final call using `doit()`.
15336/// // Values shown here are possibly random and not representative !
15337/// let result = hub.users().settings_cse_keypairs_get("userId", "keyPairId")
15338///              .doit().await;
15339/// # }
15340/// ```
15341pub struct UserSettingCseKeypairGetCall<'a, C>
15342where
15343    C: 'a,
15344{
15345    hub: &'a Gmail<C>,
15346    _user_id: String,
15347    _key_pair_id: String,
15348    _delegate: Option<&'a mut dyn common::Delegate>,
15349    _additional_params: HashMap<String, String>,
15350    _scopes: BTreeSet<String>,
15351}
15352
15353impl<'a, C> common::CallBuilder for UserSettingCseKeypairGetCall<'a, C> {}
15354
15355impl<'a, C> UserSettingCseKeypairGetCall<'a, C>
15356where
15357    C: common::Connector,
15358{
15359    /// Perform the operation you have build so far.
15360    pub async fn doit(mut self) -> common::Result<(common::Response, CseKeyPair)> {
15361        use std::borrow::Cow;
15362        use std::io::{Read, Seek};
15363
15364        use common::{url::Params, ToParts};
15365        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15366
15367        let mut dd = common::DefaultDelegate;
15368        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15369        dlg.begin(common::MethodInfo {
15370            id: "gmail.users.settings.cse.keypairs.get",
15371            http_method: hyper::Method::GET,
15372        });
15373
15374        for &field in ["alt", "userId", "keyPairId"].iter() {
15375            if self._additional_params.contains_key(field) {
15376                dlg.finished(false);
15377                return Err(common::Error::FieldClash(field));
15378            }
15379        }
15380
15381        let mut params = Params::with_capacity(4 + self._additional_params.len());
15382        params.push("userId", self._user_id);
15383        params.push("keyPairId", self._key_pair_id);
15384
15385        params.extend(self._additional_params.iter());
15386
15387        params.push("alt", "json");
15388        let mut url = self.hub._base_url.clone()
15389            + "gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}";
15390        if self._scopes.is_empty() {
15391            self._scopes.insert(Scope::Readonly.as_ref().to_string());
15392        }
15393
15394        #[allow(clippy::single_element_loop)]
15395        for &(find_this, param_name) in
15396            [("{userId}", "userId"), ("{keyPairId}", "keyPairId")].iter()
15397        {
15398            url = params.uri_replacement(url, param_name, find_this, false);
15399        }
15400        {
15401            let to_remove = ["keyPairId", "userId"];
15402            params.remove_params(&to_remove);
15403        }
15404
15405        let url = params.parse_with_url(&url);
15406
15407        loop {
15408            let token = match self
15409                .hub
15410                .auth
15411                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15412                .await
15413            {
15414                Ok(token) => token,
15415                Err(e) => match dlg.token(e) {
15416                    Ok(token) => token,
15417                    Err(e) => {
15418                        dlg.finished(false);
15419                        return Err(common::Error::MissingToken(e));
15420                    }
15421                },
15422            };
15423            let mut req_result = {
15424                let client = &self.hub.client;
15425                dlg.pre_request();
15426                let mut req_builder = hyper::Request::builder()
15427                    .method(hyper::Method::GET)
15428                    .uri(url.as_str())
15429                    .header(USER_AGENT, self.hub._user_agent.clone());
15430
15431                if let Some(token) = token.as_ref() {
15432                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15433                }
15434
15435                let request = req_builder
15436                    .header(CONTENT_LENGTH, 0_u64)
15437                    .body(common::to_body::<String>(None));
15438
15439                client.request(request.unwrap()).await
15440            };
15441
15442            match req_result {
15443                Err(err) => {
15444                    if let common::Retry::After(d) = dlg.http_error(&err) {
15445                        sleep(d).await;
15446                        continue;
15447                    }
15448                    dlg.finished(false);
15449                    return Err(common::Error::HttpError(err));
15450                }
15451                Ok(res) => {
15452                    let (mut parts, body) = res.into_parts();
15453                    let mut body = common::Body::new(body);
15454                    if !parts.status.is_success() {
15455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15456                        let error = serde_json::from_str(&common::to_string(&bytes));
15457                        let response = common::to_response(parts, bytes.into());
15458
15459                        if let common::Retry::After(d) =
15460                            dlg.http_failure(&response, error.as_ref().ok())
15461                        {
15462                            sleep(d).await;
15463                            continue;
15464                        }
15465
15466                        dlg.finished(false);
15467
15468                        return Err(match error {
15469                            Ok(value) => common::Error::BadRequest(value),
15470                            _ => common::Error::Failure(response),
15471                        });
15472                    }
15473                    let response = {
15474                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15475                        let encoded = common::to_string(&bytes);
15476                        match serde_json::from_str(&encoded) {
15477                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15478                            Err(error) => {
15479                                dlg.response_json_decode_error(&encoded, &error);
15480                                return Err(common::Error::JsonDecodeError(
15481                                    encoded.to_string(),
15482                                    error,
15483                                ));
15484                            }
15485                        }
15486                    };
15487
15488                    dlg.finished(true);
15489                    return Ok(response);
15490                }
15491            }
15492        }
15493    }
15494
15495    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
15496    ///
15497    /// Sets the *user id* path property to the given value.
15498    ///
15499    /// Even though the property as already been set when instantiating this call,
15500    /// we provide this method for API completeness.
15501    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairGetCall<'a, C> {
15502        self._user_id = new_value.to_string();
15503        self
15504    }
15505    /// The identifier of the key pair to retrieve.
15506    ///
15507    /// Sets the *key pair id* path property to the given value.
15508    ///
15509    /// Even though the property as already been set when instantiating this call,
15510    /// we provide this method for API completeness.
15511    pub fn key_pair_id(mut self, new_value: &str) -> UserSettingCseKeypairGetCall<'a, C> {
15512        self._key_pair_id = new_value.to_string();
15513        self
15514    }
15515    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15516    /// while executing the actual API request.
15517    ///
15518    /// ````text
15519    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15520    /// ````
15521    ///
15522    /// Sets the *delegate* property to the given value.
15523    pub fn delegate(
15524        mut self,
15525        new_value: &'a mut dyn common::Delegate,
15526    ) -> UserSettingCseKeypairGetCall<'a, C> {
15527        self._delegate = Some(new_value);
15528        self
15529    }
15530
15531    /// Set any additional parameter of the query string used in the request.
15532    /// It should be used to set parameters which are not yet available through their own
15533    /// setters.
15534    ///
15535    /// Please note that this method must not be used to set any of the known parameters
15536    /// which have their own setter method. If done anyway, the request will fail.
15537    ///
15538    /// # Additional Parameters
15539    ///
15540    /// * *$.xgafv* (query-string) - V1 error format.
15541    /// * *access_token* (query-string) - OAuth access token.
15542    /// * *alt* (query-string) - Data format for response.
15543    /// * *callback* (query-string) - JSONP
15544    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15545    /// * *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.
15546    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15547    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15548    /// * *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.
15549    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15550    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15551    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairGetCall<'a, C>
15552    where
15553        T: AsRef<str>,
15554    {
15555        self._additional_params
15556            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15557        self
15558    }
15559
15560    /// Identifies the authorization scope for the method you are building.
15561    ///
15562    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15563    /// [`Scope::Readonly`].
15564    ///
15565    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15566    /// tokens for more than one scope.
15567    ///
15568    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15569    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15570    /// sufficient, a read-write scope will do as well.
15571    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairGetCall<'a, C>
15572    where
15573        St: AsRef<str>,
15574    {
15575        self._scopes.insert(String::from(scope.as_ref()));
15576        self
15577    }
15578    /// Identifies the authorization scope(s) for the method you are building.
15579    ///
15580    /// See [`Self::add_scope()`] for details.
15581    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairGetCall<'a, C>
15582    where
15583        I: IntoIterator<Item = St>,
15584        St: AsRef<str>,
15585    {
15586        self._scopes
15587            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15588        self
15589    }
15590
15591    /// Removes all scopes, and no default scope will be used either.
15592    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15593    /// for details).
15594    pub fn clear_scopes(mut self) -> UserSettingCseKeypairGetCall<'a, C> {
15595        self._scopes.clear();
15596        self
15597    }
15598}
15599
15600/// Lists client-side encryption key pairs for an authenticated user. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
15601///
15602/// A builder for the *settings.cse.keypairs.list* method supported by a *user* resource.
15603/// It is not used directly, but through a [`UserMethods`] instance.
15604///
15605/// # Example
15606///
15607/// Instantiate a resource method builder
15608///
15609/// ```test_harness,no_run
15610/// # extern crate hyper;
15611/// # extern crate hyper_rustls;
15612/// # extern crate google_gmail1 as gmail1;
15613/// # async fn dox() {
15614/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15615///
15616/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15617/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15618/// #     .with_native_roots()
15619/// #     .unwrap()
15620/// #     .https_only()
15621/// #     .enable_http2()
15622/// #     .build();
15623///
15624/// # let executor = hyper_util::rt::TokioExecutor::new();
15625/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15626/// #     secret,
15627/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15628/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15629/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15630/// #     ),
15631/// # ).build().await.unwrap();
15632///
15633/// # let client = hyper_util::client::legacy::Client::builder(
15634/// #     hyper_util::rt::TokioExecutor::new()
15635/// # )
15636/// # .build(
15637/// #     hyper_rustls::HttpsConnectorBuilder::new()
15638/// #         .with_native_roots()
15639/// #         .unwrap()
15640/// #         .https_or_http()
15641/// #         .enable_http2()
15642/// #         .build()
15643/// # );
15644/// # let mut hub = Gmail::new(client, auth);
15645/// // You can configure optional parameters by calling the respective setters at will, and
15646/// // execute the final call using `doit()`.
15647/// // Values shown here are possibly random and not representative !
15648/// let result = hub.users().settings_cse_keypairs_list("userId")
15649///              .page_token("tempor")
15650///              .page_size(-32)
15651///              .doit().await;
15652/// # }
15653/// ```
15654pub struct UserSettingCseKeypairListCall<'a, C>
15655where
15656    C: 'a,
15657{
15658    hub: &'a Gmail<C>,
15659    _user_id: String,
15660    _page_token: Option<String>,
15661    _page_size: Option<i32>,
15662    _delegate: Option<&'a mut dyn common::Delegate>,
15663    _additional_params: HashMap<String, String>,
15664    _scopes: BTreeSet<String>,
15665}
15666
15667impl<'a, C> common::CallBuilder for UserSettingCseKeypairListCall<'a, C> {}
15668
15669impl<'a, C> UserSettingCseKeypairListCall<'a, C>
15670where
15671    C: common::Connector,
15672{
15673    /// Perform the operation you have build so far.
15674    pub async fn doit(mut self) -> common::Result<(common::Response, ListCseKeyPairsResponse)> {
15675        use std::borrow::Cow;
15676        use std::io::{Read, Seek};
15677
15678        use common::{url::Params, ToParts};
15679        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15680
15681        let mut dd = common::DefaultDelegate;
15682        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15683        dlg.begin(common::MethodInfo {
15684            id: "gmail.users.settings.cse.keypairs.list",
15685            http_method: hyper::Method::GET,
15686        });
15687
15688        for &field in ["alt", "userId", "pageToken", "pageSize"].iter() {
15689            if self._additional_params.contains_key(field) {
15690                dlg.finished(false);
15691                return Err(common::Error::FieldClash(field));
15692            }
15693        }
15694
15695        let mut params = Params::with_capacity(5 + self._additional_params.len());
15696        params.push("userId", self._user_id);
15697        if let Some(value) = self._page_token.as_ref() {
15698            params.push("pageToken", value);
15699        }
15700        if let Some(value) = self._page_size.as_ref() {
15701            params.push("pageSize", value.to_string());
15702        }
15703
15704        params.extend(self._additional_params.iter());
15705
15706        params.push("alt", "json");
15707        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/cse/keypairs";
15708        if self._scopes.is_empty() {
15709            self._scopes.insert(Scope::Readonly.as_ref().to_string());
15710        }
15711
15712        #[allow(clippy::single_element_loop)]
15713        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
15714            url = params.uri_replacement(url, param_name, find_this, false);
15715        }
15716        {
15717            let to_remove = ["userId"];
15718            params.remove_params(&to_remove);
15719        }
15720
15721        let url = params.parse_with_url(&url);
15722
15723        loop {
15724            let token = match self
15725                .hub
15726                .auth
15727                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15728                .await
15729            {
15730                Ok(token) => token,
15731                Err(e) => match dlg.token(e) {
15732                    Ok(token) => token,
15733                    Err(e) => {
15734                        dlg.finished(false);
15735                        return Err(common::Error::MissingToken(e));
15736                    }
15737                },
15738            };
15739            let mut req_result = {
15740                let client = &self.hub.client;
15741                dlg.pre_request();
15742                let mut req_builder = hyper::Request::builder()
15743                    .method(hyper::Method::GET)
15744                    .uri(url.as_str())
15745                    .header(USER_AGENT, self.hub._user_agent.clone());
15746
15747                if let Some(token) = token.as_ref() {
15748                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15749                }
15750
15751                let request = req_builder
15752                    .header(CONTENT_LENGTH, 0_u64)
15753                    .body(common::to_body::<String>(None));
15754
15755                client.request(request.unwrap()).await
15756            };
15757
15758            match req_result {
15759                Err(err) => {
15760                    if let common::Retry::After(d) = dlg.http_error(&err) {
15761                        sleep(d).await;
15762                        continue;
15763                    }
15764                    dlg.finished(false);
15765                    return Err(common::Error::HttpError(err));
15766                }
15767                Ok(res) => {
15768                    let (mut parts, body) = res.into_parts();
15769                    let mut body = common::Body::new(body);
15770                    if !parts.status.is_success() {
15771                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15772                        let error = serde_json::from_str(&common::to_string(&bytes));
15773                        let response = common::to_response(parts, bytes.into());
15774
15775                        if let common::Retry::After(d) =
15776                            dlg.http_failure(&response, error.as_ref().ok())
15777                        {
15778                            sleep(d).await;
15779                            continue;
15780                        }
15781
15782                        dlg.finished(false);
15783
15784                        return Err(match error {
15785                            Ok(value) => common::Error::BadRequest(value),
15786                            _ => common::Error::Failure(response),
15787                        });
15788                    }
15789                    let response = {
15790                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15791                        let encoded = common::to_string(&bytes);
15792                        match serde_json::from_str(&encoded) {
15793                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15794                            Err(error) => {
15795                                dlg.response_json_decode_error(&encoded, &error);
15796                                return Err(common::Error::JsonDecodeError(
15797                                    encoded.to_string(),
15798                                    error,
15799                                ));
15800                            }
15801                        }
15802                    };
15803
15804                    dlg.finished(true);
15805                    return Ok(response);
15806                }
15807            }
15808        }
15809    }
15810
15811    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
15812    ///
15813    /// Sets the *user id* path property to the given value.
15814    ///
15815    /// Even though the property as already been set when instantiating this call,
15816    /// we provide this method for API completeness.
15817    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairListCall<'a, C> {
15818        self._user_id = new_value.to_string();
15819        self
15820    }
15821    /// Pagination token indicating which page of key pairs to return. If the token is not supplied, then the API will return the first page of results.
15822    ///
15823    /// Sets the *page token* query property to the given value.
15824    pub fn page_token(mut self, new_value: &str) -> UserSettingCseKeypairListCall<'a, C> {
15825        self._page_token = Some(new_value.to_string());
15826        self
15827    }
15828    /// The number of key pairs to return. If not provided, the page size will default to 20 entries.
15829    ///
15830    /// Sets the *page size* query property to the given value.
15831    pub fn page_size(mut self, new_value: i32) -> UserSettingCseKeypairListCall<'a, C> {
15832        self._page_size = Some(new_value);
15833        self
15834    }
15835    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15836    /// while executing the actual API request.
15837    ///
15838    /// ````text
15839    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15840    /// ````
15841    ///
15842    /// Sets the *delegate* property to the given value.
15843    pub fn delegate(
15844        mut self,
15845        new_value: &'a mut dyn common::Delegate,
15846    ) -> UserSettingCseKeypairListCall<'a, C> {
15847        self._delegate = Some(new_value);
15848        self
15849    }
15850
15851    /// Set any additional parameter of the query string used in the request.
15852    /// It should be used to set parameters which are not yet available through their own
15853    /// setters.
15854    ///
15855    /// Please note that this method must not be used to set any of the known parameters
15856    /// which have their own setter method. If done anyway, the request will fail.
15857    ///
15858    /// # Additional Parameters
15859    ///
15860    /// * *$.xgafv* (query-string) - V1 error format.
15861    /// * *access_token* (query-string) - OAuth access token.
15862    /// * *alt* (query-string) - Data format for response.
15863    /// * *callback* (query-string) - JSONP
15864    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15865    /// * *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.
15866    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15867    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15868    /// * *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.
15869    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15870    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15871    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairListCall<'a, C>
15872    where
15873        T: AsRef<str>,
15874    {
15875        self._additional_params
15876            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15877        self
15878    }
15879
15880    /// Identifies the authorization scope for the method you are building.
15881    ///
15882    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15883    /// [`Scope::Readonly`].
15884    ///
15885    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15886    /// tokens for more than one scope.
15887    ///
15888    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15889    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15890    /// sufficient, a read-write scope will do as well.
15891    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairListCall<'a, C>
15892    where
15893        St: AsRef<str>,
15894    {
15895        self._scopes.insert(String::from(scope.as_ref()));
15896        self
15897    }
15898    /// Identifies the authorization scope(s) for the method you are building.
15899    ///
15900    /// See [`Self::add_scope()`] for details.
15901    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairListCall<'a, C>
15902    where
15903        I: IntoIterator<Item = St>,
15904        St: AsRef<str>,
15905    {
15906        self._scopes
15907            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15908        self
15909    }
15910
15911    /// Removes all scopes, and no default scope will be used either.
15912    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15913    /// for details).
15914    pub fn clear_scopes(mut self) -> UserSettingCseKeypairListCall<'a, C> {
15915        self._scopes.clear();
15916        self
15917    }
15918}
15919
15920/// Deletes a client-side encryption key pair permanently and immediately. You can only permanently delete key pairs that have been turned off for more than 30 days. To turn off a key pair, use the DisableCseKeyPair method. Gmail can't restore or decrypt any messages that were encrypted by an obliterated key. Authenticated users and Google Workspace administrators lose access to reading the encrypted messages. For administrators managing identities and keypairs for users in their organization, requests require authorization with a [service account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount) that has [domain-wide delegation authority](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority) to impersonate users with the `https://www.googleapis.com/auth/gmail.settings.basic` scope. For users managing their own identities and keypairs, requests require [hardware key encryption](https://support.google.com/a/answer/14153163) turned on and configured.
15921///
15922/// A builder for the *settings.cse.keypairs.obliterate* method supported by a *user* resource.
15923/// It is not used directly, but through a [`UserMethods`] instance.
15924///
15925/// # Example
15926///
15927/// Instantiate a resource method builder
15928///
15929/// ```test_harness,no_run
15930/// # extern crate hyper;
15931/// # extern crate hyper_rustls;
15932/// # extern crate google_gmail1 as gmail1;
15933/// use gmail1::api::ObliterateCseKeyPairRequest;
15934/// # async fn dox() {
15935/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15936///
15937/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15938/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15939/// #     .with_native_roots()
15940/// #     .unwrap()
15941/// #     .https_only()
15942/// #     .enable_http2()
15943/// #     .build();
15944///
15945/// # let executor = hyper_util::rt::TokioExecutor::new();
15946/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15947/// #     secret,
15948/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15949/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
15950/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
15951/// #     ),
15952/// # ).build().await.unwrap();
15953///
15954/// # let client = hyper_util::client::legacy::Client::builder(
15955/// #     hyper_util::rt::TokioExecutor::new()
15956/// # )
15957/// # .build(
15958/// #     hyper_rustls::HttpsConnectorBuilder::new()
15959/// #         .with_native_roots()
15960/// #         .unwrap()
15961/// #         .https_or_http()
15962/// #         .enable_http2()
15963/// #         .build()
15964/// # );
15965/// # let mut hub = Gmail::new(client, auth);
15966/// // As the method needs a request, you would usually fill it with the desired information
15967/// // into the respective structure. Some of the parts shown here might not be applicable !
15968/// // Values shown here are possibly random and not representative !
15969/// let mut req = ObliterateCseKeyPairRequest::default();
15970///
15971/// // You can configure optional parameters by calling the respective setters at will, and
15972/// // execute the final call using `doit()`.
15973/// // Values shown here are possibly random and not representative !
15974/// let result = hub.users().settings_cse_keypairs_obliterate(req, "userId", "keyPairId")
15975///              .doit().await;
15976/// # }
15977/// ```
15978pub struct UserSettingCseKeypairObliterateCall<'a, C>
15979where
15980    C: 'a,
15981{
15982    hub: &'a Gmail<C>,
15983    _request: ObliterateCseKeyPairRequest,
15984    _user_id: String,
15985    _key_pair_id: String,
15986    _delegate: Option<&'a mut dyn common::Delegate>,
15987    _additional_params: HashMap<String, String>,
15988    _scopes: BTreeSet<String>,
15989}
15990
15991impl<'a, C> common::CallBuilder for UserSettingCseKeypairObliterateCall<'a, C> {}
15992
15993impl<'a, C> UserSettingCseKeypairObliterateCall<'a, C>
15994where
15995    C: common::Connector,
15996{
15997    /// Perform the operation you have build so far.
15998    pub async fn doit(mut self) -> common::Result<common::Response> {
15999        use std::borrow::Cow;
16000        use std::io::{Read, Seek};
16001
16002        use common::{url::Params, ToParts};
16003        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16004
16005        let mut dd = common::DefaultDelegate;
16006        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16007        dlg.begin(common::MethodInfo {
16008            id: "gmail.users.settings.cse.keypairs.obliterate",
16009            http_method: hyper::Method::POST,
16010        });
16011
16012        for &field in ["userId", "keyPairId"].iter() {
16013            if self._additional_params.contains_key(field) {
16014                dlg.finished(false);
16015                return Err(common::Error::FieldClash(field));
16016            }
16017        }
16018
16019        let mut params = Params::with_capacity(4 + self._additional_params.len());
16020        params.push("userId", self._user_id);
16021        params.push("keyPairId", self._key_pair_id);
16022
16023        params.extend(self._additional_params.iter());
16024
16025        let mut url = self.hub._base_url.clone()
16026            + "gmail/v1/users/{userId}/settings/cse/keypairs/{keyPairId}:obliterate";
16027        if self._scopes.is_empty() {
16028            self._scopes
16029                .insert(Scope::SettingBasic.as_ref().to_string());
16030        }
16031
16032        #[allow(clippy::single_element_loop)]
16033        for &(find_this, param_name) in
16034            [("{userId}", "userId"), ("{keyPairId}", "keyPairId")].iter()
16035        {
16036            url = params.uri_replacement(url, param_name, find_this, false);
16037        }
16038        {
16039            let to_remove = ["keyPairId", "userId"];
16040            params.remove_params(&to_remove);
16041        }
16042
16043        let url = params.parse_with_url(&url);
16044
16045        let mut json_mime_type = mime::APPLICATION_JSON;
16046        let mut request_value_reader = {
16047            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16048            common::remove_json_null_values(&mut value);
16049            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16050            serde_json::to_writer(&mut dst, &value).unwrap();
16051            dst
16052        };
16053        let request_size = request_value_reader
16054            .seek(std::io::SeekFrom::End(0))
16055            .unwrap();
16056        request_value_reader
16057            .seek(std::io::SeekFrom::Start(0))
16058            .unwrap();
16059
16060        loop {
16061            let token = match self
16062                .hub
16063                .auth
16064                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16065                .await
16066            {
16067                Ok(token) => token,
16068                Err(e) => match dlg.token(e) {
16069                    Ok(token) => token,
16070                    Err(e) => {
16071                        dlg.finished(false);
16072                        return Err(common::Error::MissingToken(e));
16073                    }
16074                },
16075            };
16076            request_value_reader
16077                .seek(std::io::SeekFrom::Start(0))
16078                .unwrap();
16079            let mut req_result = {
16080                let client = &self.hub.client;
16081                dlg.pre_request();
16082                let mut req_builder = hyper::Request::builder()
16083                    .method(hyper::Method::POST)
16084                    .uri(url.as_str())
16085                    .header(USER_AGENT, self.hub._user_agent.clone());
16086
16087                if let Some(token) = token.as_ref() {
16088                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16089                }
16090
16091                let request = req_builder
16092                    .header(CONTENT_TYPE, json_mime_type.to_string())
16093                    .header(CONTENT_LENGTH, request_size as u64)
16094                    .body(common::to_body(
16095                        request_value_reader.get_ref().clone().into(),
16096                    ));
16097
16098                client.request(request.unwrap()).await
16099            };
16100
16101            match req_result {
16102                Err(err) => {
16103                    if let common::Retry::After(d) = dlg.http_error(&err) {
16104                        sleep(d).await;
16105                        continue;
16106                    }
16107                    dlg.finished(false);
16108                    return Err(common::Error::HttpError(err));
16109                }
16110                Ok(res) => {
16111                    let (mut parts, body) = res.into_parts();
16112                    let mut body = common::Body::new(body);
16113                    if !parts.status.is_success() {
16114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16115                        let error = serde_json::from_str(&common::to_string(&bytes));
16116                        let response = common::to_response(parts, bytes.into());
16117
16118                        if let common::Retry::After(d) =
16119                            dlg.http_failure(&response, error.as_ref().ok())
16120                        {
16121                            sleep(d).await;
16122                            continue;
16123                        }
16124
16125                        dlg.finished(false);
16126
16127                        return Err(match error {
16128                            Ok(value) => common::Error::BadRequest(value),
16129                            _ => common::Error::Failure(response),
16130                        });
16131                    }
16132                    let response = common::Response::from_parts(parts, body);
16133
16134                    dlg.finished(true);
16135                    return Ok(response);
16136                }
16137            }
16138        }
16139    }
16140
16141    ///
16142    /// Sets the *request* property to the given value.
16143    ///
16144    /// Even though the property as already been set when instantiating this call,
16145    /// we provide this method for API completeness.
16146    pub fn request(
16147        mut self,
16148        new_value: ObliterateCseKeyPairRequest,
16149    ) -> UserSettingCseKeypairObliterateCall<'a, C> {
16150        self._request = new_value;
16151        self
16152    }
16153    /// The requester's primary email address. To indicate the authenticated user, you can use the special value `me`.
16154    ///
16155    /// Sets the *user id* path property to the given value.
16156    ///
16157    /// Even though the property as already been set when instantiating this call,
16158    /// we provide this method for API completeness.
16159    pub fn user_id(mut self, new_value: &str) -> UserSettingCseKeypairObliterateCall<'a, C> {
16160        self._user_id = new_value.to_string();
16161        self
16162    }
16163    /// The identifier of the key pair to obliterate.
16164    ///
16165    /// Sets the *key pair id* path property to the given value.
16166    ///
16167    /// Even though the property as already been set when instantiating this call,
16168    /// we provide this method for API completeness.
16169    pub fn key_pair_id(mut self, new_value: &str) -> UserSettingCseKeypairObliterateCall<'a, C> {
16170        self._key_pair_id = new_value.to_string();
16171        self
16172    }
16173    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16174    /// while executing the actual API request.
16175    ///
16176    /// ````text
16177    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16178    /// ````
16179    ///
16180    /// Sets the *delegate* property to the given value.
16181    pub fn delegate(
16182        mut self,
16183        new_value: &'a mut dyn common::Delegate,
16184    ) -> UserSettingCseKeypairObliterateCall<'a, C> {
16185        self._delegate = Some(new_value);
16186        self
16187    }
16188
16189    /// Set any additional parameter of the query string used in the request.
16190    /// It should be used to set parameters which are not yet available through their own
16191    /// setters.
16192    ///
16193    /// Please note that this method must not be used to set any of the known parameters
16194    /// which have their own setter method. If done anyway, the request will fail.
16195    ///
16196    /// # Additional Parameters
16197    ///
16198    /// * *$.xgafv* (query-string) - V1 error format.
16199    /// * *access_token* (query-string) - OAuth access token.
16200    /// * *alt* (query-string) - Data format for response.
16201    /// * *callback* (query-string) - JSONP
16202    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16203    /// * *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.
16204    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16205    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16206    /// * *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.
16207    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16208    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16209    pub fn param<T>(mut self, name: T, value: T) -> UserSettingCseKeypairObliterateCall<'a, C>
16210    where
16211        T: AsRef<str>,
16212    {
16213        self._additional_params
16214            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16215        self
16216    }
16217
16218    /// Identifies the authorization scope for the method you are building.
16219    ///
16220    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16221    /// [`Scope::SettingBasic`].
16222    ///
16223    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16224    /// tokens for more than one scope.
16225    ///
16226    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16227    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16228    /// sufficient, a read-write scope will do as well.
16229    pub fn add_scope<St>(mut self, scope: St) -> UserSettingCseKeypairObliterateCall<'a, C>
16230    where
16231        St: AsRef<str>,
16232    {
16233        self._scopes.insert(String::from(scope.as_ref()));
16234        self
16235    }
16236    /// Identifies the authorization scope(s) for the method you are building.
16237    ///
16238    /// See [`Self::add_scope()`] for details.
16239    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingCseKeypairObliterateCall<'a, C>
16240    where
16241        I: IntoIterator<Item = St>,
16242        St: AsRef<str>,
16243    {
16244        self._scopes
16245            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16246        self
16247    }
16248
16249    /// Removes all scopes, and no default scope will be used either.
16250    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16251    /// for details).
16252    pub fn clear_scopes(mut self) -> UserSettingCseKeypairObliterateCall<'a, C> {
16253        self._scopes.clear();
16254        self
16255    }
16256}
16257
16258/// Adds a delegate with its verification status set directly to `accepted`, without sending any verification email. The delegate user must be a member of the same Google Workspace organization as the delegator user. Gmail imposes limitations on the number of delegates and delegators each user in a Google Workspace organization can have. These limits depend on your organization, but in general each user can have up to 25 delegates and up to 10 delegators. Note that a delegate user must be referred to by their primary email address, and not an email alias. Also note that when a new delegate is created, there may be up to a one minute delay before the new delegate is available for use. This method is only available to service account clients that have been delegated domain-wide authority.
16259///
16260/// A builder for the *settings.delegates.create* method supported by a *user* resource.
16261/// It is not used directly, but through a [`UserMethods`] instance.
16262///
16263/// # Example
16264///
16265/// Instantiate a resource method builder
16266///
16267/// ```test_harness,no_run
16268/// # extern crate hyper;
16269/// # extern crate hyper_rustls;
16270/// # extern crate google_gmail1 as gmail1;
16271/// use gmail1::api::Delegate;
16272/// # async fn dox() {
16273/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16274///
16275/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16276/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16277/// #     .with_native_roots()
16278/// #     .unwrap()
16279/// #     .https_only()
16280/// #     .enable_http2()
16281/// #     .build();
16282///
16283/// # let executor = hyper_util::rt::TokioExecutor::new();
16284/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16285/// #     secret,
16286/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16287/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16288/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16289/// #     ),
16290/// # ).build().await.unwrap();
16291///
16292/// # let client = hyper_util::client::legacy::Client::builder(
16293/// #     hyper_util::rt::TokioExecutor::new()
16294/// # )
16295/// # .build(
16296/// #     hyper_rustls::HttpsConnectorBuilder::new()
16297/// #         .with_native_roots()
16298/// #         .unwrap()
16299/// #         .https_or_http()
16300/// #         .enable_http2()
16301/// #         .build()
16302/// # );
16303/// # let mut hub = Gmail::new(client, auth);
16304/// // As the method needs a request, you would usually fill it with the desired information
16305/// // into the respective structure. Some of the parts shown here might not be applicable !
16306/// // Values shown here are possibly random and not representative !
16307/// let mut req = Delegate::default();
16308///
16309/// // You can configure optional parameters by calling the respective setters at will, and
16310/// // execute the final call using `doit()`.
16311/// // Values shown here are possibly random and not representative !
16312/// let result = hub.users().settings_delegates_create(req, "userId")
16313///              .doit().await;
16314/// # }
16315/// ```
16316pub struct UserSettingDelegateCreateCall<'a, C>
16317where
16318    C: 'a,
16319{
16320    hub: &'a Gmail<C>,
16321    _request: Delegate,
16322    _user_id: String,
16323    _delegate: Option<&'a mut dyn common::Delegate>,
16324    _additional_params: HashMap<String, String>,
16325    _scopes: BTreeSet<String>,
16326}
16327
16328impl<'a, C> common::CallBuilder for UserSettingDelegateCreateCall<'a, C> {}
16329
16330impl<'a, C> UserSettingDelegateCreateCall<'a, C>
16331where
16332    C: common::Connector,
16333{
16334    /// Perform the operation you have build so far.
16335    pub async fn doit(mut self) -> common::Result<(common::Response, Delegate)> {
16336        use std::borrow::Cow;
16337        use std::io::{Read, Seek};
16338
16339        use common::{url::Params, ToParts};
16340        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16341
16342        let mut dd = common::DefaultDelegate;
16343        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16344        dlg.begin(common::MethodInfo {
16345            id: "gmail.users.settings.delegates.create",
16346            http_method: hyper::Method::POST,
16347        });
16348
16349        for &field in ["alt", "userId"].iter() {
16350            if self._additional_params.contains_key(field) {
16351                dlg.finished(false);
16352                return Err(common::Error::FieldClash(field));
16353            }
16354        }
16355
16356        let mut params = Params::with_capacity(4 + self._additional_params.len());
16357        params.push("userId", self._user_id);
16358
16359        params.extend(self._additional_params.iter());
16360
16361        params.push("alt", "json");
16362        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/delegates";
16363        if self._scopes.is_empty() {
16364            self._scopes
16365                .insert(Scope::SettingSharing.as_ref().to_string());
16366        }
16367
16368        #[allow(clippy::single_element_loop)]
16369        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
16370            url = params.uri_replacement(url, param_name, find_this, false);
16371        }
16372        {
16373            let to_remove = ["userId"];
16374            params.remove_params(&to_remove);
16375        }
16376
16377        let url = params.parse_with_url(&url);
16378
16379        let mut json_mime_type = mime::APPLICATION_JSON;
16380        let mut request_value_reader = {
16381            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16382            common::remove_json_null_values(&mut value);
16383            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16384            serde_json::to_writer(&mut dst, &value).unwrap();
16385            dst
16386        };
16387        let request_size = request_value_reader
16388            .seek(std::io::SeekFrom::End(0))
16389            .unwrap();
16390        request_value_reader
16391            .seek(std::io::SeekFrom::Start(0))
16392            .unwrap();
16393
16394        loop {
16395            let token = match self
16396                .hub
16397                .auth
16398                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16399                .await
16400            {
16401                Ok(token) => token,
16402                Err(e) => match dlg.token(e) {
16403                    Ok(token) => token,
16404                    Err(e) => {
16405                        dlg.finished(false);
16406                        return Err(common::Error::MissingToken(e));
16407                    }
16408                },
16409            };
16410            request_value_reader
16411                .seek(std::io::SeekFrom::Start(0))
16412                .unwrap();
16413            let mut req_result = {
16414                let client = &self.hub.client;
16415                dlg.pre_request();
16416                let mut req_builder = hyper::Request::builder()
16417                    .method(hyper::Method::POST)
16418                    .uri(url.as_str())
16419                    .header(USER_AGENT, self.hub._user_agent.clone());
16420
16421                if let Some(token) = token.as_ref() {
16422                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16423                }
16424
16425                let request = req_builder
16426                    .header(CONTENT_TYPE, json_mime_type.to_string())
16427                    .header(CONTENT_LENGTH, request_size as u64)
16428                    .body(common::to_body(
16429                        request_value_reader.get_ref().clone().into(),
16430                    ));
16431
16432                client.request(request.unwrap()).await
16433            };
16434
16435            match req_result {
16436                Err(err) => {
16437                    if let common::Retry::After(d) = dlg.http_error(&err) {
16438                        sleep(d).await;
16439                        continue;
16440                    }
16441                    dlg.finished(false);
16442                    return Err(common::Error::HttpError(err));
16443                }
16444                Ok(res) => {
16445                    let (mut parts, body) = res.into_parts();
16446                    let mut body = common::Body::new(body);
16447                    if !parts.status.is_success() {
16448                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16449                        let error = serde_json::from_str(&common::to_string(&bytes));
16450                        let response = common::to_response(parts, bytes.into());
16451
16452                        if let common::Retry::After(d) =
16453                            dlg.http_failure(&response, error.as_ref().ok())
16454                        {
16455                            sleep(d).await;
16456                            continue;
16457                        }
16458
16459                        dlg.finished(false);
16460
16461                        return Err(match error {
16462                            Ok(value) => common::Error::BadRequest(value),
16463                            _ => common::Error::Failure(response),
16464                        });
16465                    }
16466                    let response = {
16467                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16468                        let encoded = common::to_string(&bytes);
16469                        match serde_json::from_str(&encoded) {
16470                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16471                            Err(error) => {
16472                                dlg.response_json_decode_error(&encoded, &error);
16473                                return Err(common::Error::JsonDecodeError(
16474                                    encoded.to_string(),
16475                                    error,
16476                                ));
16477                            }
16478                        }
16479                    };
16480
16481                    dlg.finished(true);
16482                    return Ok(response);
16483                }
16484            }
16485        }
16486    }
16487
16488    ///
16489    /// Sets the *request* property to the given value.
16490    ///
16491    /// Even though the property as already been set when instantiating this call,
16492    /// we provide this method for API completeness.
16493    pub fn request(mut self, new_value: Delegate) -> UserSettingDelegateCreateCall<'a, C> {
16494        self._request = new_value;
16495        self
16496    }
16497    /// User's email address. The special value "me" can be used to indicate the authenticated user.
16498    ///
16499    /// Sets the *user id* path property to the given value.
16500    ///
16501    /// Even though the property as already been set when instantiating this call,
16502    /// we provide this method for API completeness.
16503    pub fn user_id(mut self, new_value: &str) -> UserSettingDelegateCreateCall<'a, C> {
16504        self._user_id = new_value.to_string();
16505        self
16506    }
16507    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16508    /// while executing the actual API request.
16509    ///
16510    /// ````text
16511    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16512    /// ````
16513    ///
16514    /// Sets the *delegate* property to the given value.
16515    pub fn delegate(
16516        mut self,
16517        new_value: &'a mut dyn common::Delegate,
16518    ) -> UserSettingDelegateCreateCall<'a, C> {
16519        self._delegate = Some(new_value);
16520        self
16521    }
16522
16523    /// Set any additional parameter of the query string used in the request.
16524    /// It should be used to set parameters which are not yet available through their own
16525    /// setters.
16526    ///
16527    /// Please note that this method must not be used to set any of the known parameters
16528    /// which have their own setter method. If done anyway, the request will fail.
16529    ///
16530    /// # Additional Parameters
16531    ///
16532    /// * *$.xgafv* (query-string) - V1 error format.
16533    /// * *access_token* (query-string) - OAuth access token.
16534    /// * *alt* (query-string) - Data format for response.
16535    /// * *callback* (query-string) - JSONP
16536    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16537    /// * *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.
16538    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16539    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16540    /// * *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.
16541    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16542    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16543    pub fn param<T>(mut self, name: T, value: T) -> UserSettingDelegateCreateCall<'a, C>
16544    where
16545        T: AsRef<str>,
16546    {
16547        self._additional_params
16548            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16549        self
16550    }
16551
16552    /// Identifies the authorization scope for the method you are building.
16553    ///
16554    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16555    /// [`Scope::SettingSharing`].
16556    ///
16557    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16558    /// tokens for more than one scope.
16559    ///
16560    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16561    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16562    /// sufficient, a read-write scope will do as well.
16563    pub fn add_scope<St>(mut self, scope: St) -> UserSettingDelegateCreateCall<'a, C>
16564    where
16565        St: AsRef<str>,
16566    {
16567        self._scopes.insert(String::from(scope.as_ref()));
16568        self
16569    }
16570    /// Identifies the authorization scope(s) for the method you are building.
16571    ///
16572    /// See [`Self::add_scope()`] for details.
16573    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingDelegateCreateCall<'a, C>
16574    where
16575        I: IntoIterator<Item = St>,
16576        St: AsRef<str>,
16577    {
16578        self._scopes
16579            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16580        self
16581    }
16582
16583    /// Removes all scopes, and no default scope will be used either.
16584    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16585    /// for details).
16586    pub fn clear_scopes(mut self) -> UserSettingDelegateCreateCall<'a, C> {
16587        self._scopes.clear();
16588        self
16589    }
16590}
16591
16592/// Removes the specified delegate (which can be of any verification status), and revokes any verification that may have been required for using it. Note that a delegate user must be referred to by their primary email address, and not an email alias. This method is only available to service account clients that have been delegated domain-wide authority.
16593///
16594/// A builder for the *settings.delegates.delete* method supported by a *user* resource.
16595/// It is not used directly, but through a [`UserMethods`] instance.
16596///
16597/// # Example
16598///
16599/// Instantiate a resource method builder
16600///
16601/// ```test_harness,no_run
16602/// # extern crate hyper;
16603/// # extern crate hyper_rustls;
16604/// # extern crate google_gmail1 as gmail1;
16605/// # async fn dox() {
16606/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16607///
16608/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16609/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16610/// #     .with_native_roots()
16611/// #     .unwrap()
16612/// #     .https_only()
16613/// #     .enable_http2()
16614/// #     .build();
16615///
16616/// # let executor = hyper_util::rt::TokioExecutor::new();
16617/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16618/// #     secret,
16619/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16620/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16621/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16622/// #     ),
16623/// # ).build().await.unwrap();
16624///
16625/// # let client = hyper_util::client::legacy::Client::builder(
16626/// #     hyper_util::rt::TokioExecutor::new()
16627/// # )
16628/// # .build(
16629/// #     hyper_rustls::HttpsConnectorBuilder::new()
16630/// #         .with_native_roots()
16631/// #         .unwrap()
16632/// #         .https_or_http()
16633/// #         .enable_http2()
16634/// #         .build()
16635/// # );
16636/// # let mut hub = Gmail::new(client, auth);
16637/// // You can configure optional parameters by calling the respective setters at will, and
16638/// // execute the final call using `doit()`.
16639/// // Values shown here are possibly random and not representative !
16640/// let result = hub.users().settings_delegates_delete("userId", "delegateEmail")
16641///              .doit().await;
16642/// # }
16643/// ```
16644pub struct UserSettingDelegateDeleteCall<'a, C>
16645where
16646    C: 'a,
16647{
16648    hub: &'a Gmail<C>,
16649    _user_id: String,
16650    _delegate_email: String,
16651    _delegate: Option<&'a mut dyn common::Delegate>,
16652    _additional_params: HashMap<String, String>,
16653    _scopes: BTreeSet<String>,
16654}
16655
16656impl<'a, C> common::CallBuilder for UserSettingDelegateDeleteCall<'a, C> {}
16657
16658impl<'a, C> UserSettingDelegateDeleteCall<'a, C>
16659where
16660    C: common::Connector,
16661{
16662    /// Perform the operation you have build so far.
16663    pub async fn doit(mut self) -> common::Result<common::Response> {
16664        use std::borrow::Cow;
16665        use std::io::{Read, Seek};
16666
16667        use common::{url::Params, ToParts};
16668        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16669
16670        let mut dd = common::DefaultDelegate;
16671        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16672        dlg.begin(common::MethodInfo {
16673            id: "gmail.users.settings.delegates.delete",
16674            http_method: hyper::Method::DELETE,
16675        });
16676
16677        for &field in ["userId", "delegateEmail"].iter() {
16678            if self._additional_params.contains_key(field) {
16679                dlg.finished(false);
16680                return Err(common::Error::FieldClash(field));
16681            }
16682        }
16683
16684        let mut params = Params::with_capacity(3 + self._additional_params.len());
16685        params.push("userId", self._user_id);
16686        params.push("delegateEmail", self._delegate_email);
16687
16688        params.extend(self._additional_params.iter());
16689
16690        let mut url = self.hub._base_url.clone()
16691            + "gmail/v1/users/{userId}/settings/delegates/{delegateEmail}";
16692        if self._scopes.is_empty() {
16693            self._scopes
16694                .insert(Scope::SettingSharing.as_ref().to_string());
16695        }
16696
16697        #[allow(clippy::single_element_loop)]
16698        for &(find_this, param_name) in
16699            [("{userId}", "userId"), ("{delegateEmail}", "delegateEmail")].iter()
16700        {
16701            url = params.uri_replacement(url, param_name, find_this, false);
16702        }
16703        {
16704            let to_remove = ["delegateEmail", "userId"];
16705            params.remove_params(&to_remove);
16706        }
16707
16708        let url = params.parse_with_url(&url);
16709
16710        loop {
16711            let token = match self
16712                .hub
16713                .auth
16714                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16715                .await
16716            {
16717                Ok(token) => token,
16718                Err(e) => match dlg.token(e) {
16719                    Ok(token) => token,
16720                    Err(e) => {
16721                        dlg.finished(false);
16722                        return Err(common::Error::MissingToken(e));
16723                    }
16724                },
16725            };
16726            let mut req_result = {
16727                let client = &self.hub.client;
16728                dlg.pre_request();
16729                let mut req_builder = hyper::Request::builder()
16730                    .method(hyper::Method::DELETE)
16731                    .uri(url.as_str())
16732                    .header(USER_AGENT, self.hub._user_agent.clone());
16733
16734                if let Some(token) = token.as_ref() {
16735                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16736                }
16737
16738                let request = req_builder
16739                    .header(CONTENT_LENGTH, 0_u64)
16740                    .body(common::to_body::<String>(None));
16741
16742                client.request(request.unwrap()).await
16743            };
16744
16745            match req_result {
16746                Err(err) => {
16747                    if let common::Retry::After(d) = dlg.http_error(&err) {
16748                        sleep(d).await;
16749                        continue;
16750                    }
16751                    dlg.finished(false);
16752                    return Err(common::Error::HttpError(err));
16753                }
16754                Ok(res) => {
16755                    let (mut parts, body) = res.into_parts();
16756                    let mut body = common::Body::new(body);
16757                    if !parts.status.is_success() {
16758                        let bytes = common::to_bytes(body).await.unwrap_or_default();
16759                        let error = serde_json::from_str(&common::to_string(&bytes));
16760                        let response = common::to_response(parts, bytes.into());
16761
16762                        if let common::Retry::After(d) =
16763                            dlg.http_failure(&response, error.as_ref().ok())
16764                        {
16765                            sleep(d).await;
16766                            continue;
16767                        }
16768
16769                        dlg.finished(false);
16770
16771                        return Err(match error {
16772                            Ok(value) => common::Error::BadRequest(value),
16773                            _ => common::Error::Failure(response),
16774                        });
16775                    }
16776                    let response = common::Response::from_parts(parts, body);
16777
16778                    dlg.finished(true);
16779                    return Ok(response);
16780                }
16781            }
16782        }
16783    }
16784
16785    /// User's email address. The special value "me" can be used to indicate the authenticated user.
16786    ///
16787    /// Sets the *user id* path property to the given value.
16788    ///
16789    /// Even though the property as already been set when instantiating this call,
16790    /// we provide this method for API completeness.
16791    pub fn user_id(mut self, new_value: &str) -> UserSettingDelegateDeleteCall<'a, C> {
16792        self._user_id = new_value.to_string();
16793        self
16794    }
16795    /// The email address of the user to be removed as a delegate.
16796    ///
16797    /// Sets the *delegate email* path property to the given value.
16798    ///
16799    /// Even though the property as already been set when instantiating this call,
16800    /// we provide this method for API completeness.
16801    pub fn delegate_email(mut self, new_value: &str) -> UserSettingDelegateDeleteCall<'a, C> {
16802        self._delegate_email = new_value.to_string();
16803        self
16804    }
16805    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16806    /// while executing the actual API request.
16807    ///
16808    /// ````text
16809    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
16810    /// ````
16811    ///
16812    /// Sets the *delegate* property to the given value.
16813    pub fn delegate(
16814        mut self,
16815        new_value: &'a mut dyn common::Delegate,
16816    ) -> UserSettingDelegateDeleteCall<'a, C> {
16817        self._delegate = Some(new_value);
16818        self
16819    }
16820
16821    /// Set any additional parameter of the query string used in the request.
16822    /// It should be used to set parameters which are not yet available through their own
16823    /// setters.
16824    ///
16825    /// Please note that this method must not be used to set any of the known parameters
16826    /// which have their own setter method. If done anyway, the request will fail.
16827    ///
16828    /// # Additional Parameters
16829    ///
16830    /// * *$.xgafv* (query-string) - V1 error format.
16831    /// * *access_token* (query-string) - OAuth access token.
16832    /// * *alt* (query-string) - Data format for response.
16833    /// * *callback* (query-string) - JSONP
16834    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16835    /// * *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.
16836    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16837    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16838    /// * *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.
16839    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16840    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16841    pub fn param<T>(mut self, name: T, value: T) -> UserSettingDelegateDeleteCall<'a, C>
16842    where
16843        T: AsRef<str>,
16844    {
16845        self._additional_params
16846            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16847        self
16848    }
16849
16850    /// Identifies the authorization scope for the method you are building.
16851    ///
16852    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16853    /// [`Scope::SettingSharing`].
16854    ///
16855    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16856    /// tokens for more than one scope.
16857    ///
16858    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16859    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16860    /// sufficient, a read-write scope will do as well.
16861    pub fn add_scope<St>(mut self, scope: St) -> UserSettingDelegateDeleteCall<'a, C>
16862    where
16863        St: AsRef<str>,
16864    {
16865        self._scopes.insert(String::from(scope.as_ref()));
16866        self
16867    }
16868    /// Identifies the authorization scope(s) for the method you are building.
16869    ///
16870    /// See [`Self::add_scope()`] for details.
16871    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingDelegateDeleteCall<'a, C>
16872    where
16873        I: IntoIterator<Item = St>,
16874        St: AsRef<str>,
16875    {
16876        self._scopes
16877            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16878        self
16879    }
16880
16881    /// Removes all scopes, and no default scope will be used either.
16882    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16883    /// for details).
16884    pub fn clear_scopes(mut self) -> UserSettingDelegateDeleteCall<'a, C> {
16885        self._scopes.clear();
16886        self
16887    }
16888}
16889
16890/// Gets the specified delegate. Note that a delegate user must be referred to by their primary email address, and not an email alias. This method is only available to service account clients that have been delegated domain-wide authority.
16891///
16892/// A builder for the *settings.delegates.get* method supported by a *user* resource.
16893/// It is not used directly, but through a [`UserMethods`] instance.
16894///
16895/// # Example
16896///
16897/// Instantiate a resource method builder
16898///
16899/// ```test_harness,no_run
16900/// # extern crate hyper;
16901/// # extern crate hyper_rustls;
16902/// # extern crate google_gmail1 as gmail1;
16903/// # async fn dox() {
16904/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16905///
16906/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16907/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16908/// #     .with_native_roots()
16909/// #     .unwrap()
16910/// #     .https_only()
16911/// #     .enable_http2()
16912/// #     .build();
16913///
16914/// # let executor = hyper_util::rt::TokioExecutor::new();
16915/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16916/// #     secret,
16917/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16918/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
16919/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
16920/// #     ),
16921/// # ).build().await.unwrap();
16922///
16923/// # let client = hyper_util::client::legacy::Client::builder(
16924/// #     hyper_util::rt::TokioExecutor::new()
16925/// # )
16926/// # .build(
16927/// #     hyper_rustls::HttpsConnectorBuilder::new()
16928/// #         .with_native_roots()
16929/// #         .unwrap()
16930/// #         .https_or_http()
16931/// #         .enable_http2()
16932/// #         .build()
16933/// # );
16934/// # let mut hub = Gmail::new(client, auth);
16935/// // You can configure optional parameters by calling the respective setters at will, and
16936/// // execute the final call using `doit()`.
16937/// // Values shown here are possibly random and not representative !
16938/// let result = hub.users().settings_delegates_get("userId", "delegateEmail")
16939///              .doit().await;
16940/// # }
16941/// ```
16942pub struct UserSettingDelegateGetCall<'a, C>
16943where
16944    C: 'a,
16945{
16946    hub: &'a Gmail<C>,
16947    _user_id: String,
16948    _delegate_email: String,
16949    _delegate: Option<&'a mut dyn common::Delegate>,
16950    _additional_params: HashMap<String, String>,
16951    _scopes: BTreeSet<String>,
16952}
16953
16954impl<'a, C> common::CallBuilder for UserSettingDelegateGetCall<'a, C> {}
16955
16956impl<'a, C> UserSettingDelegateGetCall<'a, C>
16957where
16958    C: common::Connector,
16959{
16960    /// Perform the operation you have build so far.
16961    pub async fn doit(mut self) -> common::Result<(common::Response, Delegate)> {
16962        use std::borrow::Cow;
16963        use std::io::{Read, Seek};
16964
16965        use common::{url::Params, ToParts};
16966        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16967
16968        let mut dd = common::DefaultDelegate;
16969        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16970        dlg.begin(common::MethodInfo {
16971            id: "gmail.users.settings.delegates.get",
16972            http_method: hyper::Method::GET,
16973        });
16974
16975        for &field in ["alt", "userId", "delegateEmail"].iter() {
16976            if self._additional_params.contains_key(field) {
16977                dlg.finished(false);
16978                return Err(common::Error::FieldClash(field));
16979            }
16980        }
16981
16982        let mut params = Params::with_capacity(4 + self._additional_params.len());
16983        params.push("userId", self._user_id);
16984        params.push("delegateEmail", self._delegate_email);
16985
16986        params.extend(self._additional_params.iter());
16987
16988        params.push("alt", "json");
16989        let mut url = self.hub._base_url.clone()
16990            + "gmail/v1/users/{userId}/settings/delegates/{delegateEmail}";
16991        if self._scopes.is_empty() {
16992            self._scopes.insert(Scope::Readonly.as_ref().to_string());
16993        }
16994
16995        #[allow(clippy::single_element_loop)]
16996        for &(find_this, param_name) in
16997            [("{userId}", "userId"), ("{delegateEmail}", "delegateEmail")].iter()
16998        {
16999            url = params.uri_replacement(url, param_name, find_this, false);
17000        }
17001        {
17002            let to_remove = ["delegateEmail", "userId"];
17003            params.remove_params(&to_remove);
17004        }
17005
17006        let url = params.parse_with_url(&url);
17007
17008        loop {
17009            let token = match self
17010                .hub
17011                .auth
17012                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17013                .await
17014            {
17015                Ok(token) => token,
17016                Err(e) => match dlg.token(e) {
17017                    Ok(token) => token,
17018                    Err(e) => {
17019                        dlg.finished(false);
17020                        return Err(common::Error::MissingToken(e));
17021                    }
17022                },
17023            };
17024            let mut req_result = {
17025                let client = &self.hub.client;
17026                dlg.pre_request();
17027                let mut req_builder = hyper::Request::builder()
17028                    .method(hyper::Method::GET)
17029                    .uri(url.as_str())
17030                    .header(USER_AGENT, self.hub._user_agent.clone());
17031
17032                if let Some(token) = token.as_ref() {
17033                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17034                }
17035
17036                let request = req_builder
17037                    .header(CONTENT_LENGTH, 0_u64)
17038                    .body(common::to_body::<String>(None));
17039
17040                client.request(request.unwrap()).await
17041            };
17042
17043            match req_result {
17044                Err(err) => {
17045                    if let common::Retry::After(d) = dlg.http_error(&err) {
17046                        sleep(d).await;
17047                        continue;
17048                    }
17049                    dlg.finished(false);
17050                    return Err(common::Error::HttpError(err));
17051                }
17052                Ok(res) => {
17053                    let (mut parts, body) = res.into_parts();
17054                    let mut body = common::Body::new(body);
17055                    if !parts.status.is_success() {
17056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17057                        let error = serde_json::from_str(&common::to_string(&bytes));
17058                        let response = common::to_response(parts, bytes.into());
17059
17060                        if let common::Retry::After(d) =
17061                            dlg.http_failure(&response, error.as_ref().ok())
17062                        {
17063                            sleep(d).await;
17064                            continue;
17065                        }
17066
17067                        dlg.finished(false);
17068
17069                        return Err(match error {
17070                            Ok(value) => common::Error::BadRequest(value),
17071                            _ => common::Error::Failure(response),
17072                        });
17073                    }
17074                    let response = {
17075                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17076                        let encoded = common::to_string(&bytes);
17077                        match serde_json::from_str(&encoded) {
17078                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17079                            Err(error) => {
17080                                dlg.response_json_decode_error(&encoded, &error);
17081                                return Err(common::Error::JsonDecodeError(
17082                                    encoded.to_string(),
17083                                    error,
17084                                ));
17085                            }
17086                        }
17087                    };
17088
17089                    dlg.finished(true);
17090                    return Ok(response);
17091                }
17092            }
17093        }
17094    }
17095
17096    /// User's email address. The special value "me" can be used to indicate the authenticated user.
17097    ///
17098    /// Sets the *user id* path property to the given value.
17099    ///
17100    /// Even though the property as already been set when instantiating this call,
17101    /// we provide this method for API completeness.
17102    pub fn user_id(mut self, new_value: &str) -> UserSettingDelegateGetCall<'a, C> {
17103        self._user_id = new_value.to_string();
17104        self
17105    }
17106    /// The email address of the user whose delegate relationship is to be retrieved.
17107    ///
17108    /// Sets the *delegate email* path property to the given value.
17109    ///
17110    /// Even though the property as already been set when instantiating this call,
17111    /// we provide this method for API completeness.
17112    pub fn delegate_email(mut self, new_value: &str) -> UserSettingDelegateGetCall<'a, C> {
17113        self._delegate_email = new_value.to_string();
17114        self
17115    }
17116    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17117    /// while executing the actual API request.
17118    ///
17119    /// ````text
17120    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17121    /// ````
17122    ///
17123    /// Sets the *delegate* property to the given value.
17124    pub fn delegate(
17125        mut self,
17126        new_value: &'a mut dyn common::Delegate,
17127    ) -> UserSettingDelegateGetCall<'a, C> {
17128        self._delegate = Some(new_value);
17129        self
17130    }
17131
17132    /// Set any additional parameter of the query string used in the request.
17133    /// It should be used to set parameters which are not yet available through their own
17134    /// setters.
17135    ///
17136    /// Please note that this method must not be used to set any of the known parameters
17137    /// which have their own setter method. If done anyway, the request will fail.
17138    ///
17139    /// # Additional Parameters
17140    ///
17141    /// * *$.xgafv* (query-string) - V1 error format.
17142    /// * *access_token* (query-string) - OAuth access token.
17143    /// * *alt* (query-string) - Data format for response.
17144    /// * *callback* (query-string) - JSONP
17145    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17146    /// * *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.
17147    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17148    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17149    /// * *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.
17150    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17151    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17152    pub fn param<T>(mut self, name: T, value: T) -> UserSettingDelegateGetCall<'a, C>
17153    where
17154        T: AsRef<str>,
17155    {
17156        self._additional_params
17157            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17158        self
17159    }
17160
17161    /// Identifies the authorization scope for the method you are building.
17162    ///
17163    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17164    /// [`Scope::Readonly`].
17165    ///
17166    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17167    /// tokens for more than one scope.
17168    ///
17169    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17170    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17171    /// sufficient, a read-write scope will do as well.
17172    pub fn add_scope<St>(mut self, scope: St) -> UserSettingDelegateGetCall<'a, C>
17173    where
17174        St: AsRef<str>,
17175    {
17176        self._scopes.insert(String::from(scope.as_ref()));
17177        self
17178    }
17179    /// Identifies the authorization scope(s) for the method you are building.
17180    ///
17181    /// See [`Self::add_scope()`] for details.
17182    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingDelegateGetCall<'a, C>
17183    where
17184        I: IntoIterator<Item = St>,
17185        St: AsRef<str>,
17186    {
17187        self._scopes
17188            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17189        self
17190    }
17191
17192    /// Removes all scopes, and no default scope will be used either.
17193    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17194    /// for details).
17195    pub fn clear_scopes(mut self) -> UserSettingDelegateGetCall<'a, C> {
17196        self._scopes.clear();
17197        self
17198    }
17199}
17200
17201/// Lists the delegates for the specified account. This method is only available to service account clients that have been delegated domain-wide authority.
17202///
17203/// A builder for the *settings.delegates.list* method supported by a *user* resource.
17204/// It is not used directly, but through a [`UserMethods`] instance.
17205///
17206/// # Example
17207///
17208/// Instantiate a resource method builder
17209///
17210/// ```test_harness,no_run
17211/// # extern crate hyper;
17212/// # extern crate hyper_rustls;
17213/// # extern crate google_gmail1 as gmail1;
17214/// # async fn dox() {
17215/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17216///
17217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17218/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17219/// #     .with_native_roots()
17220/// #     .unwrap()
17221/// #     .https_only()
17222/// #     .enable_http2()
17223/// #     .build();
17224///
17225/// # let executor = hyper_util::rt::TokioExecutor::new();
17226/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17227/// #     secret,
17228/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17229/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17230/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17231/// #     ),
17232/// # ).build().await.unwrap();
17233///
17234/// # let client = hyper_util::client::legacy::Client::builder(
17235/// #     hyper_util::rt::TokioExecutor::new()
17236/// # )
17237/// # .build(
17238/// #     hyper_rustls::HttpsConnectorBuilder::new()
17239/// #         .with_native_roots()
17240/// #         .unwrap()
17241/// #         .https_or_http()
17242/// #         .enable_http2()
17243/// #         .build()
17244/// # );
17245/// # let mut hub = Gmail::new(client, auth);
17246/// // You can configure optional parameters by calling the respective setters at will, and
17247/// // execute the final call using `doit()`.
17248/// // Values shown here are possibly random and not representative !
17249/// let result = hub.users().settings_delegates_list("userId")
17250///              .doit().await;
17251/// # }
17252/// ```
17253pub struct UserSettingDelegateListCall<'a, C>
17254where
17255    C: 'a,
17256{
17257    hub: &'a Gmail<C>,
17258    _user_id: String,
17259    _delegate: Option<&'a mut dyn common::Delegate>,
17260    _additional_params: HashMap<String, String>,
17261    _scopes: BTreeSet<String>,
17262}
17263
17264impl<'a, C> common::CallBuilder for UserSettingDelegateListCall<'a, C> {}
17265
17266impl<'a, C> UserSettingDelegateListCall<'a, C>
17267where
17268    C: common::Connector,
17269{
17270    /// Perform the operation you have build so far.
17271    pub async fn doit(mut self) -> common::Result<(common::Response, ListDelegatesResponse)> {
17272        use std::borrow::Cow;
17273        use std::io::{Read, Seek};
17274
17275        use common::{url::Params, ToParts};
17276        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17277
17278        let mut dd = common::DefaultDelegate;
17279        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17280        dlg.begin(common::MethodInfo {
17281            id: "gmail.users.settings.delegates.list",
17282            http_method: hyper::Method::GET,
17283        });
17284
17285        for &field in ["alt", "userId"].iter() {
17286            if self._additional_params.contains_key(field) {
17287                dlg.finished(false);
17288                return Err(common::Error::FieldClash(field));
17289            }
17290        }
17291
17292        let mut params = Params::with_capacity(3 + self._additional_params.len());
17293        params.push("userId", self._user_id);
17294
17295        params.extend(self._additional_params.iter());
17296
17297        params.push("alt", "json");
17298        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/delegates";
17299        if self._scopes.is_empty() {
17300            self._scopes.insert(Scope::Readonly.as_ref().to_string());
17301        }
17302
17303        #[allow(clippy::single_element_loop)]
17304        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
17305            url = params.uri_replacement(url, param_name, find_this, false);
17306        }
17307        {
17308            let to_remove = ["userId"];
17309            params.remove_params(&to_remove);
17310        }
17311
17312        let url = params.parse_with_url(&url);
17313
17314        loop {
17315            let token = match self
17316                .hub
17317                .auth
17318                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17319                .await
17320            {
17321                Ok(token) => token,
17322                Err(e) => match dlg.token(e) {
17323                    Ok(token) => token,
17324                    Err(e) => {
17325                        dlg.finished(false);
17326                        return Err(common::Error::MissingToken(e));
17327                    }
17328                },
17329            };
17330            let mut req_result = {
17331                let client = &self.hub.client;
17332                dlg.pre_request();
17333                let mut req_builder = hyper::Request::builder()
17334                    .method(hyper::Method::GET)
17335                    .uri(url.as_str())
17336                    .header(USER_AGENT, self.hub._user_agent.clone());
17337
17338                if let Some(token) = token.as_ref() {
17339                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17340                }
17341
17342                let request = req_builder
17343                    .header(CONTENT_LENGTH, 0_u64)
17344                    .body(common::to_body::<String>(None));
17345
17346                client.request(request.unwrap()).await
17347            };
17348
17349            match req_result {
17350                Err(err) => {
17351                    if let common::Retry::After(d) = dlg.http_error(&err) {
17352                        sleep(d).await;
17353                        continue;
17354                    }
17355                    dlg.finished(false);
17356                    return Err(common::Error::HttpError(err));
17357                }
17358                Ok(res) => {
17359                    let (mut parts, body) = res.into_parts();
17360                    let mut body = common::Body::new(body);
17361                    if !parts.status.is_success() {
17362                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17363                        let error = serde_json::from_str(&common::to_string(&bytes));
17364                        let response = common::to_response(parts, bytes.into());
17365
17366                        if let common::Retry::After(d) =
17367                            dlg.http_failure(&response, error.as_ref().ok())
17368                        {
17369                            sleep(d).await;
17370                            continue;
17371                        }
17372
17373                        dlg.finished(false);
17374
17375                        return Err(match error {
17376                            Ok(value) => common::Error::BadRequest(value),
17377                            _ => common::Error::Failure(response),
17378                        });
17379                    }
17380                    let response = {
17381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17382                        let encoded = common::to_string(&bytes);
17383                        match serde_json::from_str(&encoded) {
17384                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17385                            Err(error) => {
17386                                dlg.response_json_decode_error(&encoded, &error);
17387                                return Err(common::Error::JsonDecodeError(
17388                                    encoded.to_string(),
17389                                    error,
17390                                ));
17391                            }
17392                        }
17393                    };
17394
17395                    dlg.finished(true);
17396                    return Ok(response);
17397                }
17398            }
17399        }
17400    }
17401
17402    /// User's email address. The special value "me" can be used to indicate the authenticated user.
17403    ///
17404    /// Sets the *user id* path property to the given value.
17405    ///
17406    /// Even though the property as already been set when instantiating this call,
17407    /// we provide this method for API completeness.
17408    pub fn user_id(mut self, new_value: &str) -> UserSettingDelegateListCall<'a, C> {
17409        self._user_id = new_value.to_string();
17410        self
17411    }
17412    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17413    /// while executing the actual API request.
17414    ///
17415    /// ````text
17416    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17417    /// ````
17418    ///
17419    /// Sets the *delegate* property to the given value.
17420    pub fn delegate(
17421        mut self,
17422        new_value: &'a mut dyn common::Delegate,
17423    ) -> UserSettingDelegateListCall<'a, C> {
17424        self._delegate = Some(new_value);
17425        self
17426    }
17427
17428    /// Set any additional parameter of the query string used in the request.
17429    /// It should be used to set parameters which are not yet available through their own
17430    /// setters.
17431    ///
17432    /// Please note that this method must not be used to set any of the known parameters
17433    /// which have their own setter method. If done anyway, the request will fail.
17434    ///
17435    /// # Additional Parameters
17436    ///
17437    /// * *$.xgafv* (query-string) - V1 error format.
17438    /// * *access_token* (query-string) - OAuth access token.
17439    /// * *alt* (query-string) - Data format for response.
17440    /// * *callback* (query-string) - JSONP
17441    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17442    /// * *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.
17443    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17444    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17445    /// * *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.
17446    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17447    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17448    pub fn param<T>(mut self, name: T, value: T) -> UserSettingDelegateListCall<'a, C>
17449    where
17450        T: AsRef<str>,
17451    {
17452        self._additional_params
17453            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17454        self
17455    }
17456
17457    /// Identifies the authorization scope for the method you are building.
17458    ///
17459    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17460    /// [`Scope::Readonly`].
17461    ///
17462    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17463    /// tokens for more than one scope.
17464    ///
17465    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17466    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17467    /// sufficient, a read-write scope will do as well.
17468    pub fn add_scope<St>(mut self, scope: St) -> UserSettingDelegateListCall<'a, C>
17469    where
17470        St: AsRef<str>,
17471    {
17472        self._scopes.insert(String::from(scope.as_ref()));
17473        self
17474    }
17475    /// Identifies the authorization scope(s) for the method you are building.
17476    ///
17477    /// See [`Self::add_scope()`] for details.
17478    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingDelegateListCall<'a, C>
17479    where
17480        I: IntoIterator<Item = St>,
17481        St: AsRef<str>,
17482    {
17483        self._scopes
17484            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17485        self
17486    }
17487
17488    /// Removes all scopes, and no default scope will be used either.
17489    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17490    /// for details).
17491    pub fn clear_scopes(mut self) -> UserSettingDelegateListCall<'a, C> {
17492        self._scopes.clear();
17493        self
17494    }
17495}
17496
17497/// Creates a filter. Note: you can only create a maximum of 1,000 filters.
17498///
17499/// A builder for the *settings.filters.create* method supported by a *user* resource.
17500/// It is not used directly, but through a [`UserMethods`] instance.
17501///
17502/// # Example
17503///
17504/// Instantiate a resource method builder
17505///
17506/// ```test_harness,no_run
17507/// # extern crate hyper;
17508/// # extern crate hyper_rustls;
17509/// # extern crate google_gmail1 as gmail1;
17510/// use gmail1::api::Filter;
17511/// # async fn dox() {
17512/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17513///
17514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17516/// #     .with_native_roots()
17517/// #     .unwrap()
17518/// #     .https_only()
17519/// #     .enable_http2()
17520/// #     .build();
17521///
17522/// # let executor = hyper_util::rt::TokioExecutor::new();
17523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17524/// #     secret,
17525/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17526/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17527/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17528/// #     ),
17529/// # ).build().await.unwrap();
17530///
17531/// # let client = hyper_util::client::legacy::Client::builder(
17532/// #     hyper_util::rt::TokioExecutor::new()
17533/// # )
17534/// # .build(
17535/// #     hyper_rustls::HttpsConnectorBuilder::new()
17536/// #         .with_native_roots()
17537/// #         .unwrap()
17538/// #         .https_or_http()
17539/// #         .enable_http2()
17540/// #         .build()
17541/// # );
17542/// # let mut hub = Gmail::new(client, auth);
17543/// // As the method needs a request, you would usually fill it with the desired information
17544/// // into the respective structure. Some of the parts shown here might not be applicable !
17545/// // Values shown here are possibly random and not representative !
17546/// let mut req = Filter::default();
17547///
17548/// // You can configure optional parameters by calling the respective setters at will, and
17549/// // execute the final call using `doit()`.
17550/// // Values shown here are possibly random and not representative !
17551/// let result = hub.users().settings_filters_create(req, "userId")
17552///              .doit().await;
17553/// # }
17554/// ```
17555pub struct UserSettingFilterCreateCall<'a, C>
17556where
17557    C: 'a,
17558{
17559    hub: &'a Gmail<C>,
17560    _request: Filter,
17561    _user_id: String,
17562    _delegate: Option<&'a mut dyn common::Delegate>,
17563    _additional_params: HashMap<String, String>,
17564    _scopes: BTreeSet<String>,
17565}
17566
17567impl<'a, C> common::CallBuilder for UserSettingFilterCreateCall<'a, C> {}
17568
17569impl<'a, C> UserSettingFilterCreateCall<'a, C>
17570where
17571    C: common::Connector,
17572{
17573    /// Perform the operation you have build so far.
17574    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
17575        use std::borrow::Cow;
17576        use std::io::{Read, Seek};
17577
17578        use common::{url::Params, ToParts};
17579        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17580
17581        let mut dd = common::DefaultDelegate;
17582        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17583        dlg.begin(common::MethodInfo {
17584            id: "gmail.users.settings.filters.create",
17585            http_method: hyper::Method::POST,
17586        });
17587
17588        for &field in ["alt", "userId"].iter() {
17589            if self._additional_params.contains_key(field) {
17590                dlg.finished(false);
17591                return Err(common::Error::FieldClash(field));
17592            }
17593        }
17594
17595        let mut params = Params::with_capacity(4 + self._additional_params.len());
17596        params.push("userId", self._user_id);
17597
17598        params.extend(self._additional_params.iter());
17599
17600        params.push("alt", "json");
17601        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/filters";
17602        if self._scopes.is_empty() {
17603            self._scopes
17604                .insert(Scope::SettingBasic.as_ref().to_string());
17605        }
17606
17607        #[allow(clippy::single_element_loop)]
17608        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
17609            url = params.uri_replacement(url, param_name, find_this, false);
17610        }
17611        {
17612            let to_remove = ["userId"];
17613            params.remove_params(&to_remove);
17614        }
17615
17616        let url = params.parse_with_url(&url);
17617
17618        let mut json_mime_type = mime::APPLICATION_JSON;
17619        let mut request_value_reader = {
17620            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17621            common::remove_json_null_values(&mut value);
17622            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17623            serde_json::to_writer(&mut dst, &value).unwrap();
17624            dst
17625        };
17626        let request_size = request_value_reader
17627            .seek(std::io::SeekFrom::End(0))
17628            .unwrap();
17629        request_value_reader
17630            .seek(std::io::SeekFrom::Start(0))
17631            .unwrap();
17632
17633        loop {
17634            let token = match self
17635                .hub
17636                .auth
17637                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17638                .await
17639            {
17640                Ok(token) => token,
17641                Err(e) => match dlg.token(e) {
17642                    Ok(token) => token,
17643                    Err(e) => {
17644                        dlg.finished(false);
17645                        return Err(common::Error::MissingToken(e));
17646                    }
17647                },
17648            };
17649            request_value_reader
17650                .seek(std::io::SeekFrom::Start(0))
17651                .unwrap();
17652            let mut req_result = {
17653                let client = &self.hub.client;
17654                dlg.pre_request();
17655                let mut req_builder = hyper::Request::builder()
17656                    .method(hyper::Method::POST)
17657                    .uri(url.as_str())
17658                    .header(USER_AGENT, self.hub._user_agent.clone());
17659
17660                if let Some(token) = token.as_ref() {
17661                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17662                }
17663
17664                let request = req_builder
17665                    .header(CONTENT_TYPE, json_mime_type.to_string())
17666                    .header(CONTENT_LENGTH, request_size as u64)
17667                    .body(common::to_body(
17668                        request_value_reader.get_ref().clone().into(),
17669                    ));
17670
17671                client.request(request.unwrap()).await
17672            };
17673
17674            match req_result {
17675                Err(err) => {
17676                    if let common::Retry::After(d) = dlg.http_error(&err) {
17677                        sleep(d).await;
17678                        continue;
17679                    }
17680                    dlg.finished(false);
17681                    return Err(common::Error::HttpError(err));
17682                }
17683                Ok(res) => {
17684                    let (mut parts, body) = res.into_parts();
17685                    let mut body = common::Body::new(body);
17686                    if !parts.status.is_success() {
17687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17688                        let error = serde_json::from_str(&common::to_string(&bytes));
17689                        let response = common::to_response(parts, bytes.into());
17690
17691                        if let common::Retry::After(d) =
17692                            dlg.http_failure(&response, error.as_ref().ok())
17693                        {
17694                            sleep(d).await;
17695                            continue;
17696                        }
17697
17698                        dlg.finished(false);
17699
17700                        return Err(match error {
17701                            Ok(value) => common::Error::BadRequest(value),
17702                            _ => common::Error::Failure(response),
17703                        });
17704                    }
17705                    let response = {
17706                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17707                        let encoded = common::to_string(&bytes);
17708                        match serde_json::from_str(&encoded) {
17709                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17710                            Err(error) => {
17711                                dlg.response_json_decode_error(&encoded, &error);
17712                                return Err(common::Error::JsonDecodeError(
17713                                    encoded.to_string(),
17714                                    error,
17715                                ));
17716                            }
17717                        }
17718                    };
17719
17720                    dlg.finished(true);
17721                    return Ok(response);
17722                }
17723            }
17724        }
17725    }
17726
17727    ///
17728    /// Sets the *request* property to the given value.
17729    ///
17730    /// Even though the property as already been set when instantiating this call,
17731    /// we provide this method for API completeness.
17732    pub fn request(mut self, new_value: Filter) -> UserSettingFilterCreateCall<'a, C> {
17733        self._request = new_value;
17734        self
17735    }
17736    /// User's email address. The special value "me" can be used to indicate the authenticated user.
17737    ///
17738    /// Sets the *user id* path property to the given value.
17739    ///
17740    /// Even though the property as already been set when instantiating this call,
17741    /// we provide this method for API completeness.
17742    pub fn user_id(mut self, new_value: &str) -> UserSettingFilterCreateCall<'a, C> {
17743        self._user_id = new_value.to_string();
17744        self
17745    }
17746    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17747    /// while executing the actual API request.
17748    ///
17749    /// ````text
17750    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
17751    /// ````
17752    ///
17753    /// Sets the *delegate* property to the given value.
17754    pub fn delegate(
17755        mut self,
17756        new_value: &'a mut dyn common::Delegate,
17757    ) -> UserSettingFilterCreateCall<'a, C> {
17758        self._delegate = Some(new_value);
17759        self
17760    }
17761
17762    /// Set any additional parameter of the query string used in the request.
17763    /// It should be used to set parameters which are not yet available through their own
17764    /// setters.
17765    ///
17766    /// Please note that this method must not be used to set any of the known parameters
17767    /// which have their own setter method. If done anyway, the request will fail.
17768    ///
17769    /// # Additional Parameters
17770    ///
17771    /// * *$.xgafv* (query-string) - V1 error format.
17772    /// * *access_token* (query-string) - OAuth access token.
17773    /// * *alt* (query-string) - Data format for response.
17774    /// * *callback* (query-string) - JSONP
17775    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17776    /// * *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.
17777    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17778    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17779    /// * *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.
17780    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17781    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17782    pub fn param<T>(mut self, name: T, value: T) -> UserSettingFilterCreateCall<'a, C>
17783    where
17784        T: AsRef<str>,
17785    {
17786        self._additional_params
17787            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17788        self
17789    }
17790
17791    /// Identifies the authorization scope for the method you are building.
17792    ///
17793    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17794    /// [`Scope::SettingBasic`].
17795    ///
17796    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17797    /// tokens for more than one scope.
17798    ///
17799    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17800    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17801    /// sufficient, a read-write scope will do as well.
17802    pub fn add_scope<St>(mut self, scope: St) -> UserSettingFilterCreateCall<'a, C>
17803    where
17804        St: AsRef<str>,
17805    {
17806        self._scopes.insert(String::from(scope.as_ref()));
17807        self
17808    }
17809    /// Identifies the authorization scope(s) for the method you are building.
17810    ///
17811    /// See [`Self::add_scope()`] for details.
17812    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingFilterCreateCall<'a, C>
17813    where
17814        I: IntoIterator<Item = St>,
17815        St: AsRef<str>,
17816    {
17817        self._scopes
17818            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17819        self
17820    }
17821
17822    /// Removes all scopes, and no default scope will be used either.
17823    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17824    /// for details).
17825    pub fn clear_scopes(mut self) -> UserSettingFilterCreateCall<'a, C> {
17826        self._scopes.clear();
17827        self
17828    }
17829}
17830
17831/// Immediately and permanently deletes the specified filter.
17832///
17833/// A builder for the *settings.filters.delete* method supported by a *user* resource.
17834/// It is not used directly, but through a [`UserMethods`] instance.
17835///
17836/// # Example
17837///
17838/// Instantiate a resource method builder
17839///
17840/// ```test_harness,no_run
17841/// # extern crate hyper;
17842/// # extern crate hyper_rustls;
17843/// # extern crate google_gmail1 as gmail1;
17844/// # async fn dox() {
17845/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17846///
17847/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17848/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17849/// #     .with_native_roots()
17850/// #     .unwrap()
17851/// #     .https_only()
17852/// #     .enable_http2()
17853/// #     .build();
17854///
17855/// # let executor = hyper_util::rt::TokioExecutor::new();
17856/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17857/// #     secret,
17858/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17859/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
17860/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
17861/// #     ),
17862/// # ).build().await.unwrap();
17863///
17864/// # let client = hyper_util::client::legacy::Client::builder(
17865/// #     hyper_util::rt::TokioExecutor::new()
17866/// # )
17867/// # .build(
17868/// #     hyper_rustls::HttpsConnectorBuilder::new()
17869/// #         .with_native_roots()
17870/// #         .unwrap()
17871/// #         .https_or_http()
17872/// #         .enable_http2()
17873/// #         .build()
17874/// # );
17875/// # let mut hub = Gmail::new(client, auth);
17876/// // You can configure optional parameters by calling the respective setters at will, and
17877/// // execute the final call using `doit()`.
17878/// // Values shown here are possibly random and not representative !
17879/// let result = hub.users().settings_filters_delete("userId", "id")
17880///              .doit().await;
17881/// # }
17882/// ```
17883pub struct UserSettingFilterDeleteCall<'a, C>
17884where
17885    C: 'a,
17886{
17887    hub: &'a Gmail<C>,
17888    _user_id: String,
17889    _id: String,
17890    _delegate: Option<&'a mut dyn common::Delegate>,
17891    _additional_params: HashMap<String, String>,
17892    _scopes: BTreeSet<String>,
17893}
17894
17895impl<'a, C> common::CallBuilder for UserSettingFilterDeleteCall<'a, C> {}
17896
17897impl<'a, C> UserSettingFilterDeleteCall<'a, C>
17898where
17899    C: common::Connector,
17900{
17901    /// Perform the operation you have build so far.
17902    pub async fn doit(mut self) -> common::Result<common::Response> {
17903        use std::borrow::Cow;
17904        use std::io::{Read, Seek};
17905
17906        use common::{url::Params, ToParts};
17907        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17908
17909        let mut dd = common::DefaultDelegate;
17910        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17911        dlg.begin(common::MethodInfo {
17912            id: "gmail.users.settings.filters.delete",
17913            http_method: hyper::Method::DELETE,
17914        });
17915
17916        for &field in ["userId", "id"].iter() {
17917            if self._additional_params.contains_key(field) {
17918                dlg.finished(false);
17919                return Err(common::Error::FieldClash(field));
17920            }
17921        }
17922
17923        let mut params = Params::with_capacity(3 + self._additional_params.len());
17924        params.push("userId", self._user_id);
17925        params.push("id", self._id);
17926
17927        params.extend(self._additional_params.iter());
17928
17929        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/filters/{id}";
17930        if self._scopes.is_empty() {
17931            self._scopes
17932                .insert(Scope::SettingBasic.as_ref().to_string());
17933        }
17934
17935        #[allow(clippy::single_element_loop)]
17936        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
17937            url = params.uri_replacement(url, param_name, find_this, false);
17938        }
17939        {
17940            let to_remove = ["id", "userId"];
17941            params.remove_params(&to_remove);
17942        }
17943
17944        let url = params.parse_with_url(&url);
17945
17946        loop {
17947            let token = match self
17948                .hub
17949                .auth
17950                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17951                .await
17952            {
17953                Ok(token) => token,
17954                Err(e) => match dlg.token(e) {
17955                    Ok(token) => token,
17956                    Err(e) => {
17957                        dlg.finished(false);
17958                        return Err(common::Error::MissingToken(e));
17959                    }
17960                },
17961            };
17962            let mut req_result = {
17963                let client = &self.hub.client;
17964                dlg.pre_request();
17965                let mut req_builder = hyper::Request::builder()
17966                    .method(hyper::Method::DELETE)
17967                    .uri(url.as_str())
17968                    .header(USER_AGENT, self.hub._user_agent.clone());
17969
17970                if let Some(token) = token.as_ref() {
17971                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17972                }
17973
17974                let request = req_builder
17975                    .header(CONTENT_LENGTH, 0_u64)
17976                    .body(common::to_body::<String>(None));
17977
17978                client.request(request.unwrap()).await
17979            };
17980
17981            match req_result {
17982                Err(err) => {
17983                    if let common::Retry::After(d) = dlg.http_error(&err) {
17984                        sleep(d).await;
17985                        continue;
17986                    }
17987                    dlg.finished(false);
17988                    return Err(common::Error::HttpError(err));
17989                }
17990                Ok(res) => {
17991                    let (mut parts, body) = res.into_parts();
17992                    let mut body = common::Body::new(body);
17993                    if !parts.status.is_success() {
17994                        let bytes = common::to_bytes(body).await.unwrap_or_default();
17995                        let error = serde_json::from_str(&common::to_string(&bytes));
17996                        let response = common::to_response(parts, bytes.into());
17997
17998                        if let common::Retry::After(d) =
17999                            dlg.http_failure(&response, error.as_ref().ok())
18000                        {
18001                            sleep(d).await;
18002                            continue;
18003                        }
18004
18005                        dlg.finished(false);
18006
18007                        return Err(match error {
18008                            Ok(value) => common::Error::BadRequest(value),
18009                            _ => common::Error::Failure(response),
18010                        });
18011                    }
18012                    let response = common::Response::from_parts(parts, body);
18013
18014                    dlg.finished(true);
18015                    return Ok(response);
18016                }
18017            }
18018        }
18019    }
18020
18021    /// User's email address. The special value "me" can be used to indicate the authenticated user.
18022    ///
18023    /// Sets the *user id* path property to the given value.
18024    ///
18025    /// Even though the property as already been set when instantiating this call,
18026    /// we provide this method for API completeness.
18027    pub fn user_id(mut self, new_value: &str) -> UserSettingFilterDeleteCall<'a, C> {
18028        self._user_id = new_value.to_string();
18029        self
18030    }
18031    /// The ID of the filter to be deleted.
18032    ///
18033    /// Sets the *id* path property to the given value.
18034    ///
18035    /// Even though the property as already been set when instantiating this call,
18036    /// we provide this method for API completeness.
18037    pub fn id(mut self, new_value: &str) -> UserSettingFilterDeleteCall<'a, C> {
18038        self._id = new_value.to_string();
18039        self
18040    }
18041    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18042    /// while executing the actual API request.
18043    ///
18044    /// ````text
18045    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18046    /// ````
18047    ///
18048    /// Sets the *delegate* property to the given value.
18049    pub fn delegate(
18050        mut self,
18051        new_value: &'a mut dyn common::Delegate,
18052    ) -> UserSettingFilterDeleteCall<'a, C> {
18053        self._delegate = Some(new_value);
18054        self
18055    }
18056
18057    /// Set any additional parameter of the query string used in the request.
18058    /// It should be used to set parameters which are not yet available through their own
18059    /// setters.
18060    ///
18061    /// Please note that this method must not be used to set any of the known parameters
18062    /// which have their own setter method. If done anyway, the request will fail.
18063    ///
18064    /// # Additional Parameters
18065    ///
18066    /// * *$.xgafv* (query-string) - V1 error format.
18067    /// * *access_token* (query-string) - OAuth access token.
18068    /// * *alt* (query-string) - Data format for response.
18069    /// * *callback* (query-string) - JSONP
18070    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18071    /// * *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.
18072    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18073    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18074    /// * *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.
18075    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18076    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18077    pub fn param<T>(mut self, name: T, value: T) -> UserSettingFilterDeleteCall<'a, C>
18078    where
18079        T: AsRef<str>,
18080    {
18081        self._additional_params
18082            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18083        self
18084    }
18085
18086    /// Identifies the authorization scope for the method you are building.
18087    ///
18088    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18089    /// [`Scope::SettingBasic`].
18090    ///
18091    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18092    /// tokens for more than one scope.
18093    ///
18094    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18095    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18096    /// sufficient, a read-write scope will do as well.
18097    pub fn add_scope<St>(mut self, scope: St) -> UserSettingFilterDeleteCall<'a, C>
18098    where
18099        St: AsRef<str>,
18100    {
18101        self._scopes.insert(String::from(scope.as_ref()));
18102        self
18103    }
18104    /// Identifies the authorization scope(s) for the method you are building.
18105    ///
18106    /// See [`Self::add_scope()`] for details.
18107    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingFilterDeleteCall<'a, C>
18108    where
18109        I: IntoIterator<Item = St>,
18110        St: AsRef<str>,
18111    {
18112        self._scopes
18113            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18114        self
18115    }
18116
18117    /// Removes all scopes, and no default scope will be used either.
18118    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18119    /// for details).
18120    pub fn clear_scopes(mut self) -> UserSettingFilterDeleteCall<'a, C> {
18121        self._scopes.clear();
18122        self
18123    }
18124}
18125
18126/// Gets a filter.
18127///
18128/// A builder for the *settings.filters.get* method supported by a *user* resource.
18129/// It is not used directly, but through a [`UserMethods`] instance.
18130///
18131/// # Example
18132///
18133/// Instantiate a resource method builder
18134///
18135/// ```test_harness,no_run
18136/// # extern crate hyper;
18137/// # extern crate hyper_rustls;
18138/// # extern crate google_gmail1 as gmail1;
18139/// # async fn dox() {
18140/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18141///
18142/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18143/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18144/// #     .with_native_roots()
18145/// #     .unwrap()
18146/// #     .https_only()
18147/// #     .enable_http2()
18148/// #     .build();
18149///
18150/// # let executor = hyper_util::rt::TokioExecutor::new();
18151/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18152/// #     secret,
18153/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18154/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18155/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18156/// #     ),
18157/// # ).build().await.unwrap();
18158///
18159/// # let client = hyper_util::client::legacy::Client::builder(
18160/// #     hyper_util::rt::TokioExecutor::new()
18161/// # )
18162/// # .build(
18163/// #     hyper_rustls::HttpsConnectorBuilder::new()
18164/// #         .with_native_roots()
18165/// #         .unwrap()
18166/// #         .https_or_http()
18167/// #         .enable_http2()
18168/// #         .build()
18169/// # );
18170/// # let mut hub = Gmail::new(client, auth);
18171/// // You can configure optional parameters by calling the respective setters at will, and
18172/// // execute the final call using `doit()`.
18173/// // Values shown here are possibly random and not representative !
18174/// let result = hub.users().settings_filters_get("userId", "id")
18175///              .doit().await;
18176/// # }
18177/// ```
18178pub struct UserSettingFilterGetCall<'a, C>
18179where
18180    C: 'a,
18181{
18182    hub: &'a Gmail<C>,
18183    _user_id: String,
18184    _id: String,
18185    _delegate: Option<&'a mut dyn common::Delegate>,
18186    _additional_params: HashMap<String, String>,
18187    _scopes: BTreeSet<String>,
18188}
18189
18190impl<'a, C> common::CallBuilder for UserSettingFilterGetCall<'a, C> {}
18191
18192impl<'a, C> UserSettingFilterGetCall<'a, C>
18193where
18194    C: common::Connector,
18195{
18196    /// Perform the operation you have build so far.
18197    pub async fn doit(mut self) -> common::Result<(common::Response, Filter)> {
18198        use std::borrow::Cow;
18199        use std::io::{Read, Seek};
18200
18201        use common::{url::Params, ToParts};
18202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18203
18204        let mut dd = common::DefaultDelegate;
18205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18206        dlg.begin(common::MethodInfo {
18207            id: "gmail.users.settings.filters.get",
18208            http_method: hyper::Method::GET,
18209        });
18210
18211        for &field in ["alt", "userId", "id"].iter() {
18212            if self._additional_params.contains_key(field) {
18213                dlg.finished(false);
18214                return Err(common::Error::FieldClash(field));
18215            }
18216        }
18217
18218        let mut params = Params::with_capacity(4 + self._additional_params.len());
18219        params.push("userId", self._user_id);
18220        params.push("id", self._id);
18221
18222        params.extend(self._additional_params.iter());
18223
18224        params.push("alt", "json");
18225        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/filters/{id}";
18226        if self._scopes.is_empty() {
18227            self._scopes.insert(Scope::Readonly.as_ref().to_string());
18228        }
18229
18230        #[allow(clippy::single_element_loop)]
18231        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
18232            url = params.uri_replacement(url, param_name, find_this, false);
18233        }
18234        {
18235            let to_remove = ["id", "userId"];
18236            params.remove_params(&to_remove);
18237        }
18238
18239        let url = params.parse_with_url(&url);
18240
18241        loop {
18242            let token = match self
18243                .hub
18244                .auth
18245                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18246                .await
18247            {
18248                Ok(token) => token,
18249                Err(e) => match dlg.token(e) {
18250                    Ok(token) => token,
18251                    Err(e) => {
18252                        dlg.finished(false);
18253                        return Err(common::Error::MissingToken(e));
18254                    }
18255                },
18256            };
18257            let mut req_result = {
18258                let client = &self.hub.client;
18259                dlg.pre_request();
18260                let mut req_builder = hyper::Request::builder()
18261                    .method(hyper::Method::GET)
18262                    .uri(url.as_str())
18263                    .header(USER_AGENT, self.hub._user_agent.clone());
18264
18265                if let Some(token) = token.as_ref() {
18266                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18267                }
18268
18269                let request = req_builder
18270                    .header(CONTENT_LENGTH, 0_u64)
18271                    .body(common::to_body::<String>(None));
18272
18273                client.request(request.unwrap()).await
18274            };
18275
18276            match req_result {
18277                Err(err) => {
18278                    if let common::Retry::After(d) = dlg.http_error(&err) {
18279                        sleep(d).await;
18280                        continue;
18281                    }
18282                    dlg.finished(false);
18283                    return Err(common::Error::HttpError(err));
18284                }
18285                Ok(res) => {
18286                    let (mut parts, body) = res.into_parts();
18287                    let mut body = common::Body::new(body);
18288                    if !parts.status.is_success() {
18289                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18290                        let error = serde_json::from_str(&common::to_string(&bytes));
18291                        let response = common::to_response(parts, bytes.into());
18292
18293                        if let common::Retry::After(d) =
18294                            dlg.http_failure(&response, error.as_ref().ok())
18295                        {
18296                            sleep(d).await;
18297                            continue;
18298                        }
18299
18300                        dlg.finished(false);
18301
18302                        return Err(match error {
18303                            Ok(value) => common::Error::BadRequest(value),
18304                            _ => common::Error::Failure(response),
18305                        });
18306                    }
18307                    let response = {
18308                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18309                        let encoded = common::to_string(&bytes);
18310                        match serde_json::from_str(&encoded) {
18311                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18312                            Err(error) => {
18313                                dlg.response_json_decode_error(&encoded, &error);
18314                                return Err(common::Error::JsonDecodeError(
18315                                    encoded.to_string(),
18316                                    error,
18317                                ));
18318                            }
18319                        }
18320                    };
18321
18322                    dlg.finished(true);
18323                    return Ok(response);
18324                }
18325            }
18326        }
18327    }
18328
18329    /// User's email address. The special value "me" can be used to indicate the authenticated user.
18330    ///
18331    /// Sets the *user id* path property to the given value.
18332    ///
18333    /// Even though the property as already been set when instantiating this call,
18334    /// we provide this method for API completeness.
18335    pub fn user_id(mut self, new_value: &str) -> UserSettingFilterGetCall<'a, C> {
18336        self._user_id = new_value.to_string();
18337        self
18338    }
18339    /// The ID of the filter to be fetched.
18340    ///
18341    /// Sets the *id* path property to the given value.
18342    ///
18343    /// Even though the property as already been set when instantiating this call,
18344    /// we provide this method for API completeness.
18345    pub fn id(mut self, new_value: &str) -> UserSettingFilterGetCall<'a, C> {
18346        self._id = new_value.to_string();
18347        self
18348    }
18349    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18350    /// while executing the actual API request.
18351    ///
18352    /// ````text
18353    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18354    /// ````
18355    ///
18356    /// Sets the *delegate* property to the given value.
18357    pub fn delegate(
18358        mut self,
18359        new_value: &'a mut dyn common::Delegate,
18360    ) -> UserSettingFilterGetCall<'a, C> {
18361        self._delegate = Some(new_value);
18362        self
18363    }
18364
18365    /// Set any additional parameter of the query string used in the request.
18366    /// It should be used to set parameters which are not yet available through their own
18367    /// setters.
18368    ///
18369    /// Please note that this method must not be used to set any of the known parameters
18370    /// which have their own setter method. If done anyway, the request will fail.
18371    ///
18372    /// # Additional Parameters
18373    ///
18374    /// * *$.xgafv* (query-string) - V1 error format.
18375    /// * *access_token* (query-string) - OAuth access token.
18376    /// * *alt* (query-string) - Data format for response.
18377    /// * *callback* (query-string) - JSONP
18378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18379    /// * *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.
18380    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18381    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18382    /// * *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.
18383    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18384    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18385    pub fn param<T>(mut self, name: T, value: T) -> UserSettingFilterGetCall<'a, C>
18386    where
18387        T: AsRef<str>,
18388    {
18389        self._additional_params
18390            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18391        self
18392    }
18393
18394    /// Identifies the authorization scope for the method you are building.
18395    ///
18396    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18397    /// [`Scope::Readonly`].
18398    ///
18399    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18400    /// tokens for more than one scope.
18401    ///
18402    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18403    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18404    /// sufficient, a read-write scope will do as well.
18405    pub fn add_scope<St>(mut self, scope: St) -> UserSettingFilterGetCall<'a, C>
18406    where
18407        St: AsRef<str>,
18408    {
18409        self._scopes.insert(String::from(scope.as_ref()));
18410        self
18411    }
18412    /// Identifies the authorization scope(s) for the method you are building.
18413    ///
18414    /// See [`Self::add_scope()`] for details.
18415    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingFilterGetCall<'a, C>
18416    where
18417        I: IntoIterator<Item = St>,
18418        St: AsRef<str>,
18419    {
18420        self._scopes
18421            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18422        self
18423    }
18424
18425    /// Removes all scopes, and no default scope will be used either.
18426    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18427    /// for details).
18428    pub fn clear_scopes(mut self) -> UserSettingFilterGetCall<'a, C> {
18429        self._scopes.clear();
18430        self
18431    }
18432}
18433
18434/// Lists the message filters of a Gmail user.
18435///
18436/// A builder for the *settings.filters.list* method supported by a *user* resource.
18437/// It is not used directly, but through a [`UserMethods`] instance.
18438///
18439/// # Example
18440///
18441/// Instantiate a resource method builder
18442///
18443/// ```test_harness,no_run
18444/// # extern crate hyper;
18445/// # extern crate hyper_rustls;
18446/// # extern crate google_gmail1 as gmail1;
18447/// # async fn dox() {
18448/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18449///
18450/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18451/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18452/// #     .with_native_roots()
18453/// #     .unwrap()
18454/// #     .https_only()
18455/// #     .enable_http2()
18456/// #     .build();
18457///
18458/// # let executor = hyper_util::rt::TokioExecutor::new();
18459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18460/// #     secret,
18461/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18462/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18463/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18464/// #     ),
18465/// # ).build().await.unwrap();
18466///
18467/// # let client = hyper_util::client::legacy::Client::builder(
18468/// #     hyper_util::rt::TokioExecutor::new()
18469/// # )
18470/// # .build(
18471/// #     hyper_rustls::HttpsConnectorBuilder::new()
18472/// #         .with_native_roots()
18473/// #         .unwrap()
18474/// #         .https_or_http()
18475/// #         .enable_http2()
18476/// #         .build()
18477/// # );
18478/// # let mut hub = Gmail::new(client, auth);
18479/// // You can configure optional parameters by calling the respective setters at will, and
18480/// // execute the final call using `doit()`.
18481/// // Values shown here are possibly random and not representative !
18482/// let result = hub.users().settings_filters_list("userId")
18483///              .doit().await;
18484/// # }
18485/// ```
18486pub struct UserSettingFilterListCall<'a, C>
18487where
18488    C: 'a,
18489{
18490    hub: &'a Gmail<C>,
18491    _user_id: String,
18492    _delegate: Option<&'a mut dyn common::Delegate>,
18493    _additional_params: HashMap<String, String>,
18494    _scopes: BTreeSet<String>,
18495}
18496
18497impl<'a, C> common::CallBuilder for UserSettingFilterListCall<'a, C> {}
18498
18499impl<'a, C> UserSettingFilterListCall<'a, C>
18500where
18501    C: common::Connector,
18502{
18503    /// Perform the operation you have build so far.
18504    pub async fn doit(mut self) -> common::Result<(common::Response, ListFiltersResponse)> {
18505        use std::borrow::Cow;
18506        use std::io::{Read, Seek};
18507
18508        use common::{url::Params, ToParts};
18509        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18510
18511        let mut dd = common::DefaultDelegate;
18512        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18513        dlg.begin(common::MethodInfo {
18514            id: "gmail.users.settings.filters.list",
18515            http_method: hyper::Method::GET,
18516        });
18517
18518        for &field in ["alt", "userId"].iter() {
18519            if self._additional_params.contains_key(field) {
18520                dlg.finished(false);
18521                return Err(common::Error::FieldClash(field));
18522            }
18523        }
18524
18525        let mut params = Params::with_capacity(3 + self._additional_params.len());
18526        params.push("userId", self._user_id);
18527
18528        params.extend(self._additional_params.iter());
18529
18530        params.push("alt", "json");
18531        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/filters";
18532        if self._scopes.is_empty() {
18533            self._scopes.insert(Scope::Readonly.as_ref().to_string());
18534        }
18535
18536        #[allow(clippy::single_element_loop)]
18537        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
18538            url = params.uri_replacement(url, param_name, find_this, false);
18539        }
18540        {
18541            let to_remove = ["userId"];
18542            params.remove_params(&to_remove);
18543        }
18544
18545        let url = params.parse_with_url(&url);
18546
18547        loop {
18548            let token = match self
18549                .hub
18550                .auth
18551                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18552                .await
18553            {
18554                Ok(token) => token,
18555                Err(e) => match dlg.token(e) {
18556                    Ok(token) => token,
18557                    Err(e) => {
18558                        dlg.finished(false);
18559                        return Err(common::Error::MissingToken(e));
18560                    }
18561                },
18562            };
18563            let mut req_result = {
18564                let client = &self.hub.client;
18565                dlg.pre_request();
18566                let mut req_builder = hyper::Request::builder()
18567                    .method(hyper::Method::GET)
18568                    .uri(url.as_str())
18569                    .header(USER_AGENT, self.hub._user_agent.clone());
18570
18571                if let Some(token) = token.as_ref() {
18572                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18573                }
18574
18575                let request = req_builder
18576                    .header(CONTENT_LENGTH, 0_u64)
18577                    .body(common::to_body::<String>(None));
18578
18579                client.request(request.unwrap()).await
18580            };
18581
18582            match req_result {
18583                Err(err) => {
18584                    if let common::Retry::After(d) = dlg.http_error(&err) {
18585                        sleep(d).await;
18586                        continue;
18587                    }
18588                    dlg.finished(false);
18589                    return Err(common::Error::HttpError(err));
18590                }
18591                Ok(res) => {
18592                    let (mut parts, body) = res.into_parts();
18593                    let mut body = common::Body::new(body);
18594                    if !parts.status.is_success() {
18595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18596                        let error = serde_json::from_str(&common::to_string(&bytes));
18597                        let response = common::to_response(parts, bytes.into());
18598
18599                        if let common::Retry::After(d) =
18600                            dlg.http_failure(&response, error.as_ref().ok())
18601                        {
18602                            sleep(d).await;
18603                            continue;
18604                        }
18605
18606                        dlg.finished(false);
18607
18608                        return Err(match error {
18609                            Ok(value) => common::Error::BadRequest(value),
18610                            _ => common::Error::Failure(response),
18611                        });
18612                    }
18613                    let response = {
18614                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18615                        let encoded = common::to_string(&bytes);
18616                        match serde_json::from_str(&encoded) {
18617                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18618                            Err(error) => {
18619                                dlg.response_json_decode_error(&encoded, &error);
18620                                return Err(common::Error::JsonDecodeError(
18621                                    encoded.to_string(),
18622                                    error,
18623                                ));
18624                            }
18625                        }
18626                    };
18627
18628                    dlg.finished(true);
18629                    return Ok(response);
18630                }
18631            }
18632        }
18633    }
18634
18635    /// User's email address. The special value "me" can be used to indicate the authenticated user.
18636    ///
18637    /// Sets the *user id* path property to the given value.
18638    ///
18639    /// Even though the property as already been set when instantiating this call,
18640    /// we provide this method for API completeness.
18641    pub fn user_id(mut self, new_value: &str) -> UserSettingFilterListCall<'a, C> {
18642        self._user_id = new_value.to_string();
18643        self
18644    }
18645    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18646    /// while executing the actual API request.
18647    ///
18648    /// ````text
18649    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18650    /// ````
18651    ///
18652    /// Sets the *delegate* property to the given value.
18653    pub fn delegate(
18654        mut self,
18655        new_value: &'a mut dyn common::Delegate,
18656    ) -> UserSettingFilterListCall<'a, C> {
18657        self._delegate = Some(new_value);
18658        self
18659    }
18660
18661    /// Set any additional parameter of the query string used in the request.
18662    /// It should be used to set parameters which are not yet available through their own
18663    /// setters.
18664    ///
18665    /// Please note that this method must not be used to set any of the known parameters
18666    /// which have their own setter method. If done anyway, the request will fail.
18667    ///
18668    /// # Additional Parameters
18669    ///
18670    /// * *$.xgafv* (query-string) - V1 error format.
18671    /// * *access_token* (query-string) - OAuth access token.
18672    /// * *alt* (query-string) - Data format for response.
18673    /// * *callback* (query-string) - JSONP
18674    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18675    /// * *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.
18676    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18677    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18678    /// * *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.
18679    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18680    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18681    pub fn param<T>(mut self, name: T, value: T) -> UserSettingFilterListCall<'a, C>
18682    where
18683        T: AsRef<str>,
18684    {
18685        self._additional_params
18686            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18687        self
18688    }
18689
18690    /// Identifies the authorization scope for the method you are building.
18691    ///
18692    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18693    /// [`Scope::Readonly`].
18694    ///
18695    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18696    /// tokens for more than one scope.
18697    ///
18698    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18699    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18700    /// sufficient, a read-write scope will do as well.
18701    pub fn add_scope<St>(mut self, scope: St) -> UserSettingFilterListCall<'a, C>
18702    where
18703        St: AsRef<str>,
18704    {
18705        self._scopes.insert(String::from(scope.as_ref()));
18706        self
18707    }
18708    /// Identifies the authorization scope(s) for the method you are building.
18709    ///
18710    /// See [`Self::add_scope()`] for details.
18711    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingFilterListCall<'a, C>
18712    where
18713        I: IntoIterator<Item = St>,
18714        St: AsRef<str>,
18715    {
18716        self._scopes
18717            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18718        self
18719    }
18720
18721    /// Removes all scopes, and no default scope will be used either.
18722    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18723    /// for details).
18724    pub fn clear_scopes(mut self) -> UserSettingFilterListCall<'a, C> {
18725        self._scopes.clear();
18726        self
18727    }
18728}
18729
18730/// Creates a forwarding address. If ownership verification is required, a message will be sent to the recipient and the resource's verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. This method is only available to service account clients that have been delegated domain-wide authority.
18731///
18732/// A builder for the *settings.forwardingAddresses.create* method supported by a *user* resource.
18733/// It is not used directly, but through a [`UserMethods`] instance.
18734///
18735/// # Example
18736///
18737/// Instantiate a resource method builder
18738///
18739/// ```test_harness,no_run
18740/// # extern crate hyper;
18741/// # extern crate hyper_rustls;
18742/// # extern crate google_gmail1 as gmail1;
18743/// use gmail1::api::ForwardingAddress;
18744/// # async fn dox() {
18745/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18746///
18747/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18748/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18749/// #     .with_native_roots()
18750/// #     .unwrap()
18751/// #     .https_only()
18752/// #     .enable_http2()
18753/// #     .build();
18754///
18755/// # let executor = hyper_util::rt::TokioExecutor::new();
18756/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18757/// #     secret,
18758/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18759/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
18760/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
18761/// #     ),
18762/// # ).build().await.unwrap();
18763///
18764/// # let client = hyper_util::client::legacy::Client::builder(
18765/// #     hyper_util::rt::TokioExecutor::new()
18766/// # )
18767/// # .build(
18768/// #     hyper_rustls::HttpsConnectorBuilder::new()
18769/// #         .with_native_roots()
18770/// #         .unwrap()
18771/// #         .https_or_http()
18772/// #         .enable_http2()
18773/// #         .build()
18774/// # );
18775/// # let mut hub = Gmail::new(client, auth);
18776/// // As the method needs a request, you would usually fill it with the desired information
18777/// // into the respective structure. Some of the parts shown here might not be applicable !
18778/// // Values shown here are possibly random and not representative !
18779/// let mut req = ForwardingAddress::default();
18780///
18781/// // You can configure optional parameters by calling the respective setters at will, and
18782/// // execute the final call using `doit()`.
18783/// // Values shown here are possibly random and not representative !
18784/// let result = hub.users().settings_forwarding_addresses_create(req, "userId")
18785///              .doit().await;
18786/// # }
18787/// ```
18788pub struct UserSettingForwardingAddressCreateCall<'a, C>
18789where
18790    C: 'a,
18791{
18792    hub: &'a Gmail<C>,
18793    _request: ForwardingAddress,
18794    _user_id: String,
18795    _delegate: Option<&'a mut dyn common::Delegate>,
18796    _additional_params: HashMap<String, String>,
18797    _scopes: BTreeSet<String>,
18798}
18799
18800impl<'a, C> common::CallBuilder for UserSettingForwardingAddressCreateCall<'a, C> {}
18801
18802impl<'a, C> UserSettingForwardingAddressCreateCall<'a, C>
18803where
18804    C: common::Connector,
18805{
18806    /// Perform the operation you have build so far.
18807    pub async fn doit(mut self) -> common::Result<(common::Response, ForwardingAddress)> {
18808        use std::borrow::Cow;
18809        use std::io::{Read, Seek};
18810
18811        use common::{url::Params, ToParts};
18812        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18813
18814        let mut dd = common::DefaultDelegate;
18815        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18816        dlg.begin(common::MethodInfo {
18817            id: "gmail.users.settings.forwardingAddresses.create",
18818            http_method: hyper::Method::POST,
18819        });
18820
18821        for &field in ["alt", "userId"].iter() {
18822            if self._additional_params.contains_key(field) {
18823                dlg.finished(false);
18824                return Err(common::Error::FieldClash(field));
18825            }
18826        }
18827
18828        let mut params = Params::with_capacity(4 + self._additional_params.len());
18829        params.push("userId", self._user_id);
18830
18831        params.extend(self._additional_params.iter());
18832
18833        params.push("alt", "json");
18834        let mut url =
18835            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/forwardingAddresses";
18836        if self._scopes.is_empty() {
18837            self._scopes
18838                .insert(Scope::SettingSharing.as_ref().to_string());
18839        }
18840
18841        #[allow(clippy::single_element_loop)]
18842        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
18843            url = params.uri_replacement(url, param_name, find_this, false);
18844        }
18845        {
18846            let to_remove = ["userId"];
18847            params.remove_params(&to_remove);
18848        }
18849
18850        let url = params.parse_with_url(&url);
18851
18852        let mut json_mime_type = mime::APPLICATION_JSON;
18853        let mut request_value_reader = {
18854            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18855            common::remove_json_null_values(&mut value);
18856            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18857            serde_json::to_writer(&mut dst, &value).unwrap();
18858            dst
18859        };
18860        let request_size = request_value_reader
18861            .seek(std::io::SeekFrom::End(0))
18862            .unwrap();
18863        request_value_reader
18864            .seek(std::io::SeekFrom::Start(0))
18865            .unwrap();
18866
18867        loop {
18868            let token = match self
18869                .hub
18870                .auth
18871                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18872                .await
18873            {
18874                Ok(token) => token,
18875                Err(e) => match dlg.token(e) {
18876                    Ok(token) => token,
18877                    Err(e) => {
18878                        dlg.finished(false);
18879                        return Err(common::Error::MissingToken(e));
18880                    }
18881                },
18882            };
18883            request_value_reader
18884                .seek(std::io::SeekFrom::Start(0))
18885                .unwrap();
18886            let mut req_result = {
18887                let client = &self.hub.client;
18888                dlg.pre_request();
18889                let mut req_builder = hyper::Request::builder()
18890                    .method(hyper::Method::POST)
18891                    .uri(url.as_str())
18892                    .header(USER_AGENT, self.hub._user_agent.clone());
18893
18894                if let Some(token) = token.as_ref() {
18895                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18896                }
18897
18898                let request = req_builder
18899                    .header(CONTENT_TYPE, json_mime_type.to_string())
18900                    .header(CONTENT_LENGTH, request_size as u64)
18901                    .body(common::to_body(
18902                        request_value_reader.get_ref().clone().into(),
18903                    ));
18904
18905                client.request(request.unwrap()).await
18906            };
18907
18908            match req_result {
18909                Err(err) => {
18910                    if let common::Retry::After(d) = dlg.http_error(&err) {
18911                        sleep(d).await;
18912                        continue;
18913                    }
18914                    dlg.finished(false);
18915                    return Err(common::Error::HttpError(err));
18916                }
18917                Ok(res) => {
18918                    let (mut parts, body) = res.into_parts();
18919                    let mut body = common::Body::new(body);
18920                    if !parts.status.is_success() {
18921                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18922                        let error = serde_json::from_str(&common::to_string(&bytes));
18923                        let response = common::to_response(parts, bytes.into());
18924
18925                        if let common::Retry::After(d) =
18926                            dlg.http_failure(&response, error.as_ref().ok())
18927                        {
18928                            sleep(d).await;
18929                            continue;
18930                        }
18931
18932                        dlg.finished(false);
18933
18934                        return Err(match error {
18935                            Ok(value) => common::Error::BadRequest(value),
18936                            _ => common::Error::Failure(response),
18937                        });
18938                    }
18939                    let response = {
18940                        let bytes = common::to_bytes(body).await.unwrap_or_default();
18941                        let encoded = common::to_string(&bytes);
18942                        match serde_json::from_str(&encoded) {
18943                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18944                            Err(error) => {
18945                                dlg.response_json_decode_error(&encoded, &error);
18946                                return Err(common::Error::JsonDecodeError(
18947                                    encoded.to_string(),
18948                                    error,
18949                                ));
18950                            }
18951                        }
18952                    };
18953
18954                    dlg.finished(true);
18955                    return Ok(response);
18956                }
18957            }
18958        }
18959    }
18960
18961    ///
18962    /// Sets the *request* property to the given value.
18963    ///
18964    /// Even though the property as already been set when instantiating this call,
18965    /// we provide this method for API completeness.
18966    pub fn request(
18967        mut self,
18968        new_value: ForwardingAddress,
18969    ) -> UserSettingForwardingAddressCreateCall<'a, C> {
18970        self._request = new_value;
18971        self
18972    }
18973    /// User's email address. The special value "me" can be used to indicate the authenticated user.
18974    ///
18975    /// Sets the *user id* path property to the given value.
18976    ///
18977    /// Even though the property as already been set when instantiating this call,
18978    /// we provide this method for API completeness.
18979    pub fn user_id(mut self, new_value: &str) -> UserSettingForwardingAddressCreateCall<'a, C> {
18980        self._user_id = new_value.to_string();
18981        self
18982    }
18983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18984    /// while executing the actual API request.
18985    ///
18986    /// ````text
18987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
18988    /// ````
18989    ///
18990    /// Sets the *delegate* property to the given value.
18991    pub fn delegate(
18992        mut self,
18993        new_value: &'a mut dyn common::Delegate,
18994    ) -> UserSettingForwardingAddressCreateCall<'a, C> {
18995        self._delegate = Some(new_value);
18996        self
18997    }
18998
18999    /// Set any additional parameter of the query string used in the request.
19000    /// It should be used to set parameters which are not yet available through their own
19001    /// setters.
19002    ///
19003    /// Please note that this method must not be used to set any of the known parameters
19004    /// which have their own setter method. If done anyway, the request will fail.
19005    ///
19006    /// # Additional Parameters
19007    ///
19008    /// * *$.xgafv* (query-string) - V1 error format.
19009    /// * *access_token* (query-string) - OAuth access token.
19010    /// * *alt* (query-string) - Data format for response.
19011    /// * *callback* (query-string) - JSONP
19012    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19013    /// * *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.
19014    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19015    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19016    /// * *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.
19017    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19018    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19019    pub fn param<T>(mut self, name: T, value: T) -> UserSettingForwardingAddressCreateCall<'a, C>
19020    where
19021        T: AsRef<str>,
19022    {
19023        self._additional_params
19024            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19025        self
19026    }
19027
19028    /// Identifies the authorization scope for the method you are building.
19029    ///
19030    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19031    /// [`Scope::SettingSharing`].
19032    ///
19033    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19034    /// tokens for more than one scope.
19035    ///
19036    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19037    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19038    /// sufficient, a read-write scope will do as well.
19039    pub fn add_scope<St>(mut self, scope: St) -> UserSettingForwardingAddressCreateCall<'a, C>
19040    where
19041        St: AsRef<str>,
19042    {
19043        self._scopes.insert(String::from(scope.as_ref()));
19044        self
19045    }
19046    /// Identifies the authorization scope(s) for the method you are building.
19047    ///
19048    /// See [`Self::add_scope()`] for details.
19049    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingForwardingAddressCreateCall<'a, C>
19050    where
19051        I: IntoIterator<Item = St>,
19052        St: AsRef<str>,
19053    {
19054        self._scopes
19055            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19056        self
19057    }
19058
19059    /// Removes all scopes, and no default scope will be used either.
19060    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19061    /// for details).
19062    pub fn clear_scopes(mut self) -> UserSettingForwardingAddressCreateCall<'a, C> {
19063        self._scopes.clear();
19064        self
19065    }
19066}
19067
19068/// Deletes the specified forwarding address and revokes any verification that may have been required. This method is only available to service account clients that have been delegated domain-wide authority.
19069///
19070/// A builder for the *settings.forwardingAddresses.delete* method supported by a *user* resource.
19071/// It is not used directly, but through a [`UserMethods`] instance.
19072///
19073/// # Example
19074///
19075/// Instantiate a resource method builder
19076///
19077/// ```test_harness,no_run
19078/// # extern crate hyper;
19079/// # extern crate hyper_rustls;
19080/// # extern crate google_gmail1 as gmail1;
19081/// # async fn dox() {
19082/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19083///
19084/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19085/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19086/// #     .with_native_roots()
19087/// #     .unwrap()
19088/// #     .https_only()
19089/// #     .enable_http2()
19090/// #     .build();
19091///
19092/// # let executor = hyper_util::rt::TokioExecutor::new();
19093/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19094/// #     secret,
19095/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19096/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19097/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19098/// #     ),
19099/// # ).build().await.unwrap();
19100///
19101/// # let client = hyper_util::client::legacy::Client::builder(
19102/// #     hyper_util::rt::TokioExecutor::new()
19103/// # )
19104/// # .build(
19105/// #     hyper_rustls::HttpsConnectorBuilder::new()
19106/// #         .with_native_roots()
19107/// #         .unwrap()
19108/// #         .https_or_http()
19109/// #         .enable_http2()
19110/// #         .build()
19111/// # );
19112/// # let mut hub = Gmail::new(client, auth);
19113/// // You can configure optional parameters by calling the respective setters at will, and
19114/// // execute the final call using `doit()`.
19115/// // Values shown here are possibly random and not representative !
19116/// let result = hub.users().settings_forwarding_addresses_delete("userId", "forwardingEmail")
19117///              .doit().await;
19118/// # }
19119/// ```
19120pub struct UserSettingForwardingAddressDeleteCall<'a, C>
19121where
19122    C: 'a,
19123{
19124    hub: &'a Gmail<C>,
19125    _user_id: String,
19126    _forwarding_email: String,
19127    _delegate: Option<&'a mut dyn common::Delegate>,
19128    _additional_params: HashMap<String, String>,
19129    _scopes: BTreeSet<String>,
19130}
19131
19132impl<'a, C> common::CallBuilder for UserSettingForwardingAddressDeleteCall<'a, C> {}
19133
19134impl<'a, C> UserSettingForwardingAddressDeleteCall<'a, C>
19135where
19136    C: common::Connector,
19137{
19138    /// Perform the operation you have build so far.
19139    pub async fn doit(mut self) -> common::Result<common::Response> {
19140        use std::borrow::Cow;
19141        use std::io::{Read, Seek};
19142
19143        use common::{url::Params, ToParts};
19144        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19145
19146        let mut dd = common::DefaultDelegate;
19147        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19148        dlg.begin(common::MethodInfo {
19149            id: "gmail.users.settings.forwardingAddresses.delete",
19150            http_method: hyper::Method::DELETE,
19151        });
19152
19153        for &field in ["userId", "forwardingEmail"].iter() {
19154            if self._additional_params.contains_key(field) {
19155                dlg.finished(false);
19156                return Err(common::Error::FieldClash(field));
19157            }
19158        }
19159
19160        let mut params = Params::with_capacity(3 + self._additional_params.len());
19161        params.push("userId", self._user_id);
19162        params.push("forwardingEmail", self._forwarding_email);
19163
19164        params.extend(self._additional_params.iter());
19165
19166        let mut url = self.hub._base_url.clone()
19167            + "gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}";
19168        if self._scopes.is_empty() {
19169            self._scopes
19170                .insert(Scope::SettingSharing.as_ref().to_string());
19171        }
19172
19173        #[allow(clippy::single_element_loop)]
19174        for &(find_this, param_name) in [
19175            ("{userId}", "userId"),
19176            ("{forwardingEmail}", "forwardingEmail"),
19177        ]
19178        .iter()
19179        {
19180            url = params.uri_replacement(url, param_name, find_this, false);
19181        }
19182        {
19183            let to_remove = ["forwardingEmail", "userId"];
19184            params.remove_params(&to_remove);
19185        }
19186
19187        let url = params.parse_with_url(&url);
19188
19189        loop {
19190            let token = match self
19191                .hub
19192                .auth
19193                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19194                .await
19195            {
19196                Ok(token) => token,
19197                Err(e) => match dlg.token(e) {
19198                    Ok(token) => token,
19199                    Err(e) => {
19200                        dlg.finished(false);
19201                        return Err(common::Error::MissingToken(e));
19202                    }
19203                },
19204            };
19205            let mut req_result = {
19206                let client = &self.hub.client;
19207                dlg.pre_request();
19208                let mut req_builder = hyper::Request::builder()
19209                    .method(hyper::Method::DELETE)
19210                    .uri(url.as_str())
19211                    .header(USER_AGENT, self.hub._user_agent.clone());
19212
19213                if let Some(token) = token.as_ref() {
19214                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19215                }
19216
19217                let request = req_builder
19218                    .header(CONTENT_LENGTH, 0_u64)
19219                    .body(common::to_body::<String>(None));
19220
19221                client.request(request.unwrap()).await
19222            };
19223
19224            match req_result {
19225                Err(err) => {
19226                    if let common::Retry::After(d) = dlg.http_error(&err) {
19227                        sleep(d).await;
19228                        continue;
19229                    }
19230                    dlg.finished(false);
19231                    return Err(common::Error::HttpError(err));
19232                }
19233                Ok(res) => {
19234                    let (mut parts, body) = res.into_parts();
19235                    let mut body = common::Body::new(body);
19236                    if !parts.status.is_success() {
19237                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19238                        let error = serde_json::from_str(&common::to_string(&bytes));
19239                        let response = common::to_response(parts, bytes.into());
19240
19241                        if let common::Retry::After(d) =
19242                            dlg.http_failure(&response, error.as_ref().ok())
19243                        {
19244                            sleep(d).await;
19245                            continue;
19246                        }
19247
19248                        dlg.finished(false);
19249
19250                        return Err(match error {
19251                            Ok(value) => common::Error::BadRequest(value),
19252                            _ => common::Error::Failure(response),
19253                        });
19254                    }
19255                    let response = common::Response::from_parts(parts, body);
19256
19257                    dlg.finished(true);
19258                    return Ok(response);
19259                }
19260            }
19261        }
19262    }
19263
19264    /// User's email address. The special value "me" can be used to indicate the authenticated user.
19265    ///
19266    /// Sets the *user id* path property to the given value.
19267    ///
19268    /// Even though the property as already been set when instantiating this call,
19269    /// we provide this method for API completeness.
19270    pub fn user_id(mut self, new_value: &str) -> UserSettingForwardingAddressDeleteCall<'a, C> {
19271        self._user_id = new_value.to_string();
19272        self
19273    }
19274    /// The forwarding address to be deleted.
19275    ///
19276    /// Sets the *forwarding email* path property to the given value.
19277    ///
19278    /// Even though the property as already been set when instantiating this call,
19279    /// we provide this method for API completeness.
19280    pub fn forwarding_email(
19281        mut self,
19282        new_value: &str,
19283    ) -> UserSettingForwardingAddressDeleteCall<'a, C> {
19284        self._forwarding_email = new_value.to_string();
19285        self
19286    }
19287    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19288    /// while executing the actual API request.
19289    ///
19290    /// ````text
19291    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19292    /// ````
19293    ///
19294    /// Sets the *delegate* property to the given value.
19295    pub fn delegate(
19296        mut self,
19297        new_value: &'a mut dyn common::Delegate,
19298    ) -> UserSettingForwardingAddressDeleteCall<'a, C> {
19299        self._delegate = Some(new_value);
19300        self
19301    }
19302
19303    /// Set any additional parameter of the query string used in the request.
19304    /// It should be used to set parameters which are not yet available through their own
19305    /// setters.
19306    ///
19307    /// Please note that this method must not be used to set any of the known parameters
19308    /// which have their own setter method. If done anyway, the request will fail.
19309    ///
19310    /// # Additional Parameters
19311    ///
19312    /// * *$.xgafv* (query-string) - V1 error format.
19313    /// * *access_token* (query-string) - OAuth access token.
19314    /// * *alt* (query-string) - Data format for response.
19315    /// * *callback* (query-string) - JSONP
19316    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19317    /// * *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.
19318    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19319    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19320    /// * *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.
19321    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19322    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19323    pub fn param<T>(mut self, name: T, value: T) -> UserSettingForwardingAddressDeleteCall<'a, C>
19324    where
19325        T: AsRef<str>,
19326    {
19327        self._additional_params
19328            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19329        self
19330    }
19331
19332    /// Identifies the authorization scope for the method you are building.
19333    ///
19334    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19335    /// [`Scope::SettingSharing`].
19336    ///
19337    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19338    /// tokens for more than one scope.
19339    ///
19340    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19341    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19342    /// sufficient, a read-write scope will do as well.
19343    pub fn add_scope<St>(mut self, scope: St) -> UserSettingForwardingAddressDeleteCall<'a, C>
19344    where
19345        St: AsRef<str>,
19346    {
19347        self._scopes.insert(String::from(scope.as_ref()));
19348        self
19349    }
19350    /// Identifies the authorization scope(s) for the method you are building.
19351    ///
19352    /// See [`Self::add_scope()`] for details.
19353    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingForwardingAddressDeleteCall<'a, C>
19354    where
19355        I: IntoIterator<Item = St>,
19356        St: AsRef<str>,
19357    {
19358        self._scopes
19359            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19360        self
19361    }
19362
19363    /// Removes all scopes, and no default scope will be used either.
19364    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19365    /// for details).
19366    pub fn clear_scopes(mut self) -> UserSettingForwardingAddressDeleteCall<'a, C> {
19367        self._scopes.clear();
19368        self
19369    }
19370}
19371
19372/// Gets the specified forwarding address.
19373///
19374/// A builder for the *settings.forwardingAddresses.get* method supported by a *user* resource.
19375/// It is not used directly, but through a [`UserMethods`] instance.
19376///
19377/// # Example
19378///
19379/// Instantiate a resource method builder
19380///
19381/// ```test_harness,no_run
19382/// # extern crate hyper;
19383/// # extern crate hyper_rustls;
19384/// # extern crate google_gmail1 as gmail1;
19385/// # async fn dox() {
19386/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19387///
19388/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19389/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19390/// #     .with_native_roots()
19391/// #     .unwrap()
19392/// #     .https_only()
19393/// #     .enable_http2()
19394/// #     .build();
19395///
19396/// # let executor = hyper_util::rt::TokioExecutor::new();
19397/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19398/// #     secret,
19399/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19400/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19401/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19402/// #     ),
19403/// # ).build().await.unwrap();
19404///
19405/// # let client = hyper_util::client::legacy::Client::builder(
19406/// #     hyper_util::rt::TokioExecutor::new()
19407/// # )
19408/// # .build(
19409/// #     hyper_rustls::HttpsConnectorBuilder::new()
19410/// #         .with_native_roots()
19411/// #         .unwrap()
19412/// #         .https_or_http()
19413/// #         .enable_http2()
19414/// #         .build()
19415/// # );
19416/// # let mut hub = Gmail::new(client, auth);
19417/// // You can configure optional parameters by calling the respective setters at will, and
19418/// // execute the final call using `doit()`.
19419/// // Values shown here are possibly random and not representative !
19420/// let result = hub.users().settings_forwarding_addresses_get("userId", "forwardingEmail")
19421///              .doit().await;
19422/// # }
19423/// ```
19424pub struct UserSettingForwardingAddressGetCall<'a, C>
19425where
19426    C: 'a,
19427{
19428    hub: &'a Gmail<C>,
19429    _user_id: String,
19430    _forwarding_email: String,
19431    _delegate: Option<&'a mut dyn common::Delegate>,
19432    _additional_params: HashMap<String, String>,
19433    _scopes: BTreeSet<String>,
19434}
19435
19436impl<'a, C> common::CallBuilder for UserSettingForwardingAddressGetCall<'a, C> {}
19437
19438impl<'a, C> UserSettingForwardingAddressGetCall<'a, C>
19439where
19440    C: common::Connector,
19441{
19442    /// Perform the operation you have build so far.
19443    pub async fn doit(mut self) -> common::Result<(common::Response, ForwardingAddress)> {
19444        use std::borrow::Cow;
19445        use std::io::{Read, Seek};
19446
19447        use common::{url::Params, ToParts};
19448        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19449
19450        let mut dd = common::DefaultDelegate;
19451        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19452        dlg.begin(common::MethodInfo {
19453            id: "gmail.users.settings.forwardingAddresses.get",
19454            http_method: hyper::Method::GET,
19455        });
19456
19457        for &field in ["alt", "userId", "forwardingEmail"].iter() {
19458            if self._additional_params.contains_key(field) {
19459                dlg.finished(false);
19460                return Err(common::Error::FieldClash(field));
19461            }
19462        }
19463
19464        let mut params = Params::with_capacity(4 + self._additional_params.len());
19465        params.push("userId", self._user_id);
19466        params.push("forwardingEmail", self._forwarding_email);
19467
19468        params.extend(self._additional_params.iter());
19469
19470        params.push("alt", "json");
19471        let mut url = self.hub._base_url.clone()
19472            + "gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}";
19473        if self._scopes.is_empty() {
19474            self._scopes.insert(Scope::Readonly.as_ref().to_string());
19475        }
19476
19477        #[allow(clippy::single_element_loop)]
19478        for &(find_this, param_name) in [
19479            ("{userId}", "userId"),
19480            ("{forwardingEmail}", "forwardingEmail"),
19481        ]
19482        .iter()
19483        {
19484            url = params.uri_replacement(url, param_name, find_this, false);
19485        }
19486        {
19487            let to_remove = ["forwardingEmail", "userId"];
19488            params.remove_params(&to_remove);
19489        }
19490
19491        let url = params.parse_with_url(&url);
19492
19493        loop {
19494            let token = match self
19495                .hub
19496                .auth
19497                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19498                .await
19499            {
19500                Ok(token) => token,
19501                Err(e) => match dlg.token(e) {
19502                    Ok(token) => token,
19503                    Err(e) => {
19504                        dlg.finished(false);
19505                        return Err(common::Error::MissingToken(e));
19506                    }
19507                },
19508            };
19509            let mut req_result = {
19510                let client = &self.hub.client;
19511                dlg.pre_request();
19512                let mut req_builder = hyper::Request::builder()
19513                    .method(hyper::Method::GET)
19514                    .uri(url.as_str())
19515                    .header(USER_AGENT, self.hub._user_agent.clone());
19516
19517                if let Some(token) = token.as_ref() {
19518                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19519                }
19520
19521                let request = req_builder
19522                    .header(CONTENT_LENGTH, 0_u64)
19523                    .body(common::to_body::<String>(None));
19524
19525                client.request(request.unwrap()).await
19526            };
19527
19528            match req_result {
19529                Err(err) => {
19530                    if let common::Retry::After(d) = dlg.http_error(&err) {
19531                        sleep(d).await;
19532                        continue;
19533                    }
19534                    dlg.finished(false);
19535                    return Err(common::Error::HttpError(err));
19536                }
19537                Ok(res) => {
19538                    let (mut parts, body) = res.into_parts();
19539                    let mut body = common::Body::new(body);
19540                    if !parts.status.is_success() {
19541                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19542                        let error = serde_json::from_str(&common::to_string(&bytes));
19543                        let response = common::to_response(parts, bytes.into());
19544
19545                        if let common::Retry::After(d) =
19546                            dlg.http_failure(&response, error.as_ref().ok())
19547                        {
19548                            sleep(d).await;
19549                            continue;
19550                        }
19551
19552                        dlg.finished(false);
19553
19554                        return Err(match error {
19555                            Ok(value) => common::Error::BadRequest(value),
19556                            _ => common::Error::Failure(response),
19557                        });
19558                    }
19559                    let response = {
19560                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19561                        let encoded = common::to_string(&bytes);
19562                        match serde_json::from_str(&encoded) {
19563                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19564                            Err(error) => {
19565                                dlg.response_json_decode_error(&encoded, &error);
19566                                return Err(common::Error::JsonDecodeError(
19567                                    encoded.to_string(),
19568                                    error,
19569                                ));
19570                            }
19571                        }
19572                    };
19573
19574                    dlg.finished(true);
19575                    return Ok(response);
19576                }
19577            }
19578        }
19579    }
19580
19581    /// User's email address. The special value "me" can be used to indicate the authenticated user.
19582    ///
19583    /// Sets the *user id* path property to the given value.
19584    ///
19585    /// Even though the property as already been set when instantiating this call,
19586    /// we provide this method for API completeness.
19587    pub fn user_id(mut self, new_value: &str) -> UserSettingForwardingAddressGetCall<'a, C> {
19588        self._user_id = new_value.to_string();
19589        self
19590    }
19591    /// The forwarding address to be retrieved.
19592    ///
19593    /// Sets the *forwarding email* path property to the given value.
19594    ///
19595    /// Even though the property as already been set when instantiating this call,
19596    /// we provide this method for API completeness.
19597    pub fn forwarding_email(
19598        mut self,
19599        new_value: &str,
19600    ) -> UserSettingForwardingAddressGetCall<'a, C> {
19601        self._forwarding_email = new_value.to_string();
19602        self
19603    }
19604    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19605    /// while executing the actual API request.
19606    ///
19607    /// ````text
19608    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19609    /// ````
19610    ///
19611    /// Sets the *delegate* property to the given value.
19612    pub fn delegate(
19613        mut self,
19614        new_value: &'a mut dyn common::Delegate,
19615    ) -> UserSettingForwardingAddressGetCall<'a, C> {
19616        self._delegate = Some(new_value);
19617        self
19618    }
19619
19620    /// Set any additional parameter of the query string used in the request.
19621    /// It should be used to set parameters which are not yet available through their own
19622    /// setters.
19623    ///
19624    /// Please note that this method must not be used to set any of the known parameters
19625    /// which have their own setter method. If done anyway, the request will fail.
19626    ///
19627    /// # Additional Parameters
19628    ///
19629    /// * *$.xgafv* (query-string) - V1 error format.
19630    /// * *access_token* (query-string) - OAuth access token.
19631    /// * *alt* (query-string) - Data format for response.
19632    /// * *callback* (query-string) - JSONP
19633    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19634    /// * *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.
19635    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19636    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19637    /// * *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.
19638    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19639    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19640    pub fn param<T>(mut self, name: T, value: T) -> UserSettingForwardingAddressGetCall<'a, C>
19641    where
19642        T: AsRef<str>,
19643    {
19644        self._additional_params
19645            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19646        self
19647    }
19648
19649    /// Identifies the authorization scope for the method you are building.
19650    ///
19651    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19652    /// [`Scope::Readonly`].
19653    ///
19654    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19655    /// tokens for more than one scope.
19656    ///
19657    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19658    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19659    /// sufficient, a read-write scope will do as well.
19660    pub fn add_scope<St>(mut self, scope: St) -> UserSettingForwardingAddressGetCall<'a, C>
19661    where
19662        St: AsRef<str>,
19663    {
19664        self._scopes.insert(String::from(scope.as_ref()));
19665        self
19666    }
19667    /// Identifies the authorization scope(s) for the method you are building.
19668    ///
19669    /// See [`Self::add_scope()`] for details.
19670    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingForwardingAddressGetCall<'a, C>
19671    where
19672        I: IntoIterator<Item = St>,
19673        St: AsRef<str>,
19674    {
19675        self._scopes
19676            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19677        self
19678    }
19679
19680    /// Removes all scopes, and no default scope will be used either.
19681    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19682    /// for details).
19683    pub fn clear_scopes(mut self) -> UserSettingForwardingAddressGetCall<'a, C> {
19684        self._scopes.clear();
19685        self
19686    }
19687}
19688
19689/// Lists the forwarding addresses for the specified account.
19690///
19691/// A builder for the *settings.forwardingAddresses.list* method supported by a *user* resource.
19692/// It is not used directly, but through a [`UserMethods`] instance.
19693///
19694/// # Example
19695///
19696/// Instantiate a resource method builder
19697///
19698/// ```test_harness,no_run
19699/// # extern crate hyper;
19700/// # extern crate hyper_rustls;
19701/// # extern crate google_gmail1 as gmail1;
19702/// # async fn dox() {
19703/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19704///
19705/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19706/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19707/// #     .with_native_roots()
19708/// #     .unwrap()
19709/// #     .https_only()
19710/// #     .enable_http2()
19711/// #     .build();
19712///
19713/// # let executor = hyper_util::rt::TokioExecutor::new();
19714/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19715/// #     secret,
19716/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19717/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
19718/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
19719/// #     ),
19720/// # ).build().await.unwrap();
19721///
19722/// # let client = hyper_util::client::legacy::Client::builder(
19723/// #     hyper_util::rt::TokioExecutor::new()
19724/// # )
19725/// # .build(
19726/// #     hyper_rustls::HttpsConnectorBuilder::new()
19727/// #         .with_native_roots()
19728/// #         .unwrap()
19729/// #         .https_or_http()
19730/// #         .enable_http2()
19731/// #         .build()
19732/// # );
19733/// # let mut hub = Gmail::new(client, auth);
19734/// // You can configure optional parameters by calling the respective setters at will, and
19735/// // execute the final call using `doit()`.
19736/// // Values shown here are possibly random and not representative !
19737/// let result = hub.users().settings_forwarding_addresses_list("userId")
19738///              .doit().await;
19739/// # }
19740/// ```
19741pub struct UserSettingForwardingAddressListCall<'a, C>
19742where
19743    C: 'a,
19744{
19745    hub: &'a Gmail<C>,
19746    _user_id: String,
19747    _delegate: Option<&'a mut dyn common::Delegate>,
19748    _additional_params: HashMap<String, String>,
19749    _scopes: BTreeSet<String>,
19750}
19751
19752impl<'a, C> common::CallBuilder for UserSettingForwardingAddressListCall<'a, C> {}
19753
19754impl<'a, C> UserSettingForwardingAddressListCall<'a, C>
19755where
19756    C: common::Connector,
19757{
19758    /// Perform the operation you have build so far.
19759    pub async fn doit(
19760        mut self,
19761    ) -> common::Result<(common::Response, ListForwardingAddressesResponse)> {
19762        use std::borrow::Cow;
19763        use std::io::{Read, Seek};
19764
19765        use common::{url::Params, ToParts};
19766        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19767
19768        let mut dd = common::DefaultDelegate;
19769        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19770        dlg.begin(common::MethodInfo {
19771            id: "gmail.users.settings.forwardingAddresses.list",
19772            http_method: hyper::Method::GET,
19773        });
19774
19775        for &field in ["alt", "userId"].iter() {
19776            if self._additional_params.contains_key(field) {
19777                dlg.finished(false);
19778                return Err(common::Error::FieldClash(field));
19779            }
19780        }
19781
19782        let mut params = Params::with_capacity(3 + self._additional_params.len());
19783        params.push("userId", self._user_id);
19784
19785        params.extend(self._additional_params.iter());
19786
19787        params.push("alt", "json");
19788        let mut url =
19789            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/forwardingAddresses";
19790        if self._scopes.is_empty() {
19791            self._scopes.insert(Scope::Readonly.as_ref().to_string());
19792        }
19793
19794        #[allow(clippy::single_element_loop)]
19795        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
19796            url = params.uri_replacement(url, param_name, find_this, false);
19797        }
19798        {
19799            let to_remove = ["userId"];
19800            params.remove_params(&to_remove);
19801        }
19802
19803        let url = params.parse_with_url(&url);
19804
19805        loop {
19806            let token = match self
19807                .hub
19808                .auth
19809                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19810                .await
19811            {
19812                Ok(token) => token,
19813                Err(e) => match dlg.token(e) {
19814                    Ok(token) => token,
19815                    Err(e) => {
19816                        dlg.finished(false);
19817                        return Err(common::Error::MissingToken(e));
19818                    }
19819                },
19820            };
19821            let mut req_result = {
19822                let client = &self.hub.client;
19823                dlg.pre_request();
19824                let mut req_builder = hyper::Request::builder()
19825                    .method(hyper::Method::GET)
19826                    .uri(url.as_str())
19827                    .header(USER_AGENT, self.hub._user_agent.clone());
19828
19829                if let Some(token) = token.as_ref() {
19830                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19831                }
19832
19833                let request = req_builder
19834                    .header(CONTENT_LENGTH, 0_u64)
19835                    .body(common::to_body::<String>(None));
19836
19837                client.request(request.unwrap()).await
19838            };
19839
19840            match req_result {
19841                Err(err) => {
19842                    if let common::Retry::After(d) = dlg.http_error(&err) {
19843                        sleep(d).await;
19844                        continue;
19845                    }
19846                    dlg.finished(false);
19847                    return Err(common::Error::HttpError(err));
19848                }
19849                Ok(res) => {
19850                    let (mut parts, body) = res.into_parts();
19851                    let mut body = common::Body::new(body);
19852                    if !parts.status.is_success() {
19853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19854                        let error = serde_json::from_str(&common::to_string(&bytes));
19855                        let response = common::to_response(parts, bytes.into());
19856
19857                        if let common::Retry::After(d) =
19858                            dlg.http_failure(&response, error.as_ref().ok())
19859                        {
19860                            sleep(d).await;
19861                            continue;
19862                        }
19863
19864                        dlg.finished(false);
19865
19866                        return Err(match error {
19867                            Ok(value) => common::Error::BadRequest(value),
19868                            _ => common::Error::Failure(response),
19869                        });
19870                    }
19871                    let response = {
19872                        let bytes = common::to_bytes(body).await.unwrap_or_default();
19873                        let encoded = common::to_string(&bytes);
19874                        match serde_json::from_str(&encoded) {
19875                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19876                            Err(error) => {
19877                                dlg.response_json_decode_error(&encoded, &error);
19878                                return Err(common::Error::JsonDecodeError(
19879                                    encoded.to_string(),
19880                                    error,
19881                                ));
19882                            }
19883                        }
19884                    };
19885
19886                    dlg.finished(true);
19887                    return Ok(response);
19888                }
19889            }
19890        }
19891    }
19892
19893    /// User's email address. The special value "me" can be used to indicate the authenticated user.
19894    ///
19895    /// Sets the *user id* path property to the given value.
19896    ///
19897    /// Even though the property as already been set when instantiating this call,
19898    /// we provide this method for API completeness.
19899    pub fn user_id(mut self, new_value: &str) -> UserSettingForwardingAddressListCall<'a, C> {
19900        self._user_id = new_value.to_string();
19901        self
19902    }
19903    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19904    /// while executing the actual API request.
19905    ///
19906    /// ````text
19907    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
19908    /// ````
19909    ///
19910    /// Sets the *delegate* property to the given value.
19911    pub fn delegate(
19912        mut self,
19913        new_value: &'a mut dyn common::Delegate,
19914    ) -> UserSettingForwardingAddressListCall<'a, C> {
19915        self._delegate = Some(new_value);
19916        self
19917    }
19918
19919    /// Set any additional parameter of the query string used in the request.
19920    /// It should be used to set parameters which are not yet available through their own
19921    /// setters.
19922    ///
19923    /// Please note that this method must not be used to set any of the known parameters
19924    /// which have their own setter method. If done anyway, the request will fail.
19925    ///
19926    /// # Additional Parameters
19927    ///
19928    /// * *$.xgafv* (query-string) - V1 error format.
19929    /// * *access_token* (query-string) - OAuth access token.
19930    /// * *alt* (query-string) - Data format for response.
19931    /// * *callback* (query-string) - JSONP
19932    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19933    /// * *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.
19934    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19935    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19936    /// * *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.
19937    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19938    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19939    pub fn param<T>(mut self, name: T, value: T) -> UserSettingForwardingAddressListCall<'a, C>
19940    where
19941        T: AsRef<str>,
19942    {
19943        self._additional_params
19944            .insert(name.as_ref().to_string(), value.as_ref().to_string());
19945        self
19946    }
19947
19948    /// Identifies the authorization scope for the method you are building.
19949    ///
19950    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19951    /// [`Scope::Readonly`].
19952    ///
19953    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19954    /// tokens for more than one scope.
19955    ///
19956    /// Usually there is more than one suitable scope to authorize an operation, some of which may
19957    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19958    /// sufficient, a read-write scope will do as well.
19959    pub fn add_scope<St>(mut self, scope: St) -> UserSettingForwardingAddressListCall<'a, C>
19960    where
19961        St: AsRef<str>,
19962    {
19963        self._scopes.insert(String::from(scope.as_ref()));
19964        self
19965    }
19966    /// Identifies the authorization scope(s) for the method you are building.
19967    ///
19968    /// See [`Self::add_scope()`] for details.
19969    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingForwardingAddressListCall<'a, C>
19970    where
19971        I: IntoIterator<Item = St>,
19972        St: AsRef<str>,
19973    {
19974        self._scopes
19975            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19976        self
19977    }
19978
19979    /// Removes all scopes, and no default scope will be used either.
19980    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19981    /// for details).
19982    pub fn clear_scopes(mut self) -> UserSettingForwardingAddressListCall<'a, C> {
19983        self._scopes.clear();
19984        self
19985    }
19986}
19987
19988/// Deletes the specified S/MIME config for the specified send-as alias.
19989///
19990/// A builder for the *settings.sendAs.smimeInfo.delete* method supported by a *user* resource.
19991/// It is not used directly, but through a [`UserMethods`] instance.
19992///
19993/// # Example
19994///
19995/// Instantiate a resource method builder
19996///
19997/// ```test_harness,no_run
19998/// # extern crate hyper;
19999/// # extern crate hyper_rustls;
20000/// # extern crate google_gmail1 as gmail1;
20001/// # async fn dox() {
20002/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20003///
20004/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20005/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20006/// #     .with_native_roots()
20007/// #     .unwrap()
20008/// #     .https_only()
20009/// #     .enable_http2()
20010/// #     .build();
20011///
20012/// # let executor = hyper_util::rt::TokioExecutor::new();
20013/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20014/// #     secret,
20015/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20016/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20017/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20018/// #     ),
20019/// # ).build().await.unwrap();
20020///
20021/// # let client = hyper_util::client::legacy::Client::builder(
20022/// #     hyper_util::rt::TokioExecutor::new()
20023/// # )
20024/// # .build(
20025/// #     hyper_rustls::HttpsConnectorBuilder::new()
20026/// #         .with_native_roots()
20027/// #         .unwrap()
20028/// #         .https_or_http()
20029/// #         .enable_http2()
20030/// #         .build()
20031/// # );
20032/// # let mut hub = Gmail::new(client, auth);
20033/// // You can configure optional parameters by calling the respective setters at will, and
20034/// // execute the final call using `doit()`.
20035/// // Values shown here are possibly random and not representative !
20036/// let result = hub.users().settings_send_as_smime_info_delete("userId", "sendAsEmail", "id")
20037///              .doit().await;
20038/// # }
20039/// ```
20040pub struct UserSettingSendASmimeInfoDeleteCall<'a, C>
20041where
20042    C: 'a,
20043{
20044    hub: &'a Gmail<C>,
20045    _user_id: String,
20046    _send_as_email: String,
20047    _id: String,
20048    _delegate: Option<&'a mut dyn common::Delegate>,
20049    _additional_params: HashMap<String, String>,
20050    _scopes: BTreeSet<String>,
20051}
20052
20053impl<'a, C> common::CallBuilder for UserSettingSendASmimeInfoDeleteCall<'a, C> {}
20054
20055impl<'a, C> UserSettingSendASmimeInfoDeleteCall<'a, C>
20056where
20057    C: common::Connector,
20058{
20059    /// Perform the operation you have build so far.
20060    pub async fn doit(mut self) -> common::Result<common::Response> {
20061        use std::borrow::Cow;
20062        use std::io::{Read, Seek};
20063
20064        use common::{url::Params, ToParts};
20065        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20066
20067        let mut dd = common::DefaultDelegate;
20068        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20069        dlg.begin(common::MethodInfo {
20070            id: "gmail.users.settings.sendAs.smimeInfo.delete",
20071            http_method: hyper::Method::DELETE,
20072        });
20073
20074        for &field in ["userId", "sendAsEmail", "id"].iter() {
20075            if self._additional_params.contains_key(field) {
20076                dlg.finished(false);
20077                return Err(common::Error::FieldClash(field));
20078            }
20079        }
20080
20081        let mut params = Params::with_capacity(4 + self._additional_params.len());
20082        params.push("userId", self._user_id);
20083        params.push("sendAsEmail", self._send_as_email);
20084        params.push("id", self._id);
20085
20086        params.extend(self._additional_params.iter());
20087
20088        let mut url = self.hub._base_url.clone()
20089            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}";
20090        if self._scopes.is_empty() {
20091            self._scopes
20092                .insert(Scope::SettingBasic.as_ref().to_string());
20093        }
20094
20095        #[allow(clippy::single_element_loop)]
20096        for &(find_this, param_name) in [
20097            ("{userId}", "userId"),
20098            ("{sendAsEmail}", "sendAsEmail"),
20099            ("{id}", "id"),
20100        ]
20101        .iter()
20102        {
20103            url = params.uri_replacement(url, param_name, find_this, false);
20104        }
20105        {
20106            let to_remove = ["id", "sendAsEmail", "userId"];
20107            params.remove_params(&to_remove);
20108        }
20109
20110        let url = params.parse_with_url(&url);
20111
20112        loop {
20113            let token = match self
20114                .hub
20115                .auth
20116                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20117                .await
20118            {
20119                Ok(token) => token,
20120                Err(e) => match dlg.token(e) {
20121                    Ok(token) => token,
20122                    Err(e) => {
20123                        dlg.finished(false);
20124                        return Err(common::Error::MissingToken(e));
20125                    }
20126                },
20127            };
20128            let mut req_result = {
20129                let client = &self.hub.client;
20130                dlg.pre_request();
20131                let mut req_builder = hyper::Request::builder()
20132                    .method(hyper::Method::DELETE)
20133                    .uri(url.as_str())
20134                    .header(USER_AGENT, self.hub._user_agent.clone());
20135
20136                if let Some(token) = token.as_ref() {
20137                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20138                }
20139
20140                let request = req_builder
20141                    .header(CONTENT_LENGTH, 0_u64)
20142                    .body(common::to_body::<String>(None));
20143
20144                client.request(request.unwrap()).await
20145            };
20146
20147            match req_result {
20148                Err(err) => {
20149                    if let common::Retry::After(d) = dlg.http_error(&err) {
20150                        sleep(d).await;
20151                        continue;
20152                    }
20153                    dlg.finished(false);
20154                    return Err(common::Error::HttpError(err));
20155                }
20156                Ok(res) => {
20157                    let (mut parts, body) = res.into_parts();
20158                    let mut body = common::Body::new(body);
20159                    if !parts.status.is_success() {
20160                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20161                        let error = serde_json::from_str(&common::to_string(&bytes));
20162                        let response = common::to_response(parts, bytes.into());
20163
20164                        if let common::Retry::After(d) =
20165                            dlg.http_failure(&response, error.as_ref().ok())
20166                        {
20167                            sleep(d).await;
20168                            continue;
20169                        }
20170
20171                        dlg.finished(false);
20172
20173                        return Err(match error {
20174                            Ok(value) => common::Error::BadRequest(value),
20175                            _ => common::Error::Failure(response),
20176                        });
20177                    }
20178                    let response = common::Response::from_parts(parts, body);
20179
20180                    dlg.finished(true);
20181                    return Ok(response);
20182                }
20183            }
20184        }
20185    }
20186
20187    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
20188    ///
20189    /// Sets the *user id* path property to the given value.
20190    ///
20191    /// Even though the property as already been set when instantiating this call,
20192    /// we provide this method for API completeness.
20193    pub fn user_id(mut self, new_value: &str) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
20194        self._user_id = new_value.to_string();
20195        self
20196    }
20197    /// The email address that appears in the "From:" header for mail sent using this alias.
20198    ///
20199    /// Sets the *send as email* path property to the given value.
20200    ///
20201    /// Even though the property as already been set when instantiating this call,
20202    /// we provide this method for API completeness.
20203    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
20204        self._send_as_email = new_value.to_string();
20205        self
20206    }
20207    /// The immutable ID for the SmimeInfo.
20208    ///
20209    /// Sets the *id* path property to the given value.
20210    ///
20211    /// Even though the property as already been set when instantiating this call,
20212    /// we provide this method for API completeness.
20213    pub fn id(mut self, new_value: &str) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
20214        self._id = new_value.to_string();
20215        self
20216    }
20217    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20218    /// while executing the actual API request.
20219    ///
20220    /// ````text
20221    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20222    /// ````
20223    ///
20224    /// Sets the *delegate* property to the given value.
20225    pub fn delegate(
20226        mut self,
20227        new_value: &'a mut dyn common::Delegate,
20228    ) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
20229        self._delegate = Some(new_value);
20230        self
20231    }
20232
20233    /// Set any additional parameter of the query string used in the request.
20234    /// It should be used to set parameters which are not yet available through their own
20235    /// setters.
20236    ///
20237    /// Please note that this method must not be used to set any of the known parameters
20238    /// which have their own setter method. If done anyway, the request will fail.
20239    ///
20240    /// # Additional Parameters
20241    ///
20242    /// * *$.xgafv* (query-string) - V1 error format.
20243    /// * *access_token* (query-string) - OAuth access token.
20244    /// * *alt* (query-string) - Data format for response.
20245    /// * *callback* (query-string) - JSONP
20246    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20247    /// * *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.
20248    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20249    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20250    /// * *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.
20251    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20252    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20253    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendASmimeInfoDeleteCall<'a, C>
20254    where
20255        T: AsRef<str>,
20256    {
20257        self._additional_params
20258            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20259        self
20260    }
20261
20262    /// Identifies the authorization scope for the method you are building.
20263    ///
20264    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20265    /// [`Scope::SettingBasic`].
20266    ///
20267    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20268    /// tokens for more than one scope.
20269    ///
20270    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20271    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20272    /// sufficient, a read-write scope will do as well.
20273    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendASmimeInfoDeleteCall<'a, C>
20274    where
20275        St: AsRef<str>,
20276    {
20277        self._scopes.insert(String::from(scope.as_ref()));
20278        self
20279    }
20280    /// Identifies the authorization scope(s) for the method you are building.
20281    ///
20282    /// See [`Self::add_scope()`] for details.
20283    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendASmimeInfoDeleteCall<'a, C>
20284    where
20285        I: IntoIterator<Item = St>,
20286        St: AsRef<str>,
20287    {
20288        self._scopes
20289            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20290        self
20291    }
20292
20293    /// Removes all scopes, and no default scope will be used either.
20294    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20295    /// for details).
20296    pub fn clear_scopes(mut self) -> UserSettingSendASmimeInfoDeleteCall<'a, C> {
20297        self._scopes.clear();
20298        self
20299    }
20300}
20301
20302/// Gets the specified S/MIME config for the specified send-as alias.
20303///
20304/// A builder for the *settings.sendAs.smimeInfo.get* method supported by a *user* resource.
20305/// It is not used directly, but through a [`UserMethods`] instance.
20306///
20307/// # Example
20308///
20309/// Instantiate a resource method builder
20310///
20311/// ```test_harness,no_run
20312/// # extern crate hyper;
20313/// # extern crate hyper_rustls;
20314/// # extern crate google_gmail1 as gmail1;
20315/// # async fn dox() {
20316/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20317///
20318/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20319/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20320/// #     .with_native_roots()
20321/// #     .unwrap()
20322/// #     .https_only()
20323/// #     .enable_http2()
20324/// #     .build();
20325///
20326/// # let executor = hyper_util::rt::TokioExecutor::new();
20327/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20328/// #     secret,
20329/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20330/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20331/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20332/// #     ),
20333/// # ).build().await.unwrap();
20334///
20335/// # let client = hyper_util::client::legacy::Client::builder(
20336/// #     hyper_util::rt::TokioExecutor::new()
20337/// # )
20338/// # .build(
20339/// #     hyper_rustls::HttpsConnectorBuilder::new()
20340/// #         .with_native_roots()
20341/// #         .unwrap()
20342/// #         .https_or_http()
20343/// #         .enable_http2()
20344/// #         .build()
20345/// # );
20346/// # let mut hub = Gmail::new(client, auth);
20347/// // You can configure optional parameters by calling the respective setters at will, and
20348/// // execute the final call using `doit()`.
20349/// // Values shown here are possibly random and not representative !
20350/// let result = hub.users().settings_send_as_smime_info_get("userId", "sendAsEmail", "id")
20351///              .doit().await;
20352/// # }
20353/// ```
20354pub struct UserSettingSendASmimeInfoGetCall<'a, C>
20355where
20356    C: 'a,
20357{
20358    hub: &'a Gmail<C>,
20359    _user_id: String,
20360    _send_as_email: String,
20361    _id: String,
20362    _delegate: Option<&'a mut dyn common::Delegate>,
20363    _additional_params: HashMap<String, String>,
20364    _scopes: BTreeSet<String>,
20365}
20366
20367impl<'a, C> common::CallBuilder for UserSettingSendASmimeInfoGetCall<'a, C> {}
20368
20369impl<'a, C> UserSettingSendASmimeInfoGetCall<'a, C>
20370where
20371    C: common::Connector,
20372{
20373    /// Perform the operation you have build so far.
20374    pub async fn doit(mut self) -> common::Result<(common::Response, SmimeInfo)> {
20375        use std::borrow::Cow;
20376        use std::io::{Read, Seek};
20377
20378        use common::{url::Params, ToParts};
20379        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20380
20381        let mut dd = common::DefaultDelegate;
20382        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20383        dlg.begin(common::MethodInfo {
20384            id: "gmail.users.settings.sendAs.smimeInfo.get",
20385            http_method: hyper::Method::GET,
20386        });
20387
20388        for &field in ["alt", "userId", "sendAsEmail", "id"].iter() {
20389            if self._additional_params.contains_key(field) {
20390                dlg.finished(false);
20391                return Err(common::Error::FieldClash(field));
20392            }
20393        }
20394
20395        let mut params = Params::with_capacity(5 + self._additional_params.len());
20396        params.push("userId", self._user_id);
20397        params.push("sendAsEmail", self._send_as_email);
20398        params.push("id", self._id);
20399
20400        params.extend(self._additional_params.iter());
20401
20402        params.push("alt", "json");
20403        let mut url = self.hub._base_url.clone()
20404            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}";
20405        if self._scopes.is_empty() {
20406            self._scopes.insert(Scope::Readonly.as_ref().to_string());
20407        }
20408
20409        #[allow(clippy::single_element_loop)]
20410        for &(find_this, param_name) in [
20411            ("{userId}", "userId"),
20412            ("{sendAsEmail}", "sendAsEmail"),
20413            ("{id}", "id"),
20414        ]
20415        .iter()
20416        {
20417            url = params.uri_replacement(url, param_name, find_this, false);
20418        }
20419        {
20420            let to_remove = ["id", "sendAsEmail", "userId"];
20421            params.remove_params(&to_remove);
20422        }
20423
20424        let url = params.parse_with_url(&url);
20425
20426        loop {
20427            let token = match self
20428                .hub
20429                .auth
20430                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20431                .await
20432            {
20433                Ok(token) => token,
20434                Err(e) => match dlg.token(e) {
20435                    Ok(token) => token,
20436                    Err(e) => {
20437                        dlg.finished(false);
20438                        return Err(common::Error::MissingToken(e));
20439                    }
20440                },
20441            };
20442            let mut req_result = {
20443                let client = &self.hub.client;
20444                dlg.pre_request();
20445                let mut req_builder = hyper::Request::builder()
20446                    .method(hyper::Method::GET)
20447                    .uri(url.as_str())
20448                    .header(USER_AGENT, self.hub._user_agent.clone());
20449
20450                if let Some(token) = token.as_ref() {
20451                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20452                }
20453
20454                let request = req_builder
20455                    .header(CONTENT_LENGTH, 0_u64)
20456                    .body(common::to_body::<String>(None));
20457
20458                client.request(request.unwrap()).await
20459            };
20460
20461            match req_result {
20462                Err(err) => {
20463                    if let common::Retry::After(d) = dlg.http_error(&err) {
20464                        sleep(d).await;
20465                        continue;
20466                    }
20467                    dlg.finished(false);
20468                    return Err(common::Error::HttpError(err));
20469                }
20470                Ok(res) => {
20471                    let (mut parts, body) = res.into_parts();
20472                    let mut body = common::Body::new(body);
20473                    if !parts.status.is_success() {
20474                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20475                        let error = serde_json::from_str(&common::to_string(&bytes));
20476                        let response = common::to_response(parts, bytes.into());
20477
20478                        if let common::Retry::After(d) =
20479                            dlg.http_failure(&response, error.as_ref().ok())
20480                        {
20481                            sleep(d).await;
20482                            continue;
20483                        }
20484
20485                        dlg.finished(false);
20486
20487                        return Err(match error {
20488                            Ok(value) => common::Error::BadRequest(value),
20489                            _ => common::Error::Failure(response),
20490                        });
20491                    }
20492                    let response = {
20493                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20494                        let encoded = common::to_string(&bytes);
20495                        match serde_json::from_str(&encoded) {
20496                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20497                            Err(error) => {
20498                                dlg.response_json_decode_error(&encoded, &error);
20499                                return Err(common::Error::JsonDecodeError(
20500                                    encoded.to_string(),
20501                                    error,
20502                                ));
20503                            }
20504                        }
20505                    };
20506
20507                    dlg.finished(true);
20508                    return Ok(response);
20509                }
20510            }
20511        }
20512    }
20513
20514    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
20515    ///
20516    /// Sets the *user id* path property to the given value.
20517    ///
20518    /// Even though the property as already been set when instantiating this call,
20519    /// we provide this method for API completeness.
20520    pub fn user_id(mut self, new_value: &str) -> UserSettingSendASmimeInfoGetCall<'a, C> {
20521        self._user_id = new_value.to_string();
20522        self
20523    }
20524    /// The email address that appears in the "From:" header for mail sent using this alias.
20525    ///
20526    /// Sets the *send as email* path property to the given value.
20527    ///
20528    /// Even though the property as already been set when instantiating this call,
20529    /// we provide this method for API completeness.
20530    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendASmimeInfoGetCall<'a, C> {
20531        self._send_as_email = new_value.to_string();
20532        self
20533    }
20534    /// The immutable ID for the SmimeInfo.
20535    ///
20536    /// Sets the *id* path property to the given value.
20537    ///
20538    /// Even though the property as already been set when instantiating this call,
20539    /// we provide this method for API completeness.
20540    pub fn id(mut self, new_value: &str) -> UserSettingSendASmimeInfoGetCall<'a, C> {
20541        self._id = new_value.to_string();
20542        self
20543    }
20544    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20545    /// while executing the actual API request.
20546    ///
20547    /// ````text
20548    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20549    /// ````
20550    ///
20551    /// Sets the *delegate* property to the given value.
20552    pub fn delegate(
20553        mut self,
20554        new_value: &'a mut dyn common::Delegate,
20555    ) -> UserSettingSendASmimeInfoGetCall<'a, C> {
20556        self._delegate = Some(new_value);
20557        self
20558    }
20559
20560    /// Set any additional parameter of the query string used in the request.
20561    /// It should be used to set parameters which are not yet available through their own
20562    /// setters.
20563    ///
20564    /// Please note that this method must not be used to set any of the known parameters
20565    /// which have their own setter method. If done anyway, the request will fail.
20566    ///
20567    /// # Additional Parameters
20568    ///
20569    /// * *$.xgafv* (query-string) - V1 error format.
20570    /// * *access_token* (query-string) - OAuth access token.
20571    /// * *alt* (query-string) - Data format for response.
20572    /// * *callback* (query-string) - JSONP
20573    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20574    /// * *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.
20575    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20576    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20577    /// * *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.
20578    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20579    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20580    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendASmimeInfoGetCall<'a, C>
20581    where
20582        T: AsRef<str>,
20583    {
20584        self._additional_params
20585            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20586        self
20587    }
20588
20589    /// Identifies the authorization scope for the method you are building.
20590    ///
20591    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20592    /// [`Scope::Readonly`].
20593    ///
20594    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20595    /// tokens for more than one scope.
20596    ///
20597    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20598    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20599    /// sufficient, a read-write scope will do as well.
20600    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendASmimeInfoGetCall<'a, C>
20601    where
20602        St: AsRef<str>,
20603    {
20604        self._scopes.insert(String::from(scope.as_ref()));
20605        self
20606    }
20607    /// Identifies the authorization scope(s) for the method you are building.
20608    ///
20609    /// See [`Self::add_scope()`] for details.
20610    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendASmimeInfoGetCall<'a, C>
20611    where
20612        I: IntoIterator<Item = St>,
20613        St: AsRef<str>,
20614    {
20615        self._scopes
20616            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20617        self
20618    }
20619
20620    /// Removes all scopes, and no default scope will be used either.
20621    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20622    /// for details).
20623    pub fn clear_scopes(mut self) -> UserSettingSendASmimeInfoGetCall<'a, C> {
20624        self._scopes.clear();
20625        self
20626    }
20627}
20628
20629/// Insert (upload) the given S/MIME config for the specified send-as alias. Note that pkcs12 format is required for the key.
20630///
20631/// A builder for the *settings.sendAs.smimeInfo.insert* method supported by a *user* resource.
20632/// It is not used directly, but through a [`UserMethods`] instance.
20633///
20634/// # Example
20635///
20636/// Instantiate a resource method builder
20637///
20638/// ```test_harness,no_run
20639/// # extern crate hyper;
20640/// # extern crate hyper_rustls;
20641/// # extern crate google_gmail1 as gmail1;
20642/// use gmail1::api::SmimeInfo;
20643/// # async fn dox() {
20644/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20645///
20646/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20647/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20648/// #     .with_native_roots()
20649/// #     .unwrap()
20650/// #     .https_only()
20651/// #     .enable_http2()
20652/// #     .build();
20653///
20654/// # let executor = hyper_util::rt::TokioExecutor::new();
20655/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20656/// #     secret,
20657/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20658/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
20659/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
20660/// #     ),
20661/// # ).build().await.unwrap();
20662///
20663/// # let client = hyper_util::client::legacy::Client::builder(
20664/// #     hyper_util::rt::TokioExecutor::new()
20665/// # )
20666/// # .build(
20667/// #     hyper_rustls::HttpsConnectorBuilder::new()
20668/// #         .with_native_roots()
20669/// #         .unwrap()
20670/// #         .https_or_http()
20671/// #         .enable_http2()
20672/// #         .build()
20673/// # );
20674/// # let mut hub = Gmail::new(client, auth);
20675/// // As the method needs a request, you would usually fill it with the desired information
20676/// // into the respective structure. Some of the parts shown here might not be applicable !
20677/// // Values shown here are possibly random and not representative !
20678/// let mut req = SmimeInfo::default();
20679///
20680/// // You can configure optional parameters by calling the respective setters at will, and
20681/// // execute the final call using `doit()`.
20682/// // Values shown here are possibly random and not representative !
20683/// let result = hub.users().settings_send_as_smime_info_insert(req, "userId", "sendAsEmail")
20684///              .doit().await;
20685/// # }
20686/// ```
20687pub struct UserSettingSendASmimeInfoInsertCall<'a, C>
20688where
20689    C: 'a,
20690{
20691    hub: &'a Gmail<C>,
20692    _request: SmimeInfo,
20693    _user_id: String,
20694    _send_as_email: String,
20695    _delegate: Option<&'a mut dyn common::Delegate>,
20696    _additional_params: HashMap<String, String>,
20697    _scopes: BTreeSet<String>,
20698}
20699
20700impl<'a, C> common::CallBuilder for UserSettingSendASmimeInfoInsertCall<'a, C> {}
20701
20702impl<'a, C> UserSettingSendASmimeInfoInsertCall<'a, C>
20703where
20704    C: common::Connector,
20705{
20706    /// Perform the operation you have build so far.
20707    pub async fn doit(mut self) -> common::Result<(common::Response, SmimeInfo)> {
20708        use std::borrow::Cow;
20709        use std::io::{Read, Seek};
20710
20711        use common::{url::Params, ToParts};
20712        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20713
20714        let mut dd = common::DefaultDelegate;
20715        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20716        dlg.begin(common::MethodInfo {
20717            id: "gmail.users.settings.sendAs.smimeInfo.insert",
20718            http_method: hyper::Method::POST,
20719        });
20720
20721        for &field in ["alt", "userId", "sendAsEmail"].iter() {
20722            if self._additional_params.contains_key(field) {
20723                dlg.finished(false);
20724                return Err(common::Error::FieldClash(field));
20725            }
20726        }
20727
20728        let mut params = Params::with_capacity(5 + self._additional_params.len());
20729        params.push("userId", self._user_id);
20730        params.push("sendAsEmail", self._send_as_email);
20731
20732        params.extend(self._additional_params.iter());
20733
20734        params.push("alt", "json");
20735        let mut url = self.hub._base_url.clone()
20736            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo";
20737        if self._scopes.is_empty() {
20738            self._scopes
20739                .insert(Scope::SettingBasic.as_ref().to_string());
20740        }
20741
20742        #[allow(clippy::single_element_loop)]
20743        for &(find_this, param_name) in
20744            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
20745        {
20746            url = params.uri_replacement(url, param_name, find_this, false);
20747        }
20748        {
20749            let to_remove = ["sendAsEmail", "userId"];
20750            params.remove_params(&to_remove);
20751        }
20752
20753        let url = params.parse_with_url(&url);
20754
20755        let mut json_mime_type = mime::APPLICATION_JSON;
20756        let mut request_value_reader = {
20757            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20758            common::remove_json_null_values(&mut value);
20759            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20760            serde_json::to_writer(&mut dst, &value).unwrap();
20761            dst
20762        };
20763        let request_size = request_value_reader
20764            .seek(std::io::SeekFrom::End(0))
20765            .unwrap();
20766        request_value_reader
20767            .seek(std::io::SeekFrom::Start(0))
20768            .unwrap();
20769
20770        loop {
20771            let token = match self
20772                .hub
20773                .auth
20774                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20775                .await
20776            {
20777                Ok(token) => token,
20778                Err(e) => match dlg.token(e) {
20779                    Ok(token) => token,
20780                    Err(e) => {
20781                        dlg.finished(false);
20782                        return Err(common::Error::MissingToken(e));
20783                    }
20784                },
20785            };
20786            request_value_reader
20787                .seek(std::io::SeekFrom::Start(0))
20788                .unwrap();
20789            let mut req_result = {
20790                let client = &self.hub.client;
20791                dlg.pre_request();
20792                let mut req_builder = hyper::Request::builder()
20793                    .method(hyper::Method::POST)
20794                    .uri(url.as_str())
20795                    .header(USER_AGENT, self.hub._user_agent.clone());
20796
20797                if let Some(token) = token.as_ref() {
20798                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20799                }
20800
20801                let request = req_builder
20802                    .header(CONTENT_TYPE, json_mime_type.to_string())
20803                    .header(CONTENT_LENGTH, request_size as u64)
20804                    .body(common::to_body(
20805                        request_value_reader.get_ref().clone().into(),
20806                    ));
20807
20808                client.request(request.unwrap()).await
20809            };
20810
20811            match req_result {
20812                Err(err) => {
20813                    if let common::Retry::After(d) = dlg.http_error(&err) {
20814                        sleep(d).await;
20815                        continue;
20816                    }
20817                    dlg.finished(false);
20818                    return Err(common::Error::HttpError(err));
20819                }
20820                Ok(res) => {
20821                    let (mut parts, body) = res.into_parts();
20822                    let mut body = common::Body::new(body);
20823                    if !parts.status.is_success() {
20824                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20825                        let error = serde_json::from_str(&common::to_string(&bytes));
20826                        let response = common::to_response(parts, bytes.into());
20827
20828                        if let common::Retry::After(d) =
20829                            dlg.http_failure(&response, error.as_ref().ok())
20830                        {
20831                            sleep(d).await;
20832                            continue;
20833                        }
20834
20835                        dlg.finished(false);
20836
20837                        return Err(match error {
20838                            Ok(value) => common::Error::BadRequest(value),
20839                            _ => common::Error::Failure(response),
20840                        });
20841                    }
20842                    let response = {
20843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
20844                        let encoded = common::to_string(&bytes);
20845                        match serde_json::from_str(&encoded) {
20846                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20847                            Err(error) => {
20848                                dlg.response_json_decode_error(&encoded, &error);
20849                                return Err(common::Error::JsonDecodeError(
20850                                    encoded.to_string(),
20851                                    error,
20852                                ));
20853                            }
20854                        }
20855                    };
20856
20857                    dlg.finished(true);
20858                    return Ok(response);
20859                }
20860            }
20861        }
20862    }
20863
20864    ///
20865    /// Sets the *request* property to the given value.
20866    ///
20867    /// Even though the property as already been set when instantiating this call,
20868    /// we provide this method for API completeness.
20869    pub fn request(mut self, new_value: SmimeInfo) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
20870        self._request = new_value;
20871        self
20872    }
20873    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
20874    ///
20875    /// Sets the *user id* path property to the given value.
20876    ///
20877    /// Even though the property as already been set when instantiating this call,
20878    /// we provide this method for API completeness.
20879    pub fn user_id(mut self, new_value: &str) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
20880        self._user_id = new_value.to_string();
20881        self
20882    }
20883    /// The email address that appears in the "From:" header for mail sent using this alias.
20884    ///
20885    /// Sets the *send as email* path property to the given value.
20886    ///
20887    /// Even though the property as already been set when instantiating this call,
20888    /// we provide this method for API completeness.
20889    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
20890        self._send_as_email = new_value.to_string();
20891        self
20892    }
20893    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20894    /// while executing the actual API request.
20895    ///
20896    /// ````text
20897    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
20898    /// ````
20899    ///
20900    /// Sets the *delegate* property to the given value.
20901    pub fn delegate(
20902        mut self,
20903        new_value: &'a mut dyn common::Delegate,
20904    ) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
20905        self._delegate = Some(new_value);
20906        self
20907    }
20908
20909    /// Set any additional parameter of the query string used in the request.
20910    /// It should be used to set parameters which are not yet available through their own
20911    /// setters.
20912    ///
20913    /// Please note that this method must not be used to set any of the known parameters
20914    /// which have their own setter method. If done anyway, the request will fail.
20915    ///
20916    /// # Additional Parameters
20917    ///
20918    /// * *$.xgafv* (query-string) - V1 error format.
20919    /// * *access_token* (query-string) - OAuth access token.
20920    /// * *alt* (query-string) - Data format for response.
20921    /// * *callback* (query-string) - JSONP
20922    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20923    /// * *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.
20924    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20925    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20926    /// * *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.
20927    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20928    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20929    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendASmimeInfoInsertCall<'a, C>
20930    where
20931        T: AsRef<str>,
20932    {
20933        self._additional_params
20934            .insert(name.as_ref().to_string(), value.as_ref().to_string());
20935        self
20936    }
20937
20938    /// Identifies the authorization scope for the method you are building.
20939    ///
20940    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20941    /// [`Scope::SettingBasic`].
20942    ///
20943    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20944    /// tokens for more than one scope.
20945    ///
20946    /// Usually there is more than one suitable scope to authorize an operation, some of which may
20947    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20948    /// sufficient, a read-write scope will do as well.
20949    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendASmimeInfoInsertCall<'a, C>
20950    where
20951        St: AsRef<str>,
20952    {
20953        self._scopes.insert(String::from(scope.as_ref()));
20954        self
20955    }
20956    /// Identifies the authorization scope(s) for the method you are building.
20957    ///
20958    /// See [`Self::add_scope()`] for details.
20959    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendASmimeInfoInsertCall<'a, C>
20960    where
20961        I: IntoIterator<Item = St>,
20962        St: AsRef<str>,
20963    {
20964        self._scopes
20965            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20966        self
20967    }
20968
20969    /// Removes all scopes, and no default scope will be used either.
20970    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20971    /// for details).
20972    pub fn clear_scopes(mut self) -> UserSettingSendASmimeInfoInsertCall<'a, C> {
20973        self._scopes.clear();
20974        self
20975    }
20976}
20977
20978/// Lists S/MIME configs for the specified send-as alias.
20979///
20980/// A builder for the *settings.sendAs.smimeInfo.list* method supported by a *user* resource.
20981/// It is not used directly, but through a [`UserMethods`] instance.
20982///
20983/// # Example
20984///
20985/// Instantiate a resource method builder
20986///
20987/// ```test_harness,no_run
20988/// # extern crate hyper;
20989/// # extern crate hyper_rustls;
20990/// # extern crate google_gmail1 as gmail1;
20991/// # async fn dox() {
20992/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20993///
20994/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20995/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20996/// #     .with_native_roots()
20997/// #     .unwrap()
20998/// #     .https_only()
20999/// #     .enable_http2()
21000/// #     .build();
21001///
21002/// # let executor = hyper_util::rt::TokioExecutor::new();
21003/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21004/// #     secret,
21005/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21006/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21007/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21008/// #     ),
21009/// # ).build().await.unwrap();
21010///
21011/// # let client = hyper_util::client::legacy::Client::builder(
21012/// #     hyper_util::rt::TokioExecutor::new()
21013/// # )
21014/// # .build(
21015/// #     hyper_rustls::HttpsConnectorBuilder::new()
21016/// #         .with_native_roots()
21017/// #         .unwrap()
21018/// #         .https_or_http()
21019/// #         .enable_http2()
21020/// #         .build()
21021/// # );
21022/// # let mut hub = Gmail::new(client, auth);
21023/// // You can configure optional parameters by calling the respective setters at will, and
21024/// // execute the final call using `doit()`.
21025/// // Values shown here are possibly random and not representative !
21026/// let result = hub.users().settings_send_as_smime_info_list("userId", "sendAsEmail")
21027///              .doit().await;
21028/// # }
21029/// ```
21030pub struct UserSettingSendASmimeInfoListCall<'a, C>
21031where
21032    C: 'a,
21033{
21034    hub: &'a Gmail<C>,
21035    _user_id: String,
21036    _send_as_email: String,
21037    _delegate: Option<&'a mut dyn common::Delegate>,
21038    _additional_params: HashMap<String, String>,
21039    _scopes: BTreeSet<String>,
21040}
21041
21042impl<'a, C> common::CallBuilder for UserSettingSendASmimeInfoListCall<'a, C> {}
21043
21044impl<'a, C> UserSettingSendASmimeInfoListCall<'a, C>
21045where
21046    C: common::Connector,
21047{
21048    /// Perform the operation you have build so far.
21049    pub async fn doit(mut self) -> common::Result<(common::Response, ListSmimeInfoResponse)> {
21050        use std::borrow::Cow;
21051        use std::io::{Read, Seek};
21052
21053        use common::{url::Params, ToParts};
21054        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21055
21056        let mut dd = common::DefaultDelegate;
21057        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21058        dlg.begin(common::MethodInfo {
21059            id: "gmail.users.settings.sendAs.smimeInfo.list",
21060            http_method: hyper::Method::GET,
21061        });
21062
21063        for &field in ["alt", "userId", "sendAsEmail"].iter() {
21064            if self._additional_params.contains_key(field) {
21065                dlg.finished(false);
21066                return Err(common::Error::FieldClash(field));
21067            }
21068        }
21069
21070        let mut params = Params::with_capacity(4 + self._additional_params.len());
21071        params.push("userId", self._user_id);
21072        params.push("sendAsEmail", self._send_as_email);
21073
21074        params.extend(self._additional_params.iter());
21075
21076        params.push("alt", "json");
21077        let mut url = self.hub._base_url.clone()
21078            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo";
21079        if self._scopes.is_empty() {
21080            self._scopes.insert(Scope::Readonly.as_ref().to_string());
21081        }
21082
21083        #[allow(clippy::single_element_loop)]
21084        for &(find_this, param_name) in
21085            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
21086        {
21087            url = params.uri_replacement(url, param_name, find_this, false);
21088        }
21089        {
21090            let to_remove = ["sendAsEmail", "userId"];
21091            params.remove_params(&to_remove);
21092        }
21093
21094        let url = params.parse_with_url(&url);
21095
21096        loop {
21097            let token = match self
21098                .hub
21099                .auth
21100                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21101                .await
21102            {
21103                Ok(token) => token,
21104                Err(e) => match dlg.token(e) {
21105                    Ok(token) => token,
21106                    Err(e) => {
21107                        dlg.finished(false);
21108                        return Err(common::Error::MissingToken(e));
21109                    }
21110                },
21111            };
21112            let mut req_result = {
21113                let client = &self.hub.client;
21114                dlg.pre_request();
21115                let mut req_builder = hyper::Request::builder()
21116                    .method(hyper::Method::GET)
21117                    .uri(url.as_str())
21118                    .header(USER_AGENT, self.hub._user_agent.clone());
21119
21120                if let Some(token) = token.as_ref() {
21121                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21122                }
21123
21124                let request = req_builder
21125                    .header(CONTENT_LENGTH, 0_u64)
21126                    .body(common::to_body::<String>(None));
21127
21128                client.request(request.unwrap()).await
21129            };
21130
21131            match req_result {
21132                Err(err) => {
21133                    if let common::Retry::After(d) = dlg.http_error(&err) {
21134                        sleep(d).await;
21135                        continue;
21136                    }
21137                    dlg.finished(false);
21138                    return Err(common::Error::HttpError(err));
21139                }
21140                Ok(res) => {
21141                    let (mut parts, body) = res.into_parts();
21142                    let mut body = common::Body::new(body);
21143                    if !parts.status.is_success() {
21144                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21145                        let error = serde_json::from_str(&common::to_string(&bytes));
21146                        let response = common::to_response(parts, bytes.into());
21147
21148                        if let common::Retry::After(d) =
21149                            dlg.http_failure(&response, error.as_ref().ok())
21150                        {
21151                            sleep(d).await;
21152                            continue;
21153                        }
21154
21155                        dlg.finished(false);
21156
21157                        return Err(match error {
21158                            Ok(value) => common::Error::BadRequest(value),
21159                            _ => common::Error::Failure(response),
21160                        });
21161                    }
21162                    let response = {
21163                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21164                        let encoded = common::to_string(&bytes);
21165                        match serde_json::from_str(&encoded) {
21166                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21167                            Err(error) => {
21168                                dlg.response_json_decode_error(&encoded, &error);
21169                                return Err(common::Error::JsonDecodeError(
21170                                    encoded.to_string(),
21171                                    error,
21172                                ));
21173                            }
21174                        }
21175                    };
21176
21177                    dlg.finished(true);
21178                    return Ok(response);
21179                }
21180            }
21181        }
21182    }
21183
21184    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
21185    ///
21186    /// Sets the *user id* path property to the given value.
21187    ///
21188    /// Even though the property as already been set when instantiating this call,
21189    /// we provide this method for API completeness.
21190    pub fn user_id(mut self, new_value: &str) -> UserSettingSendASmimeInfoListCall<'a, C> {
21191        self._user_id = new_value.to_string();
21192        self
21193    }
21194    /// The email address that appears in the "From:" header for mail sent using this alias.
21195    ///
21196    /// Sets the *send as email* path property to the given value.
21197    ///
21198    /// Even though the property as already been set when instantiating this call,
21199    /// we provide this method for API completeness.
21200    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendASmimeInfoListCall<'a, C> {
21201        self._send_as_email = new_value.to_string();
21202        self
21203    }
21204    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21205    /// while executing the actual API request.
21206    ///
21207    /// ````text
21208    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21209    /// ````
21210    ///
21211    /// Sets the *delegate* property to the given value.
21212    pub fn delegate(
21213        mut self,
21214        new_value: &'a mut dyn common::Delegate,
21215    ) -> UserSettingSendASmimeInfoListCall<'a, C> {
21216        self._delegate = Some(new_value);
21217        self
21218    }
21219
21220    /// Set any additional parameter of the query string used in the request.
21221    /// It should be used to set parameters which are not yet available through their own
21222    /// setters.
21223    ///
21224    /// Please note that this method must not be used to set any of the known parameters
21225    /// which have their own setter method. If done anyway, the request will fail.
21226    ///
21227    /// # Additional Parameters
21228    ///
21229    /// * *$.xgafv* (query-string) - V1 error format.
21230    /// * *access_token* (query-string) - OAuth access token.
21231    /// * *alt* (query-string) - Data format for response.
21232    /// * *callback* (query-string) - JSONP
21233    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21234    /// * *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.
21235    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21236    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21237    /// * *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.
21238    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21239    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21240    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendASmimeInfoListCall<'a, C>
21241    where
21242        T: AsRef<str>,
21243    {
21244        self._additional_params
21245            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21246        self
21247    }
21248
21249    /// Identifies the authorization scope for the method you are building.
21250    ///
21251    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21252    /// [`Scope::Readonly`].
21253    ///
21254    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21255    /// tokens for more than one scope.
21256    ///
21257    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21258    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21259    /// sufficient, a read-write scope will do as well.
21260    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendASmimeInfoListCall<'a, C>
21261    where
21262        St: AsRef<str>,
21263    {
21264        self._scopes.insert(String::from(scope.as_ref()));
21265        self
21266    }
21267    /// Identifies the authorization scope(s) for the method you are building.
21268    ///
21269    /// See [`Self::add_scope()`] for details.
21270    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendASmimeInfoListCall<'a, C>
21271    where
21272        I: IntoIterator<Item = St>,
21273        St: AsRef<str>,
21274    {
21275        self._scopes
21276            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21277        self
21278    }
21279
21280    /// Removes all scopes, and no default scope will be used either.
21281    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21282    /// for details).
21283    pub fn clear_scopes(mut self) -> UserSettingSendASmimeInfoListCall<'a, C> {
21284        self._scopes.clear();
21285        self
21286    }
21287}
21288
21289/// Sets the default S/MIME config for the specified send-as alias.
21290///
21291/// A builder for the *settings.sendAs.smimeInfo.setDefault* method supported by a *user* resource.
21292/// It is not used directly, but through a [`UserMethods`] instance.
21293///
21294/// # Example
21295///
21296/// Instantiate a resource method builder
21297///
21298/// ```test_harness,no_run
21299/// # extern crate hyper;
21300/// # extern crate hyper_rustls;
21301/// # extern crate google_gmail1 as gmail1;
21302/// # async fn dox() {
21303/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21304///
21305/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21306/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21307/// #     .with_native_roots()
21308/// #     .unwrap()
21309/// #     .https_only()
21310/// #     .enable_http2()
21311/// #     .build();
21312///
21313/// # let executor = hyper_util::rt::TokioExecutor::new();
21314/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21315/// #     secret,
21316/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21317/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21318/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21319/// #     ),
21320/// # ).build().await.unwrap();
21321///
21322/// # let client = hyper_util::client::legacy::Client::builder(
21323/// #     hyper_util::rt::TokioExecutor::new()
21324/// # )
21325/// # .build(
21326/// #     hyper_rustls::HttpsConnectorBuilder::new()
21327/// #         .with_native_roots()
21328/// #         .unwrap()
21329/// #         .https_or_http()
21330/// #         .enable_http2()
21331/// #         .build()
21332/// # );
21333/// # let mut hub = Gmail::new(client, auth);
21334/// // You can configure optional parameters by calling the respective setters at will, and
21335/// // execute the final call using `doit()`.
21336/// // Values shown here are possibly random and not representative !
21337/// let result = hub.users().settings_send_as_smime_info_set_default("userId", "sendAsEmail", "id")
21338///              .doit().await;
21339/// # }
21340/// ```
21341pub struct UserSettingSendASmimeInfoSetDefaultCall<'a, C>
21342where
21343    C: 'a,
21344{
21345    hub: &'a Gmail<C>,
21346    _user_id: String,
21347    _send_as_email: String,
21348    _id: String,
21349    _delegate: Option<&'a mut dyn common::Delegate>,
21350    _additional_params: HashMap<String, String>,
21351    _scopes: BTreeSet<String>,
21352}
21353
21354impl<'a, C> common::CallBuilder for UserSettingSendASmimeInfoSetDefaultCall<'a, C> {}
21355
21356impl<'a, C> UserSettingSendASmimeInfoSetDefaultCall<'a, C>
21357where
21358    C: common::Connector,
21359{
21360    /// Perform the operation you have build so far.
21361    pub async fn doit(mut self) -> common::Result<common::Response> {
21362        use std::borrow::Cow;
21363        use std::io::{Read, Seek};
21364
21365        use common::{url::Params, ToParts};
21366        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21367
21368        let mut dd = common::DefaultDelegate;
21369        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21370        dlg.begin(common::MethodInfo {
21371            id: "gmail.users.settings.sendAs.smimeInfo.setDefault",
21372            http_method: hyper::Method::POST,
21373        });
21374
21375        for &field in ["userId", "sendAsEmail", "id"].iter() {
21376            if self._additional_params.contains_key(field) {
21377                dlg.finished(false);
21378                return Err(common::Error::FieldClash(field));
21379            }
21380        }
21381
21382        let mut params = Params::with_capacity(4 + self._additional_params.len());
21383        params.push("userId", self._user_id);
21384        params.push("sendAsEmail", self._send_as_email);
21385        params.push("id", self._id);
21386
21387        params.extend(self._additional_params.iter());
21388
21389        let mut url = self.hub._base_url.clone()
21390            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault";
21391        if self._scopes.is_empty() {
21392            self._scopes
21393                .insert(Scope::SettingBasic.as_ref().to_string());
21394        }
21395
21396        #[allow(clippy::single_element_loop)]
21397        for &(find_this, param_name) in [
21398            ("{userId}", "userId"),
21399            ("{sendAsEmail}", "sendAsEmail"),
21400            ("{id}", "id"),
21401        ]
21402        .iter()
21403        {
21404            url = params.uri_replacement(url, param_name, find_this, false);
21405        }
21406        {
21407            let to_remove = ["id", "sendAsEmail", "userId"];
21408            params.remove_params(&to_remove);
21409        }
21410
21411        let url = params.parse_with_url(&url);
21412
21413        loop {
21414            let token = match self
21415                .hub
21416                .auth
21417                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21418                .await
21419            {
21420                Ok(token) => token,
21421                Err(e) => match dlg.token(e) {
21422                    Ok(token) => token,
21423                    Err(e) => {
21424                        dlg.finished(false);
21425                        return Err(common::Error::MissingToken(e));
21426                    }
21427                },
21428            };
21429            let mut req_result = {
21430                let client = &self.hub.client;
21431                dlg.pre_request();
21432                let mut req_builder = hyper::Request::builder()
21433                    .method(hyper::Method::POST)
21434                    .uri(url.as_str())
21435                    .header(USER_AGENT, self.hub._user_agent.clone());
21436
21437                if let Some(token) = token.as_ref() {
21438                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21439                }
21440
21441                let request = req_builder
21442                    .header(CONTENT_LENGTH, 0_u64)
21443                    .body(common::to_body::<String>(None));
21444
21445                client.request(request.unwrap()).await
21446            };
21447
21448            match req_result {
21449                Err(err) => {
21450                    if let common::Retry::After(d) = dlg.http_error(&err) {
21451                        sleep(d).await;
21452                        continue;
21453                    }
21454                    dlg.finished(false);
21455                    return Err(common::Error::HttpError(err));
21456                }
21457                Ok(res) => {
21458                    let (mut parts, body) = res.into_parts();
21459                    let mut body = common::Body::new(body);
21460                    if !parts.status.is_success() {
21461                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21462                        let error = serde_json::from_str(&common::to_string(&bytes));
21463                        let response = common::to_response(parts, bytes.into());
21464
21465                        if let common::Retry::After(d) =
21466                            dlg.http_failure(&response, error.as_ref().ok())
21467                        {
21468                            sleep(d).await;
21469                            continue;
21470                        }
21471
21472                        dlg.finished(false);
21473
21474                        return Err(match error {
21475                            Ok(value) => common::Error::BadRequest(value),
21476                            _ => common::Error::Failure(response),
21477                        });
21478                    }
21479                    let response = common::Response::from_parts(parts, body);
21480
21481                    dlg.finished(true);
21482                    return Ok(response);
21483                }
21484            }
21485        }
21486    }
21487
21488    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
21489    ///
21490    /// Sets the *user id* path property to the given value.
21491    ///
21492    /// Even though the property as already been set when instantiating this call,
21493    /// we provide this method for API completeness.
21494    pub fn user_id(mut self, new_value: &str) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
21495        self._user_id = new_value.to_string();
21496        self
21497    }
21498    /// The email address that appears in the "From:" header for mail sent using this alias.
21499    ///
21500    /// Sets the *send as email* path property to the given value.
21501    ///
21502    /// Even though the property as already been set when instantiating this call,
21503    /// we provide this method for API completeness.
21504    pub fn send_as_email(
21505        mut self,
21506        new_value: &str,
21507    ) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
21508        self._send_as_email = new_value.to_string();
21509        self
21510    }
21511    /// The immutable ID for the SmimeInfo.
21512    ///
21513    /// Sets the *id* path property to the given value.
21514    ///
21515    /// Even though the property as already been set when instantiating this call,
21516    /// we provide this method for API completeness.
21517    pub fn id(mut self, new_value: &str) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
21518        self._id = new_value.to_string();
21519        self
21520    }
21521    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21522    /// while executing the actual API request.
21523    ///
21524    /// ````text
21525    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21526    /// ````
21527    ///
21528    /// Sets the *delegate* property to the given value.
21529    pub fn delegate(
21530        mut self,
21531        new_value: &'a mut dyn common::Delegate,
21532    ) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
21533        self._delegate = Some(new_value);
21534        self
21535    }
21536
21537    /// Set any additional parameter of the query string used in the request.
21538    /// It should be used to set parameters which are not yet available through their own
21539    /// setters.
21540    ///
21541    /// Please note that this method must not be used to set any of the known parameters
21542    /// which have their own setter method. If done anyway, the request will fail.
21543    ///
21544    /// # Additional Parameters
21545    ///
21546    /// * *$.xgafv* (query-string) - V1 error format.
21547    /// * *access_token* (query-string) - OAuth access token.
21548    /// * *alt* (query-string) - Data format for response.
21549    /// * *callback* (query-string) - JSONP
21550    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21551    /// * *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.
21552    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21553    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21554    /// * *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.
21555    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21556    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21557    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C>
21558    where
21559        T: AsRef<str>,
21560    {
21561        self._additional_params
21562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21563        self
21564    }
21565
21566    /// Identifies the authorization scope for the method you are building.
21567    ///
21568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21569    /// [`Scope::SettingBasic`].
21570    ///
21571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21572    /// tokens for more than one scope.
21573    ///
21574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21576    /// sufficient, a read-write scope will do as well.
21577    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C>
21578    where
21579        St: AsRef<str>,
21580    {
21581        self._scopes.insert(String::from(scope.as_ref()));
21582        self
21583    }
21584    /// Identifies the authorization scope(s) for the method you are building.
21585    ///
21586    /// See [`Self::add_scope()`] for details.
21587    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C>
21588    where
21589        I: IntoIterator<Item = St>,
21590        St: AsRef<str>,
21591    {
21592        self._scopes
21593            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21594        self
21595    }
21596
21597    /// Removes all scopes, and no default scope will be used either.
21598    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21599    /// for details).
21600    pub fn clear_scopes(mut self) -> UserSettingSendASmimeInfoSetDefaultCall<'a, C> {
21601        self._scopes.clear();
21602        self
21603    }
21604}
21605
21606/// Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail will attempt to connect to the SMTP service to validate the configuration before creating the alias. If ownership verification is required for the alias, a message will be sent to the email address and the resource's verification status will be set to `pending`; otherwise, the resource will be created with verification status set to `accepted`. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. This method is only available to service account clients that have been delegated domain-wide authority.
21607///
21608/// A builder for the *settings.sendAs.create* method supported by a *user* resource.
21609/// It is not used directly, but through a [`UserMethods`] instance.
21610///
21611/// # Example
21612///
21613/// Instantiate a resource method builder
21614///
21615/// ```test_harness,no_run
21616/// # extern crate hyper;
21617/// # extern crate hyper_rustls;
21618/// # extern crate google_gmail1 as gmail1;
21619/// use gmail1::api::SendAs;
21620/// # async fn dox() {
21621/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21622///
21623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21624/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21625/// #     .with_native_roots()
21626/// #     .unwrap()
21627/// #     .https_only()
21628/// #     .enable_http2()
21629/// #     .build();
21630///
21631/// # let executor = hyper_util::rt::TokioExecutor::new();
21632/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21633/// #     secret,
21634/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21635/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21636/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21637/// #     ),
21638/// # ).build().await.unwrap();
21639///
21640/// # let client = hyper_util::client::legacy::Client::builder(
21641/// #     hyper_util::rt::TokioExecutor::new()
21642/// # )
21643/// # .build(
21644/// #     hyper_rustls::HttpsConnectorBuilder::new()
21645/// #         .with_native_roots()
21646/// #         .unwrap()
21647/// #         .https_or_http()
21648/// #         .enable_http2()
21649/// #         .build()
21650/// # );
21651/// # let mut hub = Gmail::new(client, auth);
21652/// // As the method needs a request, you would usually fill it with the desired information
21653/// // into the respective structure. Some of the parts shown here might not be applicable !
21654/// // Values shown here are possibly random and not representative !
21655/// let mut req = SendAs::default();
21656///
21657/// // You can configure optional parameters by calling the respective setters at will, and
21658/// // execute the final call using `doit()`.
21659/// // Values shown here are possibly random and not representative !
21660/// let result = hub.users().settings_send_as_create(req, "userId")
21661///              .doit().await;
21662/// # }
21663/// ```
21664pub struct UserSettingSendACreateCall<'a, C>
21665where
21666    C: 'a,
21667{
21668    hub: &'a Gmail<C>,
21669    _request: SendAs,
21670    _user_id: String,
21671    _delegate: Option<&'a mut dyn common::Delegate>,
21672    _additional_params: HashMap<String, String>,
21673    _scopes: BTreeSet<String>,
21674}
21675
21676impl<'a, C> common::CallBuilder for UserSettingSendACreateCall<'a, C> {}
21677
21678impl<'a, C> UserSettingSendACreateCall<'a, C>
21679where
21680    C: common::Connector,
21681{
21682    /// Perform the operation you have build so far.
21683    pub async fn doit(mut self) -> common::Result<(common::Response, SendAs)> {
21684        use std::borrow::Cow;
21685        use std::io::{Read, Seek};
21686
21687        use common::{url::Params, ToParts};
21688        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21689
21690        let mut dd = common::DefaultDelegate;
21691        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21692        dlg.begin(common::MethodInfo {
21693            id: "gmail.users.settings.sendAs.create",
21694            http_method: hyper::Method::POST,
21695        });
21696
21697        for &field in ["alt", "userId"].iter() {
21698            if self._additional_params.contains_key(field) {
21699                dlg.finished(false);
21700                return Err(common::Error::FieldClash(field));
21701            }
21702        }
21703
21704        let mut params = Params::with_capacity(4 + self._additional_params.len());
21705        params.push("userId", self._user_id);
21706
21707        params.extend(self._additional_params.iter());
21708
21709        params.push("alt", "json");
21710        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs";
21711        if self._scopes.is_empty() {
21712            self._scopes
21713                .insert(Scope::SettingSharing.as_ref().to_string());
21714        }
21715
21716        #[allow(clippy::single_element_loop)]
21717        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
21718            url = params.uri_replacement(url, param_name, find_this, false);
21719        }
21720        {
21721            let to_remove = ["userId"];
21722            params.remove_params(&to_remove);
21723        }
21724
21725        let url = params.parse_with_url(&url);
21726
21727        let mut json_mime_type = mime::APPLICATION_JSON;
21728        let mut request_value_reader = {
21729            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21730            common::remove_json_null_values(&mut value);
21731            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21732            serde_json::to_writer(&mut dst, &value).unwrap();
21733            dst
21734        };
21735        let request_size = request_value_reader
21736            .seek(std::io::SeekFrom::End(0))
21737            .unwrap();
21738        request_value_reader
21739            .seek(std::io::SeekFrom::Start(0))
21740            .unwrap();
21741
21742        loop {
21743            let token = match self
21744                .hub
21745                .auth
21746                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21747                .await
21748            {
21749                Ok(token) => token,
21750                Err(e) => match dlg.token(e) {
21751                    Ok(token) => token,
21752                    Err(e) => {
21753                        dlg.finished(false);
21754                        return Err(common::Error::MissingToken(e));
21755                    }
21756                },
21757            };
21758            request_value_reader
21759                .seek(std::io::SeekFrom::Start(0))
21760                .unwrap();
21761            let mut req_result = {
21762                let client = &self.hub.client;
21763                dlg.pre_request();
21764                let mut req_builder = hyper::Request::builder()
21765                    .method(hyper::Method::POST)
21766                    .uri(url.as_str())
21767                    .header(USER_AGENT, self.hub._user_agent.clone());
21768
21769                if let Some(token) = token.as_ref() {
21770                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21771                }
21772
21773                let request = req_builder
21774                    .header(CONTENT_TYPE, json_mime_type.to_string())
21775                    .header(CONTENT_LENGTH, request_size as u64)
21776                    .body(common::to_body(
21777                        request_value_reader.get_ref().clone().into(),
21778                    ));
21779
21780                client.request(request.unwrap()).await
21781            };
21782
21783            match req_result {
21784                Err(err) => {
21785                    if let common::Retry::After(d) = dlg.http_error(&err) {
21786                        sleep(d).await;
21787                        continue;
21788                    }
21789                    dlg.finished(false);
21790                    return Err(common::Error::HttpError(err));
21791                }
21792                Ok(res) => {
21793                    let (mut parts, body) = res.into_parts();
21794                    let mut body = common::Body::new(body);
21795                    if !parts.status.is_success() {
21796                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21797                        let error = serde_json::from_str(&common::to_string(&bytes));
21798                        let response = common::to_response(parts, bytes.into());
21799
21800                        if let common::Retry::After(d) =
21801                            dlg.http_failure(&response, error.as_ref().ok())
21802                        {
21803                            sleep(d).await;
21804                            continue;
21805                        }
21806
21807                        dlg.finished(false);
21808
21809                        return Err(match error {
21810                            Ok(value) => common::Error::BadRequest(value),
21811                            _ => common::Error::Failure(response),
21812                        });
21813                    }
21814                    let response = {
21815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
21816                        let encoded = common::to_string(&bytes);
21817                        match serde_json::from_str(&encoded) {
21818                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21819                            Err(error) => {
21820                                dlg.response_json_decode_error(&encoded, &error);
21821                                return Err(common::Error::JsonDecodeError(
21822                                    encoded.to_string(),
21823                                    error,
21824                                ));
21825                            }
21826                        }
21827                    };
21828
21829                    dlg.finished(true);
21830                    return Ok(response);
21831                }
21832            }
21833        }
21834    }
21835
21836    ///
21837    /// Sets the *request* property to the given value.
21838    ///
21839    /// Even though the property as already been set when instantiating this call,
21840    /// we provide this method for API completeness.
21841    pub fn request(mut self, new_value: SendAs) -> UserSettingSendACreateCall<'a, C> {
21842        self._request = new_value;
21843        self
21844    }
21845    /// User's email address. The special value "me" can be used to indicate the authenticated user.
21846    ///
21847    /// Sets the *user id* path property to the given value.
21848    ///
21849    /// Even though the property as already been set when instantiating this call,
21850    /// we provide this method for API completeness.
21851    pub fn user_id(mut self, new_value: &str) -> UserSettingSendACreateCall<'a, C> {
21852        self._user_id = new_value.to_string();
21853        self
21854    }
21855    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21856    /// while executing the actual API request.
21857    ///
21858    /// ````text
21859    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
21860    /// ````
21861    ///
21862    /// Sets the *delegate* property to the given value.
21863    pub fn delegate(
21864        mut self,
21865        new_value: &'a mut dyn common::Delegate,
21866    ) -> UserSettingSendACreateCall<'a, C> {
21867        self._delegate = Some(new_value);
21868        self
21869    }
21870
21871    /// Set any additional parameter of the query string used in the request.
21872    /// It should be used to set parameters which are not yet available through their own
21873    /// setters.
21874    ///
21875    /// Please note that this method must not be used to set any of the known parameters
21876    /// which have their own setter method. If done anyway, the request will fail.
21877    ///
21878    /// # Additional Parameters
21879    ///
21880    /// * *$.xgafv* (query-string) - V1 error format.
21881    /// * *access_token* (query-string) - OAuth access token.
21882    /// * *alt* (query-string) - Data format for response.
21883    /// * *callback* (query-string) - JSONP
21884    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21885    /// * *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.
21886    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21887    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21888    /// * *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.
21889    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21890    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21891    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendACreateCall<'a, C>
21892    where
21893        T: AsRef<str>,
21894    {
21895        self._additional_params
21896            .insert(name.as_ref().to_string(), value.as_ref().to_string());
21897        self
21898    }
21899
21900    /// Identifies the authorization scope for the method you are building.
21901    ///
21902    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21903    /// [`Scope::SettingSharing`].
21904    ///
21905    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21906    /// tokens for more than one scope.
21907    ///
21908    /// Usually there is more than one suitable scope to authorize an operation, some of which may
21909    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21910    /// sufficient, a read-write scope will do as well.
21911    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendACreateCall<'a, C>
21912    where
21913        St: AsRef<str>,
21914    {
21915        self._scopes.insert(String::from(scope.as_ref()));
21916        self
21917    }
21918    /// Identifies the authorization scope(s) for the method you are building.
21919    ///
21920    /// See [`Self::add_scope()`] for details.
21921    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendACreateCall<'a, C>
21922    where
21923        I: IntoIterator<Item = St>,
21924        St: AsRef<str>,
21925    {
21926        self._scopes
21927            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21928        self
21929    }
21930
21931    /// Removes all scopes, and no default scope will be used either.
21932    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21933    /// for details).
21934    pub fn clear_scopes(mut self) -> UserSettingSendACreateCall<'a, C> {
21935        self._scopes.clear();
21936        self
21937    }
21938}
21939
21940/// Deletes the specified send-as alias. Revokes any verification that may have been required for using it. This method is only available to service account clients that have been delegated domain-wide authority.
21941///
21942/// A builder for the *settings.sendAs.delete* method supported by a *user* resource.
21943/// It is not used directly, but through a [`UserMethods`] instance.
21944///
21945/// # Example
21946///
21947/// Instantiate a resource method builder
21948///
21949/// ```test_harness,no_run
21950/// # extern crate hyper;
21951/// # extern crate hyper_rustls;
21952/// # extern crate google_gmail1 as gmail1;
21953/// # async fn dox() {
21954/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21955///
21956/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21957/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21958/// #     .with_native_roots()
21959/// #     .unwrap()
21960/// #     .https_only()
21961/// #     .enable_http2()
21962/// #     .build();
21963///
21964/// # let executor = hyper_util::rt::TokioExecutor::new();
21965/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21966/// #     secret,
21967/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21968/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
21969/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
21970/// #     ),
21971/// # ).build().await.unwrap();
21972///
21973/// # let client = hyper_util::client::legacy::Client::builder(
21974/// #     hyper_util::rt::TokioExecutor::new()
21975/// # )
21976/// # .build(
21977/// #     hyper_rustls::HttpsConnectorBuilder::new()
21978/// #         .with_native_roots()
21979/// #         .unwrap()
21980/// #         .https_or_http()
21981/// #         .enable_http2()
21982/// #         .build()
21983/// # );
21984/// # let mut hub = Gmail::new(client, auth);
21985/// // You can configure optional parameters by calling the respective setters at will, and
21986/// // execute the final call using `doit()`.
21987/// // Values shown here are possibly random and not representative !
21988/// let result = hub.users().settings_send_as_delete("userId", "sendAsEmail")
21989///              .doit().await;
21990/// # }
21991/// ```
21992pub struct UserSettingSendADeleteCall<'a, C>
21993where
21994    C: 'a,
21995{
21996    hub: &'a Gmail<C>,
21997    _user_id: String,
21998    _send_as_email: String,
21999    _delegate: Option<&'a mut dyn common::Delegate>,
22000    _additional_params: HashMap<String, String>,
22001    _scopes: BTreeSet<String>,
22002}
22003
22004impl<'a, C> common::CallBuilder for UserSettingSendADeleteCall<'a, C> {}
22005
22006impl<'a, C> UserSettingSendADeleteCall<'a, C>
22007where
22008    C: common::Connector,
22009{
22010    /// Perform the operation you have build so far.
22011    pub async fn doit(mut self) -> common::Result<common::Response> {
22012        use std::borrow::Cow;
22013        use std::io::{Read, Seek};
22014
22015        use common::{url::Params, ToParts};
22016        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22017
22018        let mut dd = common::DefaultDelegate;
22019        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22020        dlg.begin(common::MethodInfo {
22021            id: "gmail.users.settings.sendAs.delete",
22022            http_method: hyper::Method::DELETE,
22023        });
22024
22025        for &field in ["userId", "sendAsEmail"].iter() {
22026            if self._additional_params.contains_key(field) {
22027                dlg.finished(false);
22028                return Err(common::Error::FieldClash(field));
22029            }
22030        }
22031
22032        let mut params = Params::with_capacity(3 + self._additional_params.len());
22033        params.push("userId", self._user_id);
22034        params.push("sendAsEmail", self._send_as_email);
22035
22036        params.extend(self._additional_params.iter());
22037
22038        let mut url =
22039            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}";
22040        if self._scopes.is_empty() {
22041            self._scopes
22042                .insert(Scope::SettingSharing.as_ref().to_string());
22043        }
22044
22045        #[allow(clippy::single_element_loop)]
22046        for &(find_this, param_name) in
22047            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
22048        {
22049            url = params.uri_replacement(url, param_name, find_this, false);
22050        }
22051        {
22052            let to_remove = ["sendAsEmail", "userId"];
22053            params.remove_params(&to_remove);
22054        }
22055
22056        let url = params.parse_with_url(&url);
22057
22058        loop {
22059            let token = match self
22060                .hub
22061                .auth
22062                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22063                .await
22064            {
22065                Ok(token) => token,
22066                Err(e) => match dlg.token(e) {
22067                    Ok(token) => token,
22068                    Err(e) => {
22069                        dlg.finished(false);
22070                        return Err(common::Error::MissingToken(e));
22071                    }
22072                },
22073            };
22074            let mut req_result = {
22075                let client = &self.hub.client;
22076                dlg.pre_request();
22077                let mut req_builder = hyper::Request::builder()
22078                    .method(hyper::Method::DELETE)
22079                    .uri(url.as_str())
22080                    .header(USER_AGENT, self.hub._user_agent.clone());
22081
22082                if let Some(token) = token.as_ref() {
22083                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22084                }
22085
22086                let request = req_builder
22087                    .header(CONTENT_LENGTH, 0_u64)
22088                    .body(common::to_body::<String>(None));
22089
22090                client.request(request.unwrap()).await
22091            };
22092
22093            match req_result {
22094                Err(err) => {
22095                    if let common::Retry::After(d) = dlg.http_error(&err) {
22096                        sleep(d).await;
22097                        continue;
22098                    }
22099                    dlg.finished(false);
22100                    return Err(common::Error::HttpError(err));
22101                }
22102                Ok(res) => {
22103                    let (mut parts, body) = res.into_parts();
22104                    let mut body = common::Body::new(body);
22105                    if !parts.status.is_success() {
22106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22107                        let error = serde_json::from_str(&common::to_string(&bytes));
22108                        let response = common::to_response(parts, bytes.into());
22109
22110                        if let common::Retry::After(d) =
22111                            dlg.http_failure(&response, error.as_ref().ok())
22112                        {
22113                            sleep(d).await;
22114                            continue;
22115                        }
22116
22117                        dlg.finished(false);
22118
22119                        return Err(match error {
22120                            Ok(value) => common::Error::BadRequest(value),
22121                            _ => common::Error::Failure(response),
22122                        });
22123                    }
22124                    let response = common::Response::from_parts(parts, body);
22125
22126                    dlg.finished(true);
22127                    return Ok(response);
22128                }
22129            }
22130        }
22131    }
22132
22133    /// User's email address. The special value "me" can be used to indicate the authenticated user.
22134    ///
22135    /// Sets the *user id* path property to the given value.
22136    ///
22137    /// Even though the property as already been set when instantiating this call,
22138    /// we provide this method for API completeness.
22139    pub fn user_id(mut self, new_value: &str) -> UserSettingSendADeleteCall<'a, C> {
22140        self._user_id = new_value.to_string();
22141        self
22142    }
22143    /// The send-as alias to be deleted.
22144    ///
22145    /// Sets the *send as email* path property to the given value.
22146    ///
22147    /// Even though the property as already been set when instantiating this call,
22148    /// we provide this method for API completeness.
22149    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendADeleteCall<'a, C> {
22150        self._send_as_email = new_value.to_string();
22151        self
22152    }
22153    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22154    /// while executing the actual API request.
22155    ///
22156    /// ````text
22157    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22158    /// ````
22159    ///
22160    /// Sets the *delegate* property to the given value.
22161    pub fn delegate(
22162        mut self,
22163        new_value: &'a mut dyn common::Delegate,
22164    ) -> UserSettingSendADeleteCall<'a, C> {
22165        self._delegate = Some(new_value);
22166        self
22167    }
22168
22169    /// Set any additional parameter of the query string used in the request.
22170    /// It should be used to set parameters which are not yet available through their own
22171    /// setters.
22172    ///
22173    /// Please note that this method must not be used to set any of the known parameters
22174    /// which have their own setter method. If done anyway, the request will fail.
22175    ///
22176    /// # Additional Parameters
22177    ///
22178    /// * *$.xgafv* (query-string) - V1 error format.
22179    /// * *access_token* (query-string) - OAuth access token.
22180    /// * *alt* (query-string) - Data format for response.
22181    /// * *callback* (query-string) - JSONP
22182    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22183    /// * *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.
22184    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22185    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22186    /// * *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.
22187    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22188    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22189    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendADeleteCall<'a, C>
22190    where
22191        T: AsRef<str>,
22192    {
22193        self._additional_params
22194            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22195        self
22196    }
22197
22198    /// Identifies the authorization scope for the method you are building.
22199    ///
22200    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22201    /// [`Scope::SettingSharing`].
22202    ///
22203    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22204    /// tokens for more than one scope.
22205    ///
22206    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22207    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22208    /// sufficient, a read-write scope will do as well.
22209    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendADeleteCall<'a, C>
22210    where
22211        St: AsRef<str>,
22212    {
22213        self._scopes.insert(String::from(scope.as_ref()));
22214        self
22215    }
22216    /// Identifies the authorization scope(s) for the method you are building.
22217    ///
22218    /// See [`Self::add_scope()`] for details.
22219    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendADeleteCall<'a, C>
22220    where
22221        I: IntoIterator<Item = St>,
22222        St: AsRef<str>,
22223    {
22224        self._scopes
22225            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22226        self
22227    }
22228
22229    /// Removes all scopes, and no default scope will be used either.
22230    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22231    /// for details).
22232    pub fn clear_scopes(mut self) -> UserSettingSendADeleteCall<'a, C> {
22233        self._scopes.clear();
22234        self
22235    }
22236}
22237
22238/// Gets the specified send-as alias. Fails with an HTTP 404 error if the specified address is not a member of the collection.
22239///
22240/// A builder for the *settings.sendAs.get* method supported by a *user* resource.
22241/// It is not used directly, but through a [`UserMethods`] instance.
22242///
22243/// # Example
22244///
22245/// Instantiate a resource method builder
22246///
22247/// ```test_harness,no_run
22248/// # extern crate hyper;
22249/// # extern crate hyper_rustls;
22250/// # extern crate google_gmail1 as gmail1;
22251/// # async fn dox() {
22252/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22253///
22254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22256/// #     .with_native_roots()
22257/// #     .unwrap()
22258/// #     .https_only()
22259/// #     .enable_http2()
22260/// #     .build();
22261///
22262/// # let executor = hyper_util::rt::TokioExecutor::new();
22263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22264/// #     secret,
22265/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22266/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22267/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22268/// #     ),
22269/// # ).build().await.unwrap();
22270///
22271/// # let client = hyper_util::client::legacy::Client::builder(
22272/// #     hyper_util::rt::TokioExecutor::new()
22273/// # )
22274/// # .build(
22275/// #     hyper_rustls::HttpsConnectorBuilder::new()
22276/// #         .with_native_roots()
22277/// #         .unwrap()
22278/// #         .https_or_http()
22279/// #         .enable_http2()
22280/// #         .build()
22281/// # );
22282/// # let mut hub = Gmail::new(client, auth);
22283/// // You can configure optional parameters by calling the respective setters at will, and
22284/// // execute the final call using `doit()`.
22285/// // Values shown here are possibly random and not representative !
22286/// let result = hub.users().settings_send_as_get("userId", "sendAsEmail")
22287///              .doit().await;
22288/// # }
22289/// ```
22290pub struct UserSettingSendAGetCall<'a, C>
22291where
22292    C: 'a,
22293{
22294    hub: &'a Gmail<C>,
22295    _user_id: String,
22296    _send_as_email: String,
22297    _delegate: Option<&'a mut dyn common::Delegate>,
22298    _additional_params: HashMap<String, String>,
22299    _scopes: BTreeSet<String>,
22300}
22301
22302impl<'a, C> common::CallBuilder for UserSettingSendAGetCall<'a, C> {}
22303
22304impl<'a, C> UserSettingSendAGetCall<'a, C>
22305where
22306    C: common::Connector,
22307{
22308    /// Perform the operation you have build so far.
22309    pub async fn doit(mut self) -> common::Result<(common::Response, SendAs)> {
22310        use std::borrow::Cow;
22311        use std::io::{Read, Seek};
22312
22313        use common::{url::Params, ToParts};
22314        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22315
22316        let mut dd = common::DefaultDelegate;
22317        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22318        dlg.begin(common::MethodInfo {
22319            id: "gmail.users.settings.sendAs.get",
22320            http_method: hyper::Method::GET,
22321        });
22322
22323        for &field in ["alt", "userId", "sendAsEmail"].iter() {
22324            if self._additional_params.contains_key(field) {
22325                dlg.finished(false);
22326                return Err(common::Error::FieldClash(field));
22327            }
22328        }
22329
22330        let mut params = Params::with_capacity(4 + self._additional_params.len());
22331        params.push("userId", self._user_id);
22332        params.push("sendAsEmail", self._send_as_email);
22333
22334        params.extend(self._additional_params.iter());
22335
22336        params.push("alt", "json");
22337        let mut url =
22338            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}";
22339        if self._scopes.is_empty() {
22340            self._scopes.insert(Scope::Readonly.as_ref().to_string());
22341        }
22342
22343        #[allow(clippy::single_element_loop)]
22344        for &(find_this, param_name) in
22345            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
22346        {
22347            url = params.uri_replacement(url, param_name, find_this, false);
22348        }
22349        {
22350            let to_remove = ["sendAsEmail", "userId"];
22351            params.remove_params(&to_remove);
22352        }
22353
22354        let url = params.parse_with_url(&url);
22355
22356        loop {
22357            let token = match self
22358                .hub
22359                .auth
22360                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22361                .await
22362            {
22363                Ok(token) => token,
22364                Err(e) => match dlg.token(e) {
22365                    Ok(token) => token,
22366                    Err(e) => {
22367                        dlg.finished(false);
22368                        return Err(common::Error::MissingToken(e));
22369                    }
22370                },
22371            };
22372            let mut req_result = {
22373                let client = &self.hub.client;
22374                dlg.pre_request();
22375                let mut req_builder = hyper::Request::builder()
22376                    .method(hyper::Method::GET)
22377                    .uri(url.as_str())
22378                    .header(USER_AGENT, self.hub._user_agent.clone());
22379
22380                if let Some(token) = token.as_ref() {
22381                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22382                }
22383
22384                let request = req_builder
22385                    .header(CONTENT_LENGTH, 0_u64)
22386                    .body(common::to_body::<String>(None));
22387
22388                client.request(request.unwrap()).await
22389            };
22390
22391            match req_result {
22392                Err(err) => {
22393                    if let common::Retry::After(d) = dlg.http_error(&err) {
22394                        sleep(d).await;
22395                        continue;
22396                    }
22397                    dlg.finished(false);
22398                    return Err(common::Error::HttpError(err));
22399                }
22400                Ok(res) => {
22401                    let (mut parts, body) = res.into_parts();
22402                    let mut body = common::Body::new(body);
22403                    if !parts.status.is_success() {
22404                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22405                        let error = serde_json::from_str(&common::to_string(&bytes));
22406                        let response = common::to_response(parts, bytes.into());
22407
22408                        if let common::Retry::After(d) =
22409                            dlg.http_failure(&response, error.as_ref().ok())
22410                        {
22411                            sleep(d).await;
22412                            continue;
22413                        }
22414
22415                        dlg.finished(false);
22416
22417                        return Err(match error {
22418                            Ok(value) => common::Error::BadRequest(value),
22419                            _ => common::Error::Failure(response),
22420                        });
22421                    }
22422                    let response = {
22423                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22424                        let encoded = common::to_string(&bytes);
22425                        match serde_json::from_str(&encoded) {
22426                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22427                            Err(error) => {
22428                                dlg.response_json_decode_error(&encoded, &error);
22429                                return Err(common::Error::JsonDecodeError(
22430                                    encoded.to_string(),
22431                                    error,
22432                                ));
22433                            }
22434                        }
22435                    };
22436
22437                    dlg.finished(true);
22438                    return Ok(response);
22439                }
22440            }
22441        }
22442    }
22443
22444    /// User's email address. The special value "me" can be used to indicate the authenticated user.
22445    ///
22446    /// Sets the *user id* path property to the given value.
22447    ///
22448    /// Even though the property as already been set when instantiating this call,
22449    /// we provide this method for API completeness.
22450    pub fn user_id(mut self, new_value: &str) -> UserSettingSendAGetCall<'a, C> {
22451        self._user_id = new_value.to_string();
22452        self
22453    }
22454    /// The send-as alias to be retrieved.
22455    ///
22456    /// Sets the *send as email* path property to the given value.
22457    ///
22458    /// Even though the property as already been set when instantiating this call,
22459    /// we provide this method for API completeness.
22460    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAGetCall<'a, C> {
22461        self._send_as_email = new_value.to_string();
22462        self
22463    }
22464    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22465    /// while executing the actual API request.
22466    ///
22467    /// ````text
22468    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22469    /// ````
22470    ///
22471    /// Sets the *delegate* property to the given value.
22472    pub fn delegate(
22473        mut self,
22474        new_value: &'a mut dyn common::Delegate,
22475    ) -> UserSettingSendAGetCall<'a, C> {
22476        self._delegate = Some(new_value);
22477        self
22478    }
22479
22480    /// Set any additional parameter of the query string used in the request.
22481    /// It should be used to set parameters which are not yet available through their own
22482    /// setters.
22483    ///
22484    /// Please note that this method must not be used to set any of the known parameters
22485    /// which have their own setter method. If done anyway, the request will fail.
22486    ///
22487    /// # Additional Parameters
22488    ///
22489    /// * *$.xgafv* (query-string) - V1 error format.
22490    /// * *access_token* (query-string) - OAuth access token.
22491    /// * *alt* (query-string) - Data format for response.
22492    /// * *callback* (query-string) - JSONP
22493    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22494    /// * *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.
22495    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22496    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22497    /// * *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.
22498    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22499    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22500    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendAGetCall<'a, C>
22501    where
22502        T: AsRef<str>,
22503    {
22504        self._additional_params
22505            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22506        self
22507    }
22508
22509    /// Identifies the authorization scope for the method you are building.
22510    ///
22511    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22512    /// [`Scope::Readonly`].
22513    ///
22514    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22515    /// tokens for more than one scope.
22516    ///
22517    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22518    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22519    /// sufficient, a read-write scope will do as well.
22520    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendAGetCall<'a, C>
22521    where
22522        St: AsRef<str>,
22523    {
22524        self._scopes.insert(String::from(scope.as_ref()));
22525        self
22526    }
22527    /// Identifies the authorization scope(s) for the method you are building.
22528    ///
22529    /// See [`Self::add_scope()`] for details.
22530    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendAGetCall<'a, C>
22531    where
22532        I: IntoIterator<Item = St>,
22533        St: AsRef<str>,
22534    {
22535        self._scopes
22536            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22537        self
22538    }
22539
22540    /// Removes all scopes, and no default scope will be used either.
22541    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22542    /// for details).
22543    pub fn clear_scopes(mut self) -> UserSettingSendAGetCall<'a, C> {
22544        self._scopes.clear();
22545        self
22546    }
22547}
22548
22549/// Lists the send-as aliases for the specified account. The result includes the primary send-as address associated with the account as well as any custom "from" aliases.
22550///
22551/// A builder for the *settings.sendAs.list* method supported by a *user* resource.
22552/// It is not used directly, but through a [`UserMethods`] instance.
22553///
22554/// # Example
22555///
22556/// Instantiate a resource method builder
22557///
22558/// ```test_harness,no_run
22559/// # extern crate hyper;
22560/// # extern crate hyper_rustls;
22561/// # extern crate google_gmail1 as gmail1;
22562/// # async fn dox() {
22563/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22564///
22565/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22566/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22567/// #     .with_native_roots()
22568/// #     .unwrap()
22569/// #     .https_only()
22570/// #     .enable_http2()
22571/// #     .build();
22572///
22573/// # let executor = hyper_util::rt::TokioExecutor::new();
22574/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22575/// #     secret,
22576/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22577/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22578/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22579/// #     ),
22580/// # ).build().await.unwrap();
22581///
22582/// # let client = hyper_util::client::legacy::Client::builder(
22583/// #     hyper_util::rt::TokioExecutor::new()
22584/// # )
22585/// # .build(
22586/// #     hyper_rustls::HttpsConnectorBuilder::new()
22587/// #         .with_native_roots()
22588/// #         .unwrap()
22589/// #         .https_or_http()
22590/// #         .enable_http2()
22591/// #         .build()
22592/// # );
22593/// # let mut hub = Gmail::new(client, auth);
22594/// // You can configure optional parameters by calling the respective setters at will, and
22595/// // execute the final call using `doit()`.
22596/// // Values shown here are possibly random and not representative !
22597/// let result = hub.users().settings_send_as_list("userId")
22598///              .doit().await;
22599/// # }
22600/// ```
22601pub struct UserSettingSendAListCall<'a, C>
22602where
22603    C: 'a,
22604{
22605    hub: &'a Gmail<C>,
22606    _user_id: String,
22607    _delegate: Option<&'a mut dyn common::Delegate>,
22608    _additional_params: HashMap<String, String>,
22609    _scopes: BTreeSet<String>,
22610}
22611
22612impl<'a, C> common::CallBuilder for UserSettingSendAListCall<'a, C> {}
22613
22614impl<'a, C> UserSettingSendAListCall<'a, C>
22615where
22616    C: common::Connector,
22617{
22618    /// Perform the operation you have build so far.
22619    pub async fn doit(mut self) -> common::Result<(common::Response, ListSendAsResponse)> {
22620        use std::borrow::Cow;
22621        use std::io::{Read, Seek};
22622
22623        use common::{url::Params, ToParts};
22624        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22625
22626        let mut dd = common::DefaultDelegate;
22627        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22628        dlg.begin(common::MethodInfo {
22629            id: "gmail.users.settings.sendAs.list",
22630            http_method: hyper::Method::GET,
22631        });
22632
22633        for &field in ["alt", "userId"].iter() {
22634            if self._additional_params.contains_key(field) {
22635                dlg.finished(false);
22636                return Err(common::Error::FieldClash(field));
22637            }
22638        }
22639
22640        let mut params = Params::with_capacity(3 + self._additional_params.len());
22641        params.push("userId", self._user_id);
22642
22643        params.extend(self._additional_params.iter());
22644
22645        params.push("alt", "json");
22646        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs";
22647        if self._scopes.is_empty() {
22648            self._scopes.insert(Scope::Readonly.as_ref().to_string());
22649        }
22650
22651        #[allow(clippy::single_element_loop)]
22652        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
22653            url = params.uri_replacement(url, param_name, find_this, false);
22654        }
22655        {
22656            let to_remove = ["userId"];
22657            params.remove_params(&to_remove);
22658        }
22659
22660        let url = params.parse_with_url(&url);
22661
22662        loop {
22663            let token = match self
22664                .hub
22665                .auth
22666                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22667                .await
22668            {
22669                Ok(token) => token,
22670                Err(e) => match dlg.token(e) {
22671                    Ok(token) => token,
22672                    Err(e) => {
22673                        dlg.finished(false);
22674                        return Err(common::Error::MissingToken(e));
22675                    }
22676                },
22677            };
22678            let mut req_result = {
22679                let client = &self.hub.client;
22680                dlg.pre_request();
22681                let mut req_builder = hyper::Request::builder()
22682                    .method(hyper::Method::GET)
22683                    .uri(url.as_str())
22684                    .header(USER_AGENT, self.hub._user_agent.clone());
22685
22686                if let Some(token) = token.as_ref() {
22687                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22688                }
22689
22690                let request = req_builder
22691                    .header(CONTENT_LENGTH, 0_u64)
22692                    .body(common::to_body::<String>(None));
22693
22694                client.request(request.unwrap()).await
22695            };
22696
22697            match req_result {
22698                Err(err) => {
22699                    if let common::Retry::After(d) = dlg.http_error(&err) {
22700                        sleep(d).await;
22701                        continue;
22702                    }
22703                    dlg.finished(false);
22704                    return Err(common::Error::HttpError(err));
22705                }
22706                Ok(res) => {
22707                    let (mut parts, body) = res.into_parts();
22708                    let mut body = common::Body::new(body);
22709                    if !parts.status.is_success() {
22710                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22711                        let error = serde_json::from_str(&common::to_string(&bytes));
22712                        let response = common::to_response(parts, bytes.into());
22713
22714                        if let common::Retry::After(d) =
22715                            dlg.http_failure(&response, error.as_ref().ok())
22716                        {
22717                            sleep(d).await;
22718                            continue;
22719                        }
22720
22721                        dlg.finished(false);
22722
22723                        return Err(match error {
22724                            Ok(value) => common::Error::BadRequest(value),
22725                            _ => common::Error::Failure(response),
22726                        });
22727                    }
22728                    let response = {
22729                        let bytes = common::to_bytes(body).await.unwrap_or_default();
22730                        let encoded = common::to_string(&bytes);
22731                        match serde_json::from_str(&encoded) {
22732                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22733                            Err(error) => {
22734                                dlg.response_json_decode_error(&encoded, &error);
22735                                return Err(common::Error::JsonDecodeError(
22736                                    encoded.to_string(),
22737                                    error,
22738                                ));
22739                            }
22740                        }
22741                    };
22742
22743                    dlg.finished(true);
22744                    return Ok(response);
22745                }
22746            }
22747        }
22748    }
22749
22750    /// User's email address. The special value "me" can be used to indicate the authenticated user.
22751    ///
22752    /// Sets the *user id* path property to the given value.
22753    ///
22754    /// Even though the property as already been set when instantiating this call,
22755    /// we provide this method for API completeness.
22756    pub fn user_id(mut self, new_value: &str) -> UserSettingSendAListCall<'a, C> {
22757        self._user_id = new_value.to_string();
22758        self
22759    }
22760    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22761    /// while executing the actual API request.
22762    ///
22763    /// ````text
22764    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
22765    /// ````
22766    ///
22767    /// Sets the *delegate* property to the given value.
22768    pub fn delegate(
22769        mut self,
22770        new_value: &'a mut dyn common::Delegate,
22771    ) -> UserSettingSendAListCall<'a, C> {
22772        self._delegate = Some(new_value);
22773        self
22774    }
22775
22776    /// Set any additional parameter of the query string used in the request.
22777    /// It should be used to set parameters which are not yet available through their own
22778    /// setters.
22779    ///
22780    /// Please note that this method must not be used to set any of the known parameters
22781    /// which have their own setter method. If done anyway, the request will fail.
22782    ///
22783    /// # Additional Parameters
22784    ///
22785    /// * *$.xgafv* (query-string) - V1 error format.
22786    /// * *access_token* (query-string) - OAuth access token.
22787    /// * *alt* (query-string) - Data format for response.
22788    /// * *callback* (query-string) - JSONP
22789    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22790    /// * *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.
22791    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22792    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22793    /// * *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.
22794    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22795    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22796    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendAListCall<'a, C>
22797    where
22798        T: AsRef<str>,
22799    {
22800        self._additional_params
22801            .insert(name.as_ref().to_string(), value.as_ref().to_string());
22802        self
22803    }
22804
22805    /// Identifies the authorization scope for the method you are building.
22806    ///
22807    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22808    /// [`Scope::Readonly`].
22809    ///
22810    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22811    /// tokens for more than one scope.
22812    ///
22813    /// Usually there is more than one suitable scope to authorize an operation, some of which may
22814    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22815    /// sufficient, a read-write scope will do as well.
22816    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendAListCall<'a, C>
22817    where
22818        St: AsRef<str>,
22819    {
22820        self._scopes.insert(String::from(scope.as_ref()));
22821        self
22822    }
22823    /// Identifies the authorization scope(s) for the method you are building.
22824    ///
22825    /// See [`Self::add_scope()`] for details.
22826    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendAListCall<'a, C>
22827    where
22828        I: IntoIterator<Item = St>,
22829        St: AsRef<str>,
22830    {
22831        self._scopes
22832            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22833        self
22834    }
22835
22836    /// Removes all scopes, and no default scope will be used either.
22837    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22838    /// for details).
22839    pub fn clear_scopes(mut self) -> UserSettingSendAListCall<'a, C> {
22840        self._scopes.clear();
22841        self
22842    }
22843}
22844
22845/// Patch the specified send-as alias.
22846///
22847/// A builder for the *settings.sendAs.patch* method supported by a *user* resource.
22848/// It is not used directly, but through a [`UserMethods`] instance.
22849///
22850/// # Example
22851///
22852/// Instantiate a resource method builder
22853///
22854/// ```test_harness,no_run
22855/// # extern crate hyper;
22856/// # extern crate hyper_rustls;
22857/// # extern crate google_gmail1 as gmail1;
22858/// use gmail1::api::SendAs;
22859/// # async fn dox() {
22860/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22861///
22862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22863/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22864/// #     .with_native_roots()
22865/// #     .unwrap()
22866/// #     .https_only()
22867/// #     .enable_http2()
22868/// #     .build();
22869///
22870/// # let executor = hyper_util::rt::TokioExecutor::new();
22871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22872/// #     secret,
22873/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22874/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
22875/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
22876/// #     ),
22877/// # ).build().await.unwrap();
22878///
22879/// # let client = hyper_util::client::legacy::Client::builder(
22880/// #     hyper_util::rt::TokioExecutor::new()
22881/// # )
22882/// # .build(
22883/// #     hyper_rustls::HttpsConnectorBuilder::new()
22884/// #         .with_native_roots()
22885/// #         .unwrap()
22886/// #         .https_or_http()
22887/// #         .enable_http2()
22888/// #         .build()
22889/// # );
22890/// # let mut hub = Gmail::new(client, auth);
22891/// // As the method needs a request, you would usually fill it with the desired information
22892/// // into the respective structure. Some of the parts shown here might not be applicable !
22893/// // Values shown here are possibly random and not representative !
22894/// let mut req = SendAs::default();
22895///
22896/// // You can configure optional parameters by calling the respective setters at will, and
22897/// // execute the final call using `doit()`.
22898/// // Values shown here are possibly random and not representative !
22899/// let result = hub.users().settings_send_as_patch(req, "userId", "sendAsEmail")
22900///              .doit().await;
22901/// # }
22902/// ```
22903pub struct UserSettingSendAPatchCall<'a, C>
22904where
22905    C: 'a,
22906{
22907    hub: &'a Gmail<C>,
22908    _request: SendAs,
22909    _user_id: String,
22910    _send_as_email: String,
22911    _delegate: Option<&'a mut dyn common::Delegate>,
22912    _additional_params: HashMap<String, String>,
22913    _scopes: BTreeSet<String>,
22914}
22915
22916impl<'a, C> common::CallBuilder for UserSettingSendAPatchCall<'a, C> {}
22917
22918impl<'a, C> UserSettingSendAPatchCall<'a, C>
22919where
22920    C: common::Connector,
22921{
22922    /// Perform the operation you have build so far.
22923    pub async fn doit(mut self) -> common::Result<(common::Response, SendAs)> {
22924        use std::borrow::Cow;
22925        use std::io::{Read, Seek};
22926
22927        use common::{url::Params, ToParts};
22928        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22929
22930        let mut dd = common::DefaultDelegate;
22931        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22932        dlg.begin(common::MethodInfo {
22933            id: "gmail.users.settings.sendAs.patch",
22934            http_method: hyper::Method::PATCH,
22935        });
22936
22937        for &field in ["alt", "userId", "sendAsEmail"].iter() {
22938            if self._additional_params.contains_key(field) {
22939                dlg.finished(false);
22940                return Err(common::Error::FieldClash(field));
22941            }
22942        }
22943
22944        let mut params = Params::with_capacity(5 + self._additional_params.len());
22945        params.push("userId", self._user_id);
22946        params.push("sendAsEmail", self._send_as_email);
22947
22948        params.extend(self._additional_params.iter());
22949
22950        params.push("alt", "json");
22951        let mut url =
22952            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}";
22953        if self._scopes.is_empty() {
22954            self._scopes
22955                .insert(Scope::SettingBasic.as_ref().to_string());
22956        }
22957
22958        #[allow(clippy::single_element_loop)]
22959        for &(find_this, param_name) in
22960            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
22961        {
22962            url = params.uri_replacement(url, param_name, find_this, false);
22963        }
22964        {
22965            let to_remove = ["sendAsEmail", "userId"];
22966            params.remove_params(&to_remove);
22967        }
22968
22969        let url = params.parse_with_url(&url);
22970
22971        let mut json_mime_type = mime::APPLICATION_JSON;
22972        let mut request_value_reader = {
22973            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22974            common::remove_json_null_values(&mut value);
22975            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22976            serde_json::to_writer(&mut dst, &value).unwrap();
22977            dst
22978        };
22979        let request_size = request_value_reader
22980            .seek(std::io::SeekFrom::End(0))
22981            .unwrap();
22982        request_value_reader
22983            .seek(std::io::SeekFrom::Start(0))
22984            .unwrap();
22985
22986        loop {
22987            let token = match self
22988                .hub
22989                .auth
22990                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22991                .await
22992            {
22993                Ok(token) => token,
22994                Err(e) => match dlg.token(e) {
22995                    Ok(token) => token,
22996                    Err(e) => {
22997                        dlg.finished(false);
22998                        return Err(common::Error::MissingToken(e));
22999                    }
23000                },
23001            };
23002            request_value_reader
23003                .seek(std::io::SeekFrom::Start(0))
23004                .unwrap();
23005            let mut req_result = {
23006                let client = &self.hub.client;
23007                dlg.pre_request();
23008                let mut req_builder = hyper::Request::builder()
23009                    .method(hyper::Method::PATCH)
23010                    .uri(url.as_str())
23011                    .header(USER_AGENT, self.hub._user_agent.clone());
23012
23013                if let Some(token) = token.as_ref() {
23014                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23015                }
23016
23017                let request = req_builder
23018                    .header(CONTENT_TYPE, json_mime_type.to_string())
23019                    .header(CONTENT_LENGTH, request_size as u64)
23020                    .body(common::to_body(
23021                        request_value_reader.get_ref().clone().into(),
23022                    ));
23023
23024                client.request(request.unwrap()).await
23025            };
23026
23027            match req_result {
23028                Err(err) => {
23029                    if let common::Retry::After(d) = dlg.http_error(&err) {
23030                        sleep(d).await;
23031                        continue;
23032                    }
23033                    dlg.finished(false);
23034                    return Err(common::Error::HttpError(err));
23035                }
23036                Ok(res) => {
23037                    let (mut parts, body) = res.into_parts();
23038                    let mut body = common::Body::new(body);
23039                    if !parts.status.is_success() {
23040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23041                        let error = serde_json::from_str(&common::to_string(&bytes));
23042                        let response = common::to_response(parts, bytes.into());
23043
23044                        if let common::Retry::After(d) =
23045                            dlg.http_failure(&response, error.as_ref().ok())
23046                        {
23047                            sleep(d).await;
23048                            continue;
23049                        }
23050
23051                        dlg.finished(false);
23052
23053                        return Err(match error {
23054                            Ok(value) => common::Error::BadRequest(value),
23055                            _ => common::Error::Failure(response),
23056                        });
23057                    }
23058                    let response = {
23059                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23060                        let encoded = common::to_string(&bytes);
23061                        match serde_json::from_str(&encoded) {
23062                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23063                            Err(error) => {
23064                                dlg.response_json_decode_error(&encoded, &error);
23065                                return Err(common::Error::JsonDecodeError(
23066                                    encoded.to_string(),
23067                                    error,
23068                                ));
23069                            }
23070                        }
23071                    };
23072
23073                    dlg.finished(true);
23074                    return Ok(response);
23075                }
23076            }
23077        }
23078    }
23079
23080    ///
23081    /// Sets the *request* property to the given value.
23082    ///
23083    /// Even though the property as already been set when instantiating this call,
23084    /// we provide this method for API completeness.
23085    pub fn request(mut self, new_value: SendAs) -> UserSettingSendAPatchCall<'a, C> {
23086        self._request = new_value;
23087        self
23088    }
23089    /// User's email address. The special value "me" can be used to indicate the authenticated user.
23090    ///
23091    /// Sets the *user id* path property to the given value.
23092    ///
23093    /// Even though the property as already been set when instantiating this call,
23094    /// we provide this method for API completeness.
23095    pub fn user_id(mut self, new_value: &str) -> UserSettingSendAPatchCall<'a, C> {
23096        self._user_id = new_value.to_string();
23097        self
23098    }
23099    /// The send-as alias to be updated.
23100    ///
23101    /// Sets the *send as email* path property to the given value.
23102    ///
23103    /// Even though the property as already been set when instantiating this call,
23104    /// we provide this method for API completeness.
23105    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAPatchCall<'a, C> {
23106        self._send_as_email = new_value.to_string();
23107        self
23108    }
23109    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23110    /// while executing the actual API request.
23111    ///
23112    /// ````text
23113    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23114    /// ````
23115    ///
23116    /// Sets the *delegate* property to the given value.
23117    pub fn delegate(
23118        mut self,
23119        new_value: &'a mut dyn common::Delegate,
23120    ) -> UserSettingSendAPatchCall<'a, C> {
23121        self._delegate = Some(new_value);
23122        self
23123    }
23124
23125    /// Set any additional parameter of the query string used in the request.
23126    /// It should be used to set parameters which are not yet available through their own
23127    /// setters.
23128    ///
23129    /// Please note that this method must not be used to set any of the known parameters
23130    /// which have their own setter method. If done anyway, the request will fail.
23131    ///
23132    /// # Additional Parameters
23133    ///
23134    /// * *$.xgafv* (query-string) - V1 error format.
23135    /// * *access_token* (query-string) - OAuth access token.
23136    /// * *alt* (query-string) - Data format for response.
23137    /// * *callback* (query-string) - JSONP
23138    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23139    /// * *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.
23140    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23141    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23142    /// * *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.
23143    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23144    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23145    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendAPatchCall<'a, C>
23146    where
23147        T: AsRef<str>,
23148    {
23149        self._additional_params
23150            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23151        self
23152    }
23153
23154    /// Identifies the authorization scope for the method you are building.
23155    ///
23156    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23157    /// [`Scope::SettingBasic`].
23158    ///
23159    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23160    /// tokens for more than one scope.
23161    ///
23162    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23163    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23164    /// sufficient, a read-write scope will do as well.
23165    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendAPatchCall<'a, C>
23166    where
23167        St: AsRef<str>,
23168    {
23169        self._scopes.insert(String::from(scope.as_ref()));
23170        self
23171    }
23172    /// Identifies the authorization scope(s) for the method you are building.
23173    ///
23174    /// See [`Self::add_scope()`] for details.
23175    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendAPatchCall<'a, C>
23176    where
23177        I: IntoIterator<Item = St>,
23178        St: AsRef<str>,
23179    {
23180        self._scopes
23181            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23182        self
23183    }
23184
23185    /// Removes all scopes, and no default scope will be used either.
23186    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23187    /// for details).
23188    pub fn clear_scopes(mut self) -> UserSettingSendAPatchCall<'a, C> {
23189        self._scopes.clear();
23190        self
23191    }
23192}
23193
23194/// Updates a send-as alias. If a signature is provided, Gmail will sanitize the HTML before saving it with the alias. Addresses other than the primary address for the account can only be updated by service account clients that have been delegated domain-wide authority.
23195///
23196/// A builder for the *settings.sendAs.update* method supported by a *user* resource.
23197/// It is not used directly, but through a [`UserMethods`] instance.
23198///
23199/// # Example
23200///
23201/// Instantiate a resource method builder
23202///
23203/// ```test_harness,no_run
23204/// # extern crate hyper;
23205/// # extern crate hyper_rustls;
23206/// # extern crate google_gmail1 as gmail1;
23207/// use gmail1::api::SendAs;
23208/// # async fn dox() {
23209/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23210///
23211/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23212/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23213/// #     .with_native_roots()
23214/// #     .unwrap()
23215/// #     .https_only()
23216/// #     .enable_http2()
23217/// #     .build();
23218///
23219/// # let executor = hyper_util::rt::TokioExecutor::new();
23220/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23221/// #     secret,
23222/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23223/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23224/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23225/// #     ),
23226/// # ).build().await.unwrap();
23227///
23228/// # let client = hyper_util::client::legacy::Client::builder(
23229/// #     hyper_util::rt::TokioExecutor::new()
23230/// # )
23231/// # .build(
23232/// #     hyper_rustls::HttpsConnectorBuilder::new()
23233/// #         .with_native_roots()
23234/// #         .unwrap()
23235/// #         .https_or_http()
23236/// #         .enable_http2()
23237/// #         .build()
23238/// # );
23239/// # let mut hub = Gmail::new(client, auth);
23240/// // As the method needs a request, you would usually fill it with the desired information
23241/// // into the respective structure. Some of the parts shown here might not be applicable !
23242/// // Values shown here are possibly random and not representative !
23243/// let mut req = SendAs::default();
23244///
23245/// // You can configure optional parameters by calling the respective setters at will, and
23246/// // execute the final call using `doit()`.
23247/// // Values shown here are possibly random and not representative !
23248/// let result = hub.users().settings_send_as_update(req, "userId", "sendAsEmail")
23249///              .doit().await;
23250/// # }
23251/// ```
23252pub struct UserSettingSendAUpdateCall<'a, C>
23253where
23254    C: 'a,
23255{
23256    hub: &'a Gmail<C>,
23257    _request: SendAs,
23258    _user_id: String,
23259    _send_as_email: String,
23260    _delegate: Option<&'a mut dyn common::Delegate>,
23261    _additional_params: HashMap<String, String>,
23262    _scopes: BTreeSet<String>,
23263}
23264
23265impl<'a, C> common::CallBuilder for UserSettingSendAUpdateCall<'a, C> {}
23266
23267impl<'a, C> UserSettingSendAUpdateCall<'a, C>
23268where
23269    C: common::Connector,
23270{
23271    /// Perform the operation you have build so far.
23272    pub async fn doit(mut self) -> common::Result<(common::Response, SendAs)> {
23273        use std::borrow::Cow;
23274        use std::io::{Read, Seek};
23275
23276        use common::{url::Params, ToParts};
23277        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23278
23279        let mut dd = common::DefaultDelegate;
23280        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23281        dlg.begin(common::MethodInfo {
23282            id: "gmail.users.settings.sendAs.update",
23283            http_method: hyper::Method::PUT,
23284        });
23285
23286        for &field in ["alt", "userId", "sendAsEmail"].iter() {
23287            if self._additional_params.contains_key(field) {
23288                dlg.finished(false);
23289                return Err(common::Error::FieldClash(field));
23290            }
23291        }
23292
23293        let mut params = Params::with_capacity(5 + self._additional_params.len());
23294        params.push("userId", self._user_id);
23295        params.push("sendAsEmail", self._send_as_email);
23296
23297        params.extend(self._additional_params.iter());
23298
23299        params.push("alt", "json");
23300        let mut url =
23301            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}";
23302        if self._scopes.is_empty() {
23303            self._scopes
23304                .insert(Scope::SettingBasic.as_ref().to_string());
23305        }
23306
23307        #[allow(clippy::single_element_loop)]
23308        for &(find_this, param_name) in
23309            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
23310        {
23311            url = params.uri_replacement(url, param_name, find_this, false);
23312        }
23313        {
23314            let to_remove = ["sendAsEmail", "userId"];
23315            params.remove_params(&to_remove);
23316        }
23317
23318        let url = params.parse_with_url(&url);
23319
23320        let mut json_mime_type = mime::APPLICATION_JSON;
23321        let mut request_value_reader = {
23322            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23323            common::remove_json_null_values(&mut value);
23324            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23325            serde_json::to_writer(&mut dst, &value).unwrap();
23326            dst
23327        };
23328        let request_size = request_value_reader
23329            .seek(std::io::SeekFrom::End(0))
23330            .unwrap();
23331        request_value_reader
23332            .seek(std::io::SeekFrom::Start(0))
23333            .unwrap();
23334
23335        loop {
23336            let token = match self
23337                .hub
23338                .auth
23339                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23340                .await
23341            {
23342                Ok(token) => token,
23343                Err(e) => match dlg.token(e) {
23344                    Ok(token) => token,
23345                    Err(e) => {
23346                        dlg.finished(false);
23347                        return Err(common::Error::MissingToken(e));
23348                    }
23349                },
23350            };
23351            request_value_reader
23352                .seek(std::io::SeekFrom::Start(0))
23353                .unwrap();
23354            let mut req_result = {
23355                let client = &self.hub.client;
23356                dlg.pre_request();
23357                let mut req_builder = hyper::Request::builder()
23358                    .method(hyper::Method::PUT)
23359                    .uri(url.as_str())
23360                    .header(USER_AGENT, self.hub._user_agent.clone());
23361
23362                if let Some(token) = token.as_ref() {
23363                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23364                }
23365
23366                let request = req_builder
23367                    .header(CONTENT_TYPE, json_mime_type.to_string())
23368                    .header(CONTENT_LENGTH, request_size as u64)
23369                    .body(common::to_body(
23370                        request_value_reader.get_ref().clone().into(),
23371                    ));
23372
23373                client.request(request.unwrap()).await
23374            };
23375
23376            match req_result {
23377                Err(err) => {
23378                    if let common::Retry::After(d) = dlg.http_error(&err) {
23379                        sleep(d).await;
23380                        continue;
23381                    }
23382                    dlg.finished(false);
23383                    return Err(common::Error::HttpError(err));
23384                }
23385                Ok(res) => {
23386                    let (mut parts, body) = res.into_parts();
23387                    let mut body = common::Body::new(body);
23388                    if !parts.status.is_success() {
23389                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23390                        let error = serde_json::from_str(&common::to_string(&bytes));
23391                        let response = common::to_response(parts, bytes.into());
23392
23393                        if let common::Retry::After(d) =
23394                            dlg.http_failure(&response, error.as_ref().ok())
23395                        {
23396                            sleep(d).await;
23397                            continue;
23398                        }
23399
23400                        dlg.finished(false);
23401
23402                        return Err(match error {
23403                            Ok(value) => common::Error::BadRequest(value),
23404                            _ => common::Error::Failure(response),
23405                        });
23406                    }
23407                    let response = {
23408                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23409                        let encoded = common::to_string(&bytes);
23410                        match serde_json::from_str(&encoded) {
23411                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23412                            Err(error) => {
23413                                dlg.response_json_decode_error(&encoded, &error);
23414                                return Err(common::Error::JsonDecodeError(
23415                                    encoded.to_string(),
23416                                    error,
23417                                ));
23418                            }
23419                        }
23420                    };
23421
23422                    dlg.finished(true);
23423                    return Ok(response);
23424                }
23425            }
23426        }
23427    }
23428
23429    ///
23430    /// Sets the *request* property to the given value.
23431    ///
23432    /// Even though the property as already been set when instantiating this call,
23433    /// we provide this method for API completeness.
23434    pub fn request(mut self, new_value: SendAs) -> UserSettingSendAUpdateCall<'a, C> {
23435        self._request = new_value;
23436        self
23437    }
23438    /// User's email address. The special value "me" can be used to indicate the authenticated user.
23439    ///
23440    /// Sets the *user id* path property to the given value.
23441    ///
23442    /// Even though the property as already been set when instantiating this call,
23443    /// we provide this method for API completeness.
23444    pub fn user_id(mut self, new_value: &str) -> UserSettingSendAUpdateCall<'a, C> {
23445        self._user_id = new_value.to_string();
23446        self
23447    }
23448    /// The send-as alias to be updated.
23449    ///
23450    /// Sets the *send as email* path property to the given value.
23451    ///
23452    /// Even though the property as already been set when instantiating this call,
23453    /// we provide this method for API completeness.
23454    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAUpdateCall<'a, C> {
23455        self._send_as_email = new_value.to_string();
23456        self
23457    }
23458    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23459    /// while executing the actual API request.
23460    ///
23461    /// ````text
23462    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23463    /// ````
23464    ///
23465    /// Sets the *delegate* property to the given value.
23466    pub fn delegate(
23467        mut self,
23468        new_value: &'a mut dyn common::Delegate,
23469    ) -> UserSettingSendAUpdateCall<'a, C> {
23470        self._delegate = Some(new_value);
23471        self
23472    }
23473
23474    /// Set any additional parameter of the query string used in the request.
23475    /// It should be used to set parameters which are not yet available through their own
23476    /// setters.
23477    ///
23478    /// Please note that this method must not be used to set any of the known parameters
23479    /// which have their own setter method. If done anyway, the request will fail.
23480    ///
23481    /// # Additional Parameters
23482    ///
23483    /// * *$.xgafv* (query-string) - V1 error format.
23484    /// * *access_token* (query-string) - OAuth access token.
23485    /// * *alt* (query-string) - Data format for response.
23486    /// * *callback* (query-string) - JSONP
23487    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23488    /// * *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.
23489    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23490    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23491    /// * *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.
23492    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23493    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23494    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendAUpdateCall<'a, C>
23495    where
23496        T: AsRef<str>,
23497    {
23498        self._additional_params
23499            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23500        self
23501    }
23502
23503    /// Identifies the authorization scope for the method you are building.
23504    ///
23505    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23506    /// [`Scope::SettingBasic`].
23507    ///
23508    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23509    /// tokens for more than one scope.
23510    ///
23511    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23512    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23513    /// sufficient, a read-write scope will do as well.
23514    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendAUpdateCall<'a, C>
23515    where
23516        St: AsRef<str>,
23517    {
23518        self._scopes.insert(String::from(scope.as_ref()));
23519        self
23520    }
23521    /// Identifies the authorization scope(s) for the method you are building.
23522    ///
23523    /// See [`Self::add_scope()`] for details.
23524    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendAUpdateCall<'a, C>
23525    where
23526        I: IntoIterator<Item = St>,
23527        St: AsRef<str>,
23528    {
23529        self._scopes
23530            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23531        self
23532    }
23533
23534    /// Removes all scopes, and no default scope will be used either.
23535    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23536    /// for details).
23537    pub fn clear_scopes(mut self) -> UserSettingSendAUpdateCall<'a, C> {
23538        self._scopes.clear();
23539        self
23540    }
23541}
23542
23543/// Sends a verification email to the specified send-as alias address. The verification status must be `pending`. This method is only available to service account clients that have been delegated domain-wide authority.
23544///
23545/// A builder for the *settings.sendAs.verify* method supported by a *user* resource.
23546/// It is not used directly, but through a [`UserMethods`] instance.
23547///
23548/// # Example
23549///
23550/// Instantiate a resource method builder
23551///
23552/// ```test_harness,no_run
23553/// # extern crate hyper;
23554/// # extern crate hyper_rustls;
23555/// # extern crate google_gmail1 as gmail1;
23556/// # async fn dox() {
23557/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23558///
23559/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23560/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23561/// #     .with_native_roots()
23562/// #     .unwrap()
23563/// #     .https_only()
23564/// #     .enable_http2()
23565/// #     .build();
23566///
23567/// # let executor = hyper_util::rt::TokioExecutor::new();
23568/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23569/// #     secret,
23570/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23571/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23572/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23573/// #     ),
23574/// # ).build().await.unwrap();
23575///
23576/// # let client = hyper_util::client::legacy::Client::builder(
23577/// #     hyper_util::rt::TokioExecutor::new()
23578/// # )
23579/// # .build(
23580/// #     hyper_rustls::HttpsConnectorBuilder::new()
23581/// #         .with_native_roots()
23582/// #         .unwrap()
23583/// #         .https_or_http()
23584/// #         .enable_http2()
23585/// #         .build()
23586/// # );
23587/// # let mut hub = Gmail::new(client, auth);
23588/// // You can configure optional parameters by calling the respective setters at will, and
23589/// // execute the final call using `doit()`.
23590/// // Values shown here are possibly random and not representative !
23591/// let result = hub.users().settings_send_as_verify("userId", "sendAsEmail")
23592///              .doit().await;
23593/// # }
23594/// ```
23595pub struct UserSettingSendAVerifyCall<'a, C>
23596where
23597    C: 'a,
23598{
23599    hub: &'a Gmail<C>,
23600    _user_id: String,
23601    _send_as_email: String,
23602    _delegate: Option<&'a mut dyn common::Delegate>,
23603    _additional_params: HashMap<String, String>,
23604    _scopes: BTreeSet<String>,
23605}
23606
23607impl<'a, C> common::CallBuilder for UserSettingSendAVerifyCall<'a, C> {}
23608
23609impl<'a, C> UserSettingSendAVerifyCall<'a, C>
23610where
23611    C: common::Connector,
23612{
23613    /// Perform the operation you have build so far.
23614    pub async fn doit(mut self) -> common::Result<common::Response> {
23615        use std::borrow::Cow;
23616        use std::io::{Read, Seek};
23617
23618        use common::{url::Params, ToParts};
23619        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23620
23621        let mut dd = common::DefaultDelegate;
23622        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23623        dlg.begin(common::MethodInfo {
23624            id: "gmail.users.settings.sendAs.verify",
23625            http_method: hyper::Method::POST,
23626        });
23627
23628        for &field in ["userId", "sendAsEmail"].iter() {
23629            if self._additional_params.contains_key(field) {
23630                dlg.finished(false);
23631                return Err(common::Error::FieldClash(field));
23632            }
23633        }
23634
23635        let mut params = Params::with_capacity(3 + self._additional_params.len());
23636        params.push("userId", self._user_id);
23637        params.push("sendAsEmail", self._send_as_email);
23638
23639        params.extend(self._additional_params.iter());
23640
23641        let mut url = self.hub._base_url.clone()
23642            + "gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify";
23643        if self._scopes.is_empty() {
23644            self._scopes
23645                .insert(Scope::SettingSharing.as_ref().to_string());
23646        }
23647
23648        #[allow(clippy::single_element_loop)]
23649        for &(find_this, param_name) in
23650            [("{userId}", "userId"), ("{sendAsEmail}", "sendAsEmail")].iter()
23651        {
23652            url = params.uri_replacement(url, param_name, find_this, false);
23653        }
23654        {
23655            let to_remove = ["sendAsEmail", "userId"];
23656            params.remove_params(&to_remove);
23657        }
23658
23659        let url = params.parse_with_url(&url);
23660
23661        loop {
23662            let token = match self
23663                .hub
23664                .auth
23665                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23666                .await
23667            {
23668                Ok(token) => token,
23669                Err(e) => match dlg.token(e) {
23670                    Ok(token) => token,
23671                    Err(e) => {
23672                        dlg.finished(false);
23673                        return Err(common::Error::MissingToken(e));
23674                    }
23675                },
23676            };
23677            let mut req_result = {
23678                let client = &self.hub.client;
23679                dlg.pre_request();
23680                let mut req_builder = hyper::Request::builder()
23681                    .method(hyper::Method::POST)
23682                    .uri(url.as_str())
23683                    .header(USER_AGENT, self.hub._user_agent.clone());
23684
23685                if let Some(token) = token.as_ref() {
23686                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23687                }
23688
23689                let request = req_builder
23690                    .header(CONTENT_LENGTH, 0_u64)
23691                    .body(common::to_body::<String>(None));
23692
23693                client.request(request.unwrap()).await
23694            };
23695
23696            match req_result {
23697                Err(err) => {
23698                    if let common::Retry::After(d) = dlg.http_error(&err) {
23699                        sleep(d).await;
23700                        continue;
23701                    }
23702                    dlg.finished(false);
23703                    return Err(common::Error::HttpError(err));
23704                }
23705                Ok(res) => {
23706                    let (mut parts, body) = res.into_parts();
23707                    let mut body = common::Body::new(body);
23708                    if !parts.status.is_success() {
23709                        let bytes = common::to_bytes(body).await.unwrap_or_default();
23710                        let error = serde_json::from_str(&common::to_string(&bytes));
23711                        let response = common::to_response(parts, bytes.into());
23712
23713                        if let common::Retry::After(d) =
23714                            dlg.http_failure(&response, error.as_ref().ok())
23715                        {
23716                            sleep(d).await;
23717                            continue;
23718                        }
23719
23720                        dlg.finished(false);
23721
23722                        return Err(match error {
23723                            Ok(value) => common::Error::BadRequest(value),
23724                            _ => common::Error::Failure(response),
23725                        });
23726                    }
23727                    let response = common::Response::from_parts(parts, body);
23728
23729                    dlg.finished(true);
23730                    return Ok(response);
23731                }
23732            }
23733        }
23734    }
23735
23736    /// User's email address. The special value "me" can be used to indicate the authenticated user.
23737    ///
23738    /// Sets the *user id* path property to the given value.
23739    ///
23740    /// Even though the property as already been set when instantiating this call,
23741    /// we provide this method for API completeness.
23742    pub fn user_id(mut self, new_value: &str) -> UserSettingSendAVerifyCall<'a, C> {
23743        self._user_id = new_value.to_string();
23744        self
23745    }
23746    /// The send-as alias to be verified.
23747    ///
23748    /// Sets the *send as email* path property to the given value.
23749    ///
23750    /// Even though the property as already been set when instantiating this call,
23751    /// we provide this method for API completeness.
23752    pub fn send_as_email(mut self, new_value: &str) -> UserSettingSendAVerifyCall<'a, C> {
23753        self._send_as_email = new_value.to_string();
23754        self
23755    }
23756    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23757    /// while executing the actual API request.
23758    ///
23759    /// ````text
23760    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
23761    /// ````
23762    ///
23763    /// Sets the *delegate* property to the given value.
23764    pub fn delegate(
23765        mut self,
23766        new_value: &'a mut dyn common::Delegate,
23767    ) -> UserSettingSendAVerifyCall<'a, C> {
23768        self._delegate = Some(new_value);
23769        self
23770    }
23771
23772    /// Set any additional parameter of the query string used in the request.
23773    /// It should be used to set parameters which are not yet available through their own
23774    /// setters.
23775    ///
23776    /// Please note that this method must not be used to set any of the known parameters
23777    /// which have their own setter method. If done anyway, the request will fail.
23778    ///
23779    /// # Additional Parameters
23780    ///
23781    /// * *$.xgafv* (query-string) - V1 error format.
23782    /// * *access_token* (query-string) - OAuth access token.
23783    /// * *alt* (query-string) - Data format for response.
23784    /// * *callback* (query-string) - JSONP
23785    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23786    /// * *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.
23787    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23788    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23789    /// * *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.
23790    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23791    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23792    pub fn param<T>(mut self, name: T, value: T) -> UserSettingSendAVerifyCall<'a, C>
23793    where
23794        T: AsRef<str>,
23795    {
23796        self._additional_params
23797            .insert(name.as_ref().to_string(), value.as_ref().to_string());
23798        self
23799    }
23800
23801    /// Identifies the authorization scope for the method you are building.
23802    ///
23803    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23804    /// [`Scope::SettingSharing`].
23805    ///
23806    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23807    /// tokens for more than one scope.
23808    ///
23809    /// Usually there is more than one suitable scope to authorize an operation, some of which may
23810    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23811    /// sufficient, a read-write scope will do as well.
23812    pub fn add_scope<St>(mut self, scope: St) -> UserSettingSendAVerifyCall<'a, C>
23813    where
23814        St: AsRef<str>,
23815    {
23816        self._scopes.insert(String::from(scope.as_ref()));
23817        self
23818    }
23819    /// Identifies the authorization scope(s) for the method you are building.
23820    ///
23821    /// See [`Self::add_scope()`] for details.
23822    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingSendAVerifyCall<'a, C>
23823    where
23824        I: IntoIterator<Item = St>,
23825        St: AsRef<str>,
23826    {
23827        self._scopes
23828            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23829        self
23830    }
23831
23832    /// Removes all scopes, and no default scope will be used either.
23833    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23834    /// for details).
23835    pub fn clear_scopes(mut self) -> UserSettingSendAVerifyCall<'a, C> {
23836        self._scopes.clear();
23837        self
23838    }
23839}
23840
23841/// Gets the auto-forwarding setting for the specified account.
23842///
23843/// A builder for the *settings.getAutoForwarding* method supported by a *user* resource.
23844/// It is not used directly, but through a [`UserMethods`] instance.
23845///
23846/// # Example
23847///
23848/// Instantiate a resource method builder
23849///
23850/// ```test_harness,no_run
23851/// # extern crate hyper;
23852/// # extern crate hyper_rustls;
23853/// # extern crate google_gmail1 as gmail1;
23854/// # async fn dox() {
23855/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23856///
23857/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23858/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23859/// #     .with_native_roots()
23860/// #     .unwrap()
23861/// #     .https_only()
23862/// #     .enable_http2()
23863/// #     .build();
23864///
23865/// # let executor = hyper_util::rt::TokioExecutor::new();
23866/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23867/// #     secret,
23868/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23869/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
23870/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
23871/// #     ),
23872/// # ).build().await.unwrap();
23873///
23874/// # let client = hyper_util::client::legacy::Client::builder(
23875/// #     hyper_util::rt::TokioExecutor::new()
23876/// # )
23877/// # .build(
23878/// #     hyper_rustls::HttpsConnectorBuilder::new()
23879/// #         .with_native_roots()
23880/// #         .unwrap()
23881/// #         .https_or_http()
23882/// #         .enable_http2()
23883/// #         .build()
23884/// # );
23885/// # let mut hub = Gmail::new(client, auth);
23886/// // You can configure optional parameters by calling the respective setters at will, and
23887/// // execute the final call using `doit()`.
23888/// // Values shown here are possibly random and not representative !
23889/// let result = hub.users().settings_get_auto_forwarding("userId")
23890///              .doit().await;
23891/// # }
23892/// ```
23893pub struct UserSettingGetAutoForwardingCall<'a, C>
23894where
23895    C: 'a,
23896{
23897    hub: &'a Gmail<C>,
23898    _user_id: String,
23899    _delegate: Option<&'a mut dyn common::Delegate>,
23900    _additional_params: HashMap<String, String>,
23901    _scopes: BTreeSet<String>,
23902}
23903
23904impl<'a, C> common::CallBuilder for UserSettingGetAutoForwardingCall<'a, C> {}
23905
23906impl<'a, C> UserSettingGetAutoForwardingCall<'a, C>
23907where
23908    C: common::Connector,
23909{
23910    /// Perform the operation you have build so far.
23911    pub async fn doit(mut self) -> common::Result<(common::Response, AutoForwarding)> {
23912        use std::borrow::Cow;
23913        use std::io::{Read, Seek};
23914
23915        use common::{url::Params, ToParts};
23916        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23917
23918        let mut dd = common::DefaultDelegate;
23919        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23920        dlg.begin(common::MethodInfo {
23921            id: "gmail.users.settings.getAutoForwarding",
23922            http_method: hyper::Method::GET,
23923        });
23924
23925        for &field in ["alt", "userId"].iter() {
23926            if self._additional_params.contains_key(field) {
23927                dlg.finished(false);
23928                return Err(common::Error::FieldClash(field));
23929            }
23930        }
23931
23932        let mut params = Params::with_capacity(3 + self._additional_params.len());
23933        params.push("userId", self._user_id);
23934
23935        params.extend(self._additional_params.iter());
23936
23937        params.push("alt", "json");
23938        let mut url =
23939            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/autoForwarding";
23940        if self._scopes.is_empty() {
23941            self._scopes.insert(Scope::Readonly.as_ref().to_string());
23942        }
23943
23944        #[allow(clippy::single_element_loop)]
23945        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
23946            url = params.uri_replacement(url, param_name, find_this, false);
23947        }
23948        {
23949            let to_remove = ["userId"];
23950            params.remove_params(&to_remove);
23951        }
23952
23953        let url = params.parse_with_url(&url);
23954
23955        loop {
23956            let token = match self
23957                .hub
23958                .auth
23959                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23960                .await
23961            {
23962                Ok(token) => token,
23963                Err(e) => match dlg.token(e) {
23964                    Ok(token) => token,
23965                    Err(e) => {
23966                        dlg.finished(false);
23967                        return Err(common::Error::MissingToken(e));
23968                    }
23969                },
23970            };
23971            let mut req_result = {
23972                let client = &self.hub.client;
23973                dlg.pre_request();
23974                let mut req_builder = hyper::Request::builder()
23975                    .method(hyper::Method::GET)
23976                    .uri(url.as_str())
23977                    .header(USER_AGENT, self.hub._user_agent.clone());
23978
23979                if let Some(token) = token.as_ref() {
23980                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23981                }
23982
23983                let request = req_builder
23984                    .header(CONTENT_LENGTH, 0_u64)
23985                    .body(common::to_body::<String>(None));
23986
23987                client.request(request.unwrap()).await
23988            };
23989
23990            match req_result {
23991                Err(err) => {
23992                    if let common::Retry::After(d) = dlg.http_error(&err) {
23993                        sleep(d).await;
23994                        continue;
23995                    }
23996                    dlg.finished(false);
23997                    return Err(common::Error::HttpError(err));
23998                }
23999                Ok(res) => {
24000                    let (mut parts, body) = res.into_parts();
24001                    let mut body = common::Body::new(body);
24002                    if !parts.status.is_success() {
24003                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24004                        let error = serde_json::from_str(&common::to_string(&bytes));
24005                        let response = common::to_response(parts, bytes.into());
24006
24007                        if let common::Retry::After(d) =
24008                            dlg.http_failure(&response, error.as_ref().ok())
24009                        {
24010                            sleep(d).await;
24011                            continue;
24012                        }
24013
24014                        dlg.finished(false);
24015
24016                        return Err(match error {
24017                            Ok(value) => common::Error::BadRequest(value),
24018                            _ => common::Error::Failure(response),
24019                        });
24020                    }
24021                    let response = {
24022                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24023                        let encoded = common::to_string(&bytes);
24024                        match serde_json::from_str(&encoded) {
24025                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24026                            Err(error) => {
24027                                dlg.response_json_decode_error(&encoded, &error);
24028                                return Err(common::Error::JsonDecodeError(
24029                                    encoded.to_string(),
24030                                    error,
24031                                ));
24032                            }
24033                        }
24034                    };
24035
24036                    dlg.finished(true);
24037                    return Ok(response);
24038                }
24039            }
24040        }
24041    }
24042
24043    /// User's email address. The special value "me" can be used to indicate the authenticated user.
24044    ///
24045    /// Sets the *user id* path property to the given value.
24046    ///
24047    /// Even though the property as already been set when instantiating this call,
24048    /// we provide this method for API completeness.
24049    pub fn user_id(mut self, new_value: &str) -> UserSettingGetAutoForwardingCall<'a, C> {
24050        self._user_id = new_value.to_string();
24051        self
24052    }
24053    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24054    /// while executing the actual API request.
24055    ///
24056    /// ````text
24057    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24058    /// ````
24059    ///
24060    /// Sets the *delegate* property to the given value.
24061    pub fn delegate(
24062        mut self,
24063        new_value: &'a mut dyn common::Delegate,
24064    ) -> UserSettingGetAutoForwardingCall<'a, C> {
24065        self._delegate = Some(new_value);
24066        self
24067    }
24068
24069    /// Set any additional parameter of the query string used in the request.
24070    /// It should be used to set parameters which are not yet available through their own
24071    /// setters.
24072    ///
24073    /// Please note that this method must not be used to set any of the known parameters
24074    /// which have their own setter method. If done anyway, the request will fail.
24075    ///
24076    /// # Additional Parameters
24077    ///
24078    /// * *$.xgafv* (query-string) - V1 error format.
24079    /// * *access_token* (query-string) - OAuth access token.
24080    /// * *alt* (query-string) - Data format for response.
24081    /// * *callback* (query-string) - JSONP
24082    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24083    /// * *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.
24084    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24085    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24086    /// * *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.
24087    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24088    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24089    pub fn param<T>(mut self, name: T, value: T) -> UserSettingGetAutoForwardingCall<'a, C>
24090    where
24091        T: AsRef<str>,
24092    {
24093        self._additional_params
24094            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24095        self
24096    }
24097
24098    /// Identifies the authorization scope for the method you are building.
24099    ///
24100    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24101    /// [`Scope::Readonly`].
24102    ///
24103    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24104    /// tokens for more than one scope.
24105    ///
24106    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24107    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24108    /// sufficient, a read-write scope will do as well.
24109    pub fn add_scope<St>(mut self, scope: St) -> UserSettingGetAutoForwardingCall<'a, C>
24110    where
24111        St: AsRef<str>,
24112    {
24113        self._scopes.insert(String::from(scope.as_ref()));
24114        self
24115    }
24116    /// Identifies the authorization scope(s) for the method you are building.
24117    ///
24118    /// See [`Self::add_scope()`] for details.
24119    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingGetAutoForwardingCall<'a, C>
24120    where
24121        I: IntoIterator<Item = St>,
24122        St: AsRef<str>,
24123    {
24124        self._scopes
24125            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24126        self
24127    }
24128
24129    /// Removes all scopes, and no default scope will be used either.
24130    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24131    /// for details).
24132    pub fn clear_scopes(mut self) -> UserSettingGetAutoForwardingCall<'a, C> {
24133        self._scopes.clear();
24134        self
24135    }
24136}
24137
24138/// Gets IMAP settings.
24139///
24140/// A builder for the *settings.getImap* method supported by a *user* resource.
24141/// It is not used directly, but through a [`UserMethods`] instance.
24142///
24143/// # Example
24144///
24145/// Instantiate a resource method builder
24146///
24147/// ```test_harness,no_run
24148/// # extern crate hyper;
24149/// # extern crate hyper_rustls;
24150/// # extern crate google_gmail1 as gmail1;
24151/// # async fn dox() {
24152/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24153///
24154/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24155/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24156/// #     .with_native_roots()
24157/// #     .unwrap()
24158/// #     .https_only()
24159/// #     .enable_http2()
24160/// #     .build();
24161///
24162/// # let executor = hyper_util::rt::TokioExecutor::new();
24163/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24164/// #     secret,
24165/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24166/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24167/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24168/// #     ),
24169/// # ).build().await.unwrap();
24170///
24171/// # let client = hyper_util::client::legacy::Client::builder(
24172/// #     hyper_util::rt::TokioExecutor::new()
24173/// # )
24174/// # .build(
24175/// #     hyper_rustls::HttpsConnectorBuilder::new()
24176/// #         .with_native_roots()
24177/// #         .unwrap()
24178/// #         .https_or_http()
24179/// #         .enable_http2()
24180/// #         .build()
24181/// # );
24182/// # let mut hub = Gmail::new(client, auth);
24183/// // You can configure optional parameters by calling the respective setters at will, and
24184/// // execute the final call using `doit()`.
24185/// // Values shown here are possibly random and not representative !
24186/// let result = hub.users().settings_get_imap("userId")
24187///              .doit().await;
24188/// # }
24189/// ```
24190pub struct UserSettingGetImapCall<'a, C>
24191where
24192    C: 'a,
24193{
24194    hub: &'a Gmail<C>,
24195    _user_id: String,
24196    _delegate: Option<&'a mut dyn common::Delegate>,
24197    _additional_params: HashMap<String, String>,
24198    _scopes: BTreeSet<String>,
24199}
24200
24201impl<'a, C> common::CallBuilder for UserSettingGetImapCall<'a, C> {}
24202
24203impl<'a, C> UserSettingGetImapCall<'a, C>
24204where
24205    C: common::Connector,
24206{
24207    /// Perform the operation you have build so far.
24208    pub async fn doit(mut self) -> common::Result<(common::Response, ImapSettings)> {
24209        use std::borrow::Cow;
24210        use std::io::{Read, Seek};
24211
24212        use common::{url::Params, ToParts};
24213        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24214
24215        let mut dd = common::DefaultDelegate;
24216        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24217        dlg.begin(common::MethodInfo {
24218            id: "gmail.users.settings.getImap",
24219            http_method: hyper::Method::GET,
24220        });
24221
24222        for &field in ["alt", "userId"].iter() {
24223            if self._additional_params.contains_key(field) {
24224                dlg.finished(false);
24225                return Err(common::Error::FieldClash(field));
24226            }
24227        }
24228
24229        let mut params = Params::with_capacity(3 + self._additional_params.len());
24230        params.push("userId", self._user_id);
24231
24232        params.extend(self._additional_params.iter());
24233
24234        params.push("alt", "json");
24235        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/imap";
24236        if self._scopes.is_empty() {
24237            self._scopes.insert(Scope::Readonly.as_ref().to_string());
24238        }
24239
24240        #[allow(clippy::single_element_loop)]
24241        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
24242            url = params.uri_replacement(url, param_name, find_this, false);
24243        }
24244        {
24245            let to_remove = ["userId"];
24246            params.remove_params(&to_remove);
24247        }
24248
24249        let url = params.parse_with_url(&url);
24250
24251        loop {
24252            let token = match self
24253                .hub
24254                .auth
24255                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24256                .await
24257            {
24258                Ok(token) => token,
24259                Err(e) => match dlg.token(e) {
24260                    Ok(token) => token,
24261                    Err(e) => {
24262                        dlg.finished(false);
24263                        return Err(common::Error::MissingToken(e));
24264                    }
24265                },
24266            };
24267            let mut req_result = {
24268                let client = &self.hub.client;
24269                dlg.pre_request();
24270                let mut req_builder = hyper::Request::builder()
24271                    .method(hyper::Method::GET)
24272                    .uri(url.as_str())
24273                    .header(USER_AGENT, self.hub._user_agent.clone());
24274
24275                if let Some(token) = token.as_ref() {
24276                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24277                }
24278
24279                let request = req_builder
24280                    .header(CONTENT_LENGTH, 0_u64)
24281                    .body(common::to_body::<String>(None));
24282
24283                client.request(request.unwrap()).await
24284            };
24285
24286            match req_result {
24287                Err(err) => {
24288                    if let common::Retry::After(d) = dlg.http_error(&err) {
24289                        sleep(d).await;
24290                        continue;
24291                    }
24292                    dlg.finished(false);
24293                    return Err(common::Error::HttpError(err));
24294                }
24295                Ok(res) => {
24296                    let (mut parts, body) = res.into_parts();
24297                    let mut body = common::Body::new(body);
24298                    if !parts.status.is_success() {
24299                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24300                        let error = serde_json::from_str(&common::to_string(&bytes));
24301                        let response = common::to_response(parts, bytes.into());
24302
24303                        if let common::Retry::After(d) =
24304                            dlg.http_failure(&response, error.as_ref().ok())
24305                        {
24306                            sleep(d).await;
24307                            continue;
24308                        }
24309
24310                        dlg.finished(false);
24311
24312                        return Err(match error {
24313                            Ok(value) => common::Error::BadRequest(value),
24314                            _ => common::Error::Failure(response),
24315                        });
24316                    }
24317                    let response = {
24318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24319                        let encoded = common::to_string(&bytes);
24320                        match serde_json::from_str(&encoded) {
24321                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24322                            Err(error) => {
24323                                dlg.response_json_decode_error(&encoded, &error);
24324                                return Err(common::Error::JsonDecodeError(
24325                                    encoded.to_string(),
24326                                    error,
24327                                ));
24328                            }
24329                        }
24330                    };
24331
24332                    dlg.finished(true);
24333                    return Ok(response);
24334                }
24335            }
24336        }
24337    }
24338
24339    /// User's email address. The special value "me" can be used to indicate the authenticated user.
24340    ///
24341    /// Sets the *user id* path property to the given value.
24342    ///
24343    /// Even though the property as already been set when instantiating this call,
24344    /// we provide this method for API completeness.
24345    pub fn user_id(mut self, new_value: &str) -> UserSettingGetImapCall<'a, C> {
24346        self._user_id = new_value.to_string();
24347        self
24348    }
24349    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24350    /// while executing the actual API request.
24351    ///
24352    /// ````text
24353    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24354    /// ````
24355    ///
24356    /// Sets the *delegate* property to the given value.
24357    pub fn delegate(
24358        mut self,
24359        new_value: &'a mut dyn common::Delegate,
24360    ) -> UserSettingGetImapCall<'a, C> {
24361        self._delegate = Some(new_value);
24362        self
24363    }
24364
24365    /// Set any additional parameter of the query string used in the request.
24366    /// It should be used to set parameters which are not yet available through their own
24367    /// setters.
24368    ///
24369    /// Please note that this method must not be used to set any of the known parameters
24370    /// which have their own setter method. If done anyway, the request will fail.
24371    ///
24372    /// # Additional Parameters
24373    ///
24374    /// * *$.xgafv* (query-string) - V1 error format.
24375    /// * *access_token* (query-string) - OAuth access token.
24376    /// * *alt* (query-string) - Data format for response.
24377    /// * *callback* (query-string) - JSONP
24378    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24379    /// * *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.
24380    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24381    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24382    /// * *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.
24383    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24384    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24385    pub fn param<T>(mut self, name: T, value: T) -> UserSettingGetImapCall<'a, C>
24386    where
24387        T: AsRef<str>,
24388    {
24389        self._additional_params
24390            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24391        self
24392    }
24393
24394    /// Identifies the authorization scope for the method you are building.
24395    ///
24396    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24397    /// [`Scope::Readonly`].
24398    ///
24399    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24400    /// tokens for more than one scope.
24401    ///
24402    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24403    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24404    /// sufficient, a read-write scope will do as well.
24405    pub fn add_scope<St>(mut self, scope: St) -> UserSettingGetImapCall<'a, C>
24406    where
24407        St: AsRef<str>,
24408    {
24409        self._scopes.insert(String::from(scope.as_ref()));
24410        self
24411    }
24412    /// Identifies the authorization scope(s) for the method you are building.
24413    ///
24414    /// See [`Self::add_scope()`] for details.
24415    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingGetImapCall<'a, C>
24416    where
24417        I: IntoIterator<Item = St>,
24418        St: AsRef<str>,
24419    {
24420        self._scopes
24421            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24422        self
24423    }
24424
24425    /// Removes all scopes, and no default scope will be used either.
24426    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24427    /// for details).
24428    pub fn clear_scopes(mut self) -> UserSettingGetImapCall<'a, C> {
24429        self._scopes.clear();
24430        self
24431    }
24432}
24433
24434/// Gets language settings.
24435///
24436/// A builder for the *settings.getLanguage* method supported by a *user* resource.
24437/// It is not used directly, but through a [`UserMethods`] instance.
24438///
24439/// # Example
24440///
24441/// Instantiate a resource method builder
24442///
24443/// ```test_harness,no_run
24444/// # extern crate hyper;
24445/// # extern crate hyper_rustls;
24446/// # extern crate google_gmail1 as gmail1;
24447/// # async fn dox() {
24448/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24449///
24450/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24451/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24452/// #     .with_native_roots()
24453/// #     .unwrap()
24454/// #     .https_only()
24455/// #     .enable_http2()
24456/// #     .build();
24457///
24458/// # let executor = hyper_util::rt::TokioExecutor::new();
24459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24460/// #     secret,
24461/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24462/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24463/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24464/// #     ),
24465/// # ).build().await.unwrap();
24466///
24467/// # let client = hyper_util::client::legacy::Client::builder(
24468/// #     hyper_util::rt::TokioExecutor::new()
24469/// # )
24470/// # .build(
24471/// #     hyper_rustls::HttpsConnectorBuilder::new()
24472/// #         .with_native_roots()
24473/// #         .unwrap()
24474/// #         .https_or_http()
24475/// #         .enable_http2()
24476/// #         .build()
24477/// # );
24478/// # let mut hub = Gmail::new(client, auth);
24479/// // You can configure optional parameters by calling the respective setters at will, and
24480/// // execute the final call using `doit()`.
24481/// // Values shown here are possibly random and not representative !
24482/// let result = hub.users().settings_get_language("userId")
24483///              .doit().await;
24484/// # }
24485/// ```
24486pub struct UserSettingGetLanguageCall<'a, C>
24487where
24488    C: 'a,
24489{
24490    hub: &'a Gmail<C>,
24491    _user_id: String,
24492    _delegate: Option<&'a mut dyn common::Delegate>,
24493    _additional_params: HashMap<String, String>,
24494    _scopes: BTreeSet<String>,
24495}
24496
24497impl<'a, C> common::CallBuilder for UserSettingGetLanguageCall<'a, C> {}
24498
24499impl<'a, C> UserSettingGetLanguageCall<'a, C>
24500where
24501    C: common::Connector,
24502{
24503    /// Perform the operation you have build so far.
24504    pub async fn doit(mut self) -> common::Result<(common::Response, LanguageSettings)> {
24505        use std::borrow::Cow;
24506        use std::io::{Read, Seek};
24507
24508        use common::{url::Params, ToParts};
24509        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24510
24511        let mut dd = common::DefaultDelegate;
24512        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24513        dlg.begin(common::MethodInfo {
24514            id: "gmail.users.settings.getLanguage",
24515            http_method: hyper::Method::GET,
24516        });
24517
24518        for &field in ["alt", "userId"].iter() {
24519            if self._additional_params.contains_key(field) {
24520                dlg.finished(false);
24521                return Err(common::Error::FieldClash(field));
24522            }
24523        }
24524
24525        let mut params = Params::with_capacity(3 + self._additional_params.len());
24526        params.push("userId", self._user_id);
24527
24528        params.extend(self._additional_params.iter());
24529
24530        params.push("alt", "json");
24531        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/language";
24532        if self._scopes.is_empty() {
24533            self._scopes.insert(Scope::Readonly.as_ref().to_string());
24534        }
24535
24536        #[allow(clippy::single_element_loop)]
24537        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
24538            url = params.uri_replacement(url, param_name, find_this, false);
24539        }
24540        {
24541            let to_remove = ["userId"];
24542            params.remove_params(&to_remove);
24543        }
24544
24545        let url = params.parse_with_url(&url);
24546
24547        loop {
24548            let token = match self
24549                .hub
24550                .auth
24551                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24552                .await
24553            {
24554                Ok(token) => token,
24555                Err(e) => match dlg.token(e) {
24556                    Ok(token) => token,
24557                    Err(e) => {
24558                        dlg.finished(false);
24559                        return Err(common::Error::MissingToken(e));
24560                    }
24561                },
24562            };
24563            let mut req_result = {
24564                let client = &self.hub.client;
24565                dlg.pre_request();
24566                let mut req_builder = hyper::Request::builder()
24567                    .method(hyper::Method::GET)
24568                    .uri(url.as_str())
24569                    .header(USER_AGENT, self.hub._user_agent.clone());
24570
24571                if let Some(token) = token.as_ref() {
24572                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24573                }
24574
24575                let request = req_builder
24576                    .header(CONTENT_LENGTH, 0_u64)
24577                    .body(common::to_body::<String>(None));
24578
24579                client.request(request.unwrap()).await
24580            };
24581
24582            match req_result {
24583                Err(err) => {
24584                    if let common::Retry::After(d) = dlg.http_error(&err) {
24585                        sleep(d).await;
24586                        continue;
24587                    }
24588                    dlg.finished(false);
24589                    return Err(common::Error::HttpError(err));
24590                }
24591                Ok(res) => {
24592                    let (mut parts, body) = res.into_parts();
24593                    let mut body = common::Body::new(body);
24594                    if !parts.status.is_success() {
24595                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24596                        let error = serde_json::from_str(&common::to_string(&bytes));
24597                        let response = common::to_response(parts, bytes.into());
24598
24599                        if let common::Retry::After(d) =
24600                            dlg.http_failure(&response, error.as_ref().ok())
24601                        {
24602                            sleep(d).await;
24603                            continue;
24604                        }
24605
24606                        dlg.finished(false);
24607
24608                        return Err(match error {
24609                            Ok(value) => common::Error::BadRequest(value),
24610                            _ => common::Error::Failure(response),
24611                        });
24612                    }
24613                    let response = {
24614                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24615                        let encoded = common::to_string(&bytes);
24616                        match serde_json::from_str(&encoded) {
24617                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24618                            Err(error) => {
24619                                dlg.response_json_decode_error(&encoded, &error);
24620                                return Err(common::Error::JsonDecodeError(
24621                                    encoded.to_string(),
24622                                    error,
24623                                ));
24624                            }
24625                        }
24626                    };
24627
24628                    dlg.finished(true);
24629                    return Ok(response);
24630                }
24631            }
24632        }
24633    }
24634
24635    /// User's email address. The special value "me" can be used to indicate the authenticated user.
24636    ///
24637    /// Sets the *user id* path property to the given value.
24638    ///
24639    /// Even though the property as already been set when instantiating this call,
24640    /// we provide this method for API completeness.
24641    pub fn user_id(mut self, new_value: &str) -> UserSettingGetLanguageCall<'a, C> {
24642        self._user_id = new_value.to_string();
24643        self
24644    }
24645    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24646    /// while executing the actual API request.
24647    ///
24648    /// ````text
24649    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24650    /// ````
24651    ///
24652    /// Sets the *delegate* property to the given value.
24653    pub fn delegate(
24654        mut self,
24655        new_value: &'a mut dyn common::Delegate,
24656    ) -> UserSettingGetLanguageCall<'a, C> {
24657        self._delegate = Some(new_value);
24658        self
24659    }
24660
24661    /// Set any additional parameter of the query string used in the request.
24662    /// It should be used to set parameters which are not yet available through their own
24663    /// setters.
24664    ///
24665    /// Please note that this method must not be used to set any of the known parameters
24666    /// which have their own setter method. If done anyway, the request will fail.
24667    ///
24668    /// # Additional Parameters
24669    ///
24670    /// * *$.xgafv* (query-string) - V1 error format.
24671    /// * *access_token* (query-string) - OAuth access token.
24672    /// * *alt* (query-string) - Data format for response.
24673    /// * *callback* (query-string) - JSONP
24674    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24675    /// * *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.
24676    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24677    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24678    /// * *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.
24679    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24680    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24681    pub fn param<T>(mut self, name: T, value: T) -> UserSettingGetLanguageCall<'a, C>
24682    where
24683        T: AsRef<str>,
24684    {
24685        self._additional_params
24686            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24687        self
24688    }
24689
24690    /// Identifies the authorization scope for the method you are building.
24691    ///
24692    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24693    /// [`Scope::Readonly`].
24694    ///
24695    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24696    /// tokens for more than one scope.
24697    ///
24698    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24699    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24700    /// sufficient, a read-write scope will do as well.
24701    pub fn add_scope<St>(mut self, scope: St) -> UserSettingGetLanguageCall<'a, C>
24702    where
24703        St: AsRef<str>,
24704    {
24705        self._scopes.insert(String::from(scope.as_ref()));
24706        self
24707    }
24708    /// Identifies the authorization scope(s) for the method you are building.
24709    ///
24710    /// See [`Self::add_scope()`] for details.
24711    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingGetLanguageCall<'a, C>
24712    where
24713        I: IntoIterator<Item = St>,
24714        St: AsRef<str>,
24715    {
24716        self._scopes
24717            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24718        self
24719    }
24720
24721    /// Removes all scopes, and no default scope will be used either.
24722    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24723    /// for details).
24724    pub fn clear_scopes(mut self) -> UserSettingGetLanguageCall<'a, C> {
24725        self._scopes.clear();
24726        self
24727    }
24728}
24729
24730/// Gets POP settings.
24731///
24732/// A builder for the *settings.getPop* method supported by a *user* resource.
24733/// It is not used directly, but through a [`UserMethods`] instance.
24734///
24735/// # Example
24736///
24737/// Instantiate a resource method builder
24738///
24739/// ```test_harness,no_run
24740/// # extern crate hyper;
24741/// # extern crate hyper_rustls;
24742/// # extern crate google_gmail1 as gmail1;
24743/// # async fn dox() {
24744/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24745///
24746/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24747/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24748/// #     .with_native_roots()
24749/// #     .unwrap()
24750/// #     .https_only()
24751/// #     .enable_http2()
24752/// #     .build();
24753///
24754/// # let executor = hyper_util::rt::TokioExecutor::new();
24755/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24756/// #     secret,
24757/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24758/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
24759/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
24760/// #     ),
24761/// # ).build().await.unwrap();
24762///
24763/// # let client = hyper_util::client::legacy::Client::builder(
24764/// #     hyper_util::rt::TokioExecutor::new()
24765/// # )
24766/// # .build(
24767/// #     hyper_rustls::HttpsConnectorBuilder::new()
24768/// #         .with_native_roots()
24769/// #         .unwrap()
24770/// #         .https_or_http()
24771/// #         .enable_http2()
24772/// #         .build()
24773/// # );
24774/// # let mut hub = Gmail::new(client, auth);
24775/// // You can configure optional parameters by calling the respective setters at will, and
24776/// // execute the final call using `doit()`.
24777/// // Values shown here are possibly random and not representative !
24778/// let result = hub.users().settings_get_pop("userId")
24779///              .doit().await;
24780/// # }
24781/// ```
24782pub struct UserSettingGetPopCall<'a, C>
24783where
24784    C: 'a,
24785{
24786    hub: &'a Gmail<C>,
24787    _user_id: String,
24788    _delegate: Option<&'a mut dyn common::Delegate>,
24789    _additional_params: HashMap<String, String>,
24790    _scopes: BTreeSet<String>,
24791}
24792
24793impl<'a, C> common::CallBuilder for UserSettingGetPopCall<'a, C> {}
24794
24795impl<'a, C> UserSettingGetPopCall<'a, C>
24796where
24797    C: common::Connector,
24798{
24799    /// Perform the operation you have build so far.
24800    pub async fn doit(mut self) -> common::Result<(common::Response, PopSettings)> {
24801        use std::borrow::Cow;
24802        use std::io::{Read, Seek};
24803
24804        use common::{url::Params, ToParts};
24805        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24806
24807        let mut dd = common::DefaultDelegate;
24808        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24809        dlg.begin(common::MethodInfo {
24810            id: "gmail.users.settings.getPop",
24811            http_method: hyper::Method::GET,
24812        });
24813
24814        for &field in ["alt", "userId"].iter() {
24815            if self._additional_params.contains_key(field) {
24816                dlg.finished(false);
24817                return Err(common::Error::FieldClash(field));
24818            }
24819        }
24820
24821        let mut params = Params::with_capacity(3 + self._additional_params.len());
24822        params.push("userId", self._user_id);
24823
24824        params.extend(self._additional_params.iter());
24825
24826        params.push("alt", "json");
24827        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/pop";
24828        if self._scopes.is_empty() {
24829            self._scopes.insert(Scope::Readonly.as_ref().to_string());
24830        }
24831
24832        #[allow(clippy::single_element_loop)]
24833        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
24834            url = params.uri_replacement(url, param_name, find_this, false);
24835        }
24836        {
24837            let to_remove = ["userId"];
24838            params.remove_params(&to_remove);
24839        }
24840
24841        let url = params.parse_with_url(&url);
24842
24843        loop {
24844            let token = match self
24845                .hub
24846                .auth
24847                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24848                .await
24849            {
24850                Ok(token) => token,
24851                Err(e) => match dlg.token(e) {
24852                    Ok(token) => token,
24853                    Err(e) => {
24854                        dlg.finished(false);
24855                        return Err(common::Error::MissingToken(e));
24856                    }
24857                },
24858            };
24859            let mut req_result = {
24860                let client = &self.hub.client;
24861                dlg.pre_request();
24862                let mut req_builder = hyper::Request::builder()
24863                    .method(hyper::Method::GET)
24864                    .uri(url.as_str())
24865                    .header(USER_AGENT, self.hub._user_agent.clone());
24866
24867                if let Some(token) = token.as_ref() {
24868                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24869                }
24870
24871                let request = req_builder
24872                    .header(CONTENT_LENGTH, 0_u64)
24873                    .body(common::to_body::<String>(None));
24874
24875                client.request(request.unwrap()).await
24876            };
24877
24878            match req_result {
24879                Err(err) => {
24880                    if let common::Retry::After(d) = dlg.http_error(&err) {
24881                        sleep(d).await;
24882                        continue;
24883                    }
24884                    dlg.finished(false);
24885                    return Err(common::Error::HttpError(err));
24886                }
24887                Ok(res) => {
24888                    let (mut parts, body) = res.into_parts();
24889                    let mut body = common::Body::new(body);
24890                    if !parts.status.is_success() {
24891                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24892                        let error = serde_json::from_str(&common::to_string(&bytes));
24893                        let response = common::to_response(parts, bytes.into());
24894
24895                        if let common::Retry::After(d) =
24896                            dlg.http_failure(&response, error.as_ref().ok())
24897                        {
24898                            sleep(d).await;
24899                            continue;
24900                        }
24901
24902                        dlg.finished(false);
24903
24904                        return Err(match error {
24905                            Ok(value) => common::Error::BadRequest(value),
24906                            _ => common::Error::Failure(response),
24907                        });
24908                    }
24909                    let response = {
24910                        let bytes = common::to_bytes(body).await.unwrap_or_default();
24911                        let encoded = common::to_string(&bytes);
24912                        match serde_json::from_str(&encoded) {
24913                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24914                            Err(error) => {
24915                                dlg.response_json_decode_error(&encoded, &error);
24916                                return Err(common::Error::JsonDecodeError(
24917                                    encoded.to_string(),
24918                                    error,
24919                                ));
24920                            }
24921                        }
24922                    };
24923
24924                    dlg.finished(true);
24925                    return Ok(response);
24926                }
24927            }
24928        }
24929    }
24930
24931    /// User's email address. The special value "me" can be used to indicate the authenticated user.
24932    ///
24933    /// Sets the *user id* path property to the given value.
24934    ///
24935    /// Even though the property as already been set when instantiating this call,
24936    /// we provide this method for API completeness.
24937    pub fn user_id(mut self, new_value: &str) -> UserSettingGetPopCall<'a, C> {
24938        self._user_id = new_value.to_string();
24939        self
24940    }
24941    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24942    /// while executing the actual API request.
24943    ///
24944    /// ````text
24945    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
24946    /// ````
24947    ///
24948    /// Sets the *delegate* property to the given value.
24949    pub fn delegate(
24950        mut self,
24951        new_value: &'a mut dyn common::Delegate,
24952    ) -> UserSettingGetPopCall<'a, C> {
24953        self._delegate = Some(new_value);
24954        self
24955    }
24956
24957    /// Set any additional parameter of the query string used in the request.
24958    /// It should be used to set parameters which are not yet available through their own
24959    /// setters.
24960    ///
24961    /// Please note that this method must not be used to set any of the known parameters
24962    /// which have their own setter method. If done anyway, the request will fail.
24963    ///
24964    /// # Additional Parameters
24965    ///
24966    /// * *$.xgafv* (query-string) - V1 error format.
24967    /// * *access_token* (query-string) - OAuth access token.
24968    /// * *alt* (query-string) - Data format for response.
24969    /// * *callback* (query-string) - JSONP
24970    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24971    /// * *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.
24972    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24973    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24974    /// * *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.
24975    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24976    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24977    pub fn param<T>(mut self, name: T, value: T) -> UserSettingGetPopCall<'a, C>
24978    where
24979        T: AsRef<str>,
24980    {
24981        self._additional_params
24982            .insert(name.as_ref().to_string(), value.as_ref().to_string());
24983        self
24984    }
24985
24986    /// Identifies the authorization scope for the method you are building.
24987    ///
24988    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24989    /// [`Scope::Readonly`].
24990    ///
24991    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24992    /// tokens for more than one scope.
24993    ///
24994    /// Usually there is more than one suitable scope to authorize an operation, some of which may
24995    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24996    /// sufficient, a read-write scope will do as well.
24997    pub fn add_scope<St>(mut self, scope: St) -> UserSettingGetPopCall<'a, C>
24998    where
24999        St: AsRef<str>,
25000    {
25001        self._scopes.insert(String::from(scope.as_ref()));
25002        self
25003    }
25004    /// Identifies the authorization scope(s) for the method you are building.
25005    ///
25006    /// See [`Self::add_scope()`] for details.
25007    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingGetPopCall<'a, C>
25008    where
25009        I: IntoIterator<Item = St>,
25010        St: AsRef<str>,
25011    {
25012        self._scopes
25013            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25014        self
25015    }
25016
25017    /// Removes all scopes, and no default scope will be used either.
25018    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25019    /// for details).
25020    pub fn clear_scopes(mut self) -> UserSettingGetPopCall<'a, C> {
25021        self._scopes.clear();
25022        self
25023    }
25024}
25025
25026/// Gets vacation responder settings.
25027///
25028/// A builder for the *settings.getVacation* method supported by a *user* resource.
25029/// It is not used directly, but through a [`UserMethods`] instance.
25030///
25031/// # Example
25032///
25033/// Instantiate a resource method builder
25034///
25035/// ```test_harness,no_run
25036/// # extern crate hyper;
25037/// # extern crate hyper_rustls;
25038/// # extern crate google_gmail1 as gmail1;
25039/// # async fn dox() {
25040/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25041///
25042/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25043/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25044/// #     .with_native_roots()
25045/// #     .unwrap()
25046/// #     .https_only()
25047/// #     .enable_http2()
25048/// #     .build();
25049///
25050/// # let executor = hyper_util::rt::TokioExecutor::new();
25051/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25052/// #     secret,
25053/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25054/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25055/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25056/// #     ),
25057/// # ).build().await.unwrap();
25058///
25059/// # let client = hyper_util::client::legacy::Client::builder(
25060/// #     hyper_util::rt::TokioExecutor::new()
25061/// # )
25062/// # .build(
25063/// #     hyper_rustls::HttpsConnectorBuilder::new()
25064/// #         .with_native_roots()
25065/// #         .unwrap()
25066/// #         .https_or_http()
25067/// #         .enable_http2()
25068/// #         .build()
25069/// # );
25070/// # let mut hub = Gmail::new(client, auth);
25071/// // You can configure optional parameters by calling the respective setters at will, and
25072/// // execute the final call using `doit()`.
25073/// // Values shown here are possibly random and not representative !
25074/// let result = hub.users().settings_get_vacation("userId")
25075///              .doit().await;
25076/// # }
25077/// ```
25078pub struct UserSettingGetVacationCall<'a, C>
25079where
25080    C: 'a,
25081{
25082    hub: &'a Gmail<C>,
25083    _user_id: String,
25084    _delegate: Option<&'a mut dyn common::Delegate>,
25085    _additional_params: HashMap<String, String>,
25086    _scopes: BTreeSet<String>,
25087}
25088
25089impl<'a, C> common::CallBuilder for UserSettingGetVacationCall<'a, C> {}
25090
25091impl<'a, C> UserSettingGetVacationCall<'a, C>
25092where
25093    C: common::Connector,
25094{
25095    /// Perform the operation you have build so far.
25096    pub async fn doit(mut self) -> common::Result<(common::Response, VacationSettings)> {
25097        use std::borrow::Cow;
25098        use std::io::{Read, Seek};
25099
25100        use common::{url::Params, ToParts};
25101        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25102
25103        let mut dd = common::DefaultDelegate;
25104        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25105        dlg.begin(common::MethodInfo {
25106            id: "gmail.users.settings.getVacation",
25107            http_method: hyper::Method::GET,
25108        });
25109
25110        for &field in ["alt", "userId"].iter() {
25111            if self._additional_params.contains_key(field) {
25112                dlg.finished(false);
25113                return Err(common::Error::FieldClash(field));
25114            }
25115        }
25116
25117        let mut params = Params::with_capacity(3 + self._additional_params.len());
25118        params.push("userId", self._user_id);
25119
25120        params.extend(self._additional_params.iter());
25121
25122        params.push("alt", "json");
25123        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/vacation";
25124        if self._scopes.is_empty() {
25125            self._scopes.insert(Scope::Readonly.as_ref().to_string());
25126        }
25127
25128        #[allow(clippy::single_element_loop)]
25129        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
25130            url = params.uri_replacement(url, param_name, find_this, false);
25131        }
25132        {
25133            let to_remove = ["userId"];
25134            params.remove_params(&to_remove);
25135        }
25136
25137        let url = params.parse_with_url(&url);
25138
25139        loop {
25140            let token = match self
25141                .hub
25142                .auth
25143                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25144                .await
25145            {
25146                Ok(token) => token,
25147                Err(e) => match dlg.token(e) {
25148                    Ok(token) => token,
25149                    Err(e) => {
25150                        dlg.finished(false);
25151                        return Err(common::Error::MissingToken(e));
25152                    }
25153                },
25154            };
25155            let mut req_result = {
25156                let client = &self.hub.client;
25157                dlg.pre_request();
25158                let mut req_builder = hyper::Request::builder()
25159                    .method(hyper::Method::GET)
25160                    .uri(url.as_str())
25161                    .header(USER_AGENT, self.hub._user_agent.clone());
25162
25163                if let Some(token) = token.as_ref() {
25164                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25165                }
25166
25167                let request = req_builder
25168                    .header(CONTENT_LENGTH, 0_u64)
25169                    .body(common::to_body::<String>(None));
25170
25171                client.request(request.unwrap()).await
25172            };
25173
25174            match req_result {
25175                Err(err) => {
25176                    if let common::Retry::After(d) = dlg.http_error(&err) {
25177                        sleep(d).await;
25178                        continue;
25179                    }
25180                    dlg.finished(false);
25181                    return Err(common::Error::HttpError(err));
25182                }
25183                Ok(res) => {
25184                    let (mut parts, body) = res.into_parts();
25185                    let mut body = common::Body::new(body);
25186                    if !parts.status.is_success() {
25187                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25188                        let error = serde_json::from_str(&common::to_string(&bytes));
25189                        let response = common::to_response(parts, bytes.into());
25190
25191                        if let common::Retry::After(d) =
25192                            dlg.http_failure(&response, error.as_ref().ok())
25193                        {
25194                            sleep(d).await;
25195                            continue;
25196                        }
25197
25198                        dlg.finished(false);
25199
25200                        return Err(match error {
25201                            Ok(value) => common::Error::BadRequest(value),
25202                            _ => common::Error::Failure(response),
25203                        });
25204                    }
25205                    let response = {
25206                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25207                        let encoded = common::to_string(&bytes);
25208                        match serde_json::from_str(&encoded) {
25209                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25210                            Err(error) => {
25211                                dlg.response_json_decode_error(&encoded, &error);
25212                                return Err(common::Error::JsonDecodeError(
25213                                    encoded.to_string(),
25214                                    error,
25215                                ));
25216                            }
25217                        }
25218                    };
25219
25220                    dlg.finished(true);
25221                    return Ok(response);
25222                }
25223            }
25224        }
25225    }
25226
25227    /// User's email address. The special value "me" can be used to indicate the authenticated user.
25228    ///
25229    /// Sets the *user id* path property to the given value.
25230    ///
25231    /// Even though the property as already been set when instantiating this call,
25232    /// we provide this method for API completeness.
25233    pub fn user_id(mut self, new_value: &str) -> UserSettingGetVacationCall<'a, C> {
25234        self._user_id = new_value.to_string();
25235        self
25236    }
25237    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25238    /// while executing the actual API request.
25239    ///
25240    /// ````text
25241    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25242    /// ````
25243    ///
25244    /// Sets the *delegate* property to the given value.
25245    pub fn delegate(
25246        mut self,
25247        new_value: &'a mut dyn common::Delegate,
25248    ) -> UserSettingGetVacationCall<'a, C> {
25249        self._delegate = Some(new_value);
25250        self
25251    }
25252
25253    /// Set any additional parameter of the query string used in the request.
25254    /// It should be used to set parameters which are not yet available through their own
25255    /// setters.
25256    ///
25257    /// Please note that this method must not be used to set any of the known parameters
25258    /// which have their own setter method. If done anyway, the request will fail.
25259    ///
25260    /// # Additional Parameters
25261    ///
25262    /// * *$.xgafv* (query-string) - V1 error format.
25263    /// * *access_token* (query-string) - OAuth access token.
25264    /// * *alt* (query-string) - Data format for response.
25265    /// * *callback* (query-string) - JSONP
25266    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25267    /// * *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.
25268    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25269    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25270    /// * *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.
25271    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25272    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25273    pub fn param<T>(mut self, name: T, value: T) -> UserSettingGetVacationCall<'a, C>
25274    where
25275        T: AsRef<str>,
25276    {
25277        self._additional_params
25278            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25279        self
25280    }
25281
25282    /// Identifies the authorization scope for the method you are building.
25283    ///
25284    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25285    /// [`Scope::Readonly`].
25286    ///
25287    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25288    /// tokens for more than one scope.
25289    ///
25290    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25291    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25292    /// sufficient, a read-write scope will do as well.
25293    pub fn add_scope<St>(mut self, scope: St) -> UserSettingGetVacationCall<'a, C>
25294    where
25295        St: AsRef<str>,
25296    {
25297        self._scopes.insert(String::from(scope.as_ref()));
25298        self
25299    }
25300    /// Identifies the authorization scope(s) for the method you are building.
25301    ///
25302    /// See [`Self::add_scope()`] for details.
25303    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingGetVacationCall<'a, C>
25304    where
25305        I: IntoIterator<Item = St>,
25306        St: AsRef<str>,
25307    {
25308        self._scopes
25309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25310        self
25311    }
25312
25313    /// Removes all scopes, and no default scope will be used either.
25314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25315    /// for details).
25316    pub fn clear_scopes(mut self) -> UserSettingGetVacationCall<'a, C> {
25317        self._scopes.clear();
25318        self
25319    }
25320}
25321
25322/// Updates the auto-forwarding setting for the specified account. A verified forwarding address must be specified when auto-forwarding is enabled. This method is only available to service account clients that have been delegated domain-wide authority.
25323///
25324/// A builder for the *settings.updateAutoForwarding* method supported by a *user* resource.
25325/// It is not used directly, but through a [`UserMethods`] instance.
25326///
25327/// # Example
25328///
25329/// Instantiate a resource method builder
25330///
25331/// ```test_harness,no_run
25332/// # extern crate hyper;
25333/// # extern crate hyper_rustls;
25334/// # extern crate google_gmail1 as gmail1;
25335/// use gmail1::api::AutoForwarding;
25336/// # async fn dox() {
25337/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25338///
25339/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25340/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25341/// #     .with_native_roots()
25342/// #     .unwrap()
25343/// #     .https_only()
25344/// #     .enable_http2()
25345/// #     .build();
25346///
25347/// # let executor = hyper_util::rt::TokioExecutor::new();
25348/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25349/// #     secret,
25350/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25351/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25352/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25353/// #     ),
25354/// # ).build().await.unwrap();
25355///
25356/// # let client = hyper_util::client::legacy::Client::builder(
25357/// #     hyper_util::rt::TokioExecutor::new()
25358/// # )
25359/// # .build(
25360/// #     hyper_rustls::HttpsConnectorBuilder::new()
25361/// #         .with_native_roots()
25362/// #         .unwrap()
25363/// #         .https_or_http()
25364/// #         .enable_http2()
25365/// #         .build()
25366/// # );
25367/// # let mut hub = Gmail::new(client, auth);
25368/// // As the method needs a request, you would usually fill it with the desired information
25369/// // into the respective structure. Some of the parts shown here might not be applicable !
25370/// // Values shown here are possibly random and not representative !
25371/// let mut req = AutoForwarding::default();
25372///
25373/// // You can configure optional parameters by calling the respective setters at will, and
25374/// // execute the final call using `doit()`.
25375/// // Values shown here are possibly random and not representative !
25376/// let result = hub.users().settings_update_auto_forwarding(req, "userId")
25377///              .doit().await;
25378/// # }
25379/// ```
25380pub struct UserSettingUpdateAutoForwardingCall<'a, C>
25381where
25382    C: 'a,
25383{
25384    hub: &'a Gmail<C>,
25385    _request: AutoForwarding,
25386    _user_id: String,
25387    _delegate: Option<&'a mut dyn common::Delegate>,
25388    _additional_params: HashMap<String, String>,
25389    _scopes: BTreeSet<String>,
25390}
25391
25392impl<'a, C> common::CallBuilder for UserSettingUpdateAutoForwardingCall<'a, C> {}
25393
25394impl<'a, C> UserSettingUpdateAutoForwardingCall<'a, C>
25395where
25396    C: common::Connector,
25397{
25398    /// Perform the operation you have build so far.
25399    pub async fn doit(mut self) -> common::Result<(common::Response, AutoForwarding)> {
25400        use std::borrow::Cow;
25401        use std::io::{Read, Seek};
25402
25403        use common::{url::Params, ToParts};
25404        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25405
25406        let mut dd = common::DefaultDelegate;
25407        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25408        dlg.begin(common::MethodInfo {
25409            id: "gmail.users.settings.updateAutoForwarding",
25410            http_method: hyper::Method::PUT,
25411        });
25412
25413        for &field in ["alt", "userId"].iter() {
25414            if self._additional_params.contains_key(field) {
25415                dlg.finished(false);
25416                return Err(common::Error::FieldClash(field));
25417            }
25418        }
25419
25420        let mut params = Params::with_capacity(4 + self._additional_params.len());
25421        params.push("userId", self._user_id);
25422
25423        params.extend(self._additional_params.iter());
25424
25425        params.push("alt", "json");
25426        let mut url =
25427            self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/autoForwarding";
25428        if self._scopes.is_empty() {
25429            self._scopes
25430                .insert(Scope::SettingSharing.as_ref().to_string());
25431        }
25432
25433        #[allow(clippy::single_element_loop)]
25434        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
25435            url = params.uri_replacement(url, param_name, find_this, false);
25436        }
25437        {
25438            let to_remove = ["userId"];
25439            params.remove_params(&to_remove);
25440        }
25441
25442        let url = params.parse_with_url(&url);
25443
25444        let mut json_mime_type = mime::APPLICATION_JSON;
25445        let mut request_value_reader = {
25446            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25447            common::remove_json_null_values(&mut value);
25448            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25449            serde_json::to_writer(&mut dst, &value).unwrap();
25450            dst
25451        };
25452        let request_size = request_value_reader
25453            .seek(std::io::SeekFrom::End(0))
25454            .unwrap();
25455        request_value_reader
25456            .seek(std::io::SeekFrom::Start(0))
25457            .unwrap();
25458
25459        loop {
25460            let token = match self
25461                .hub
25462                .auth
25463                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25464                .await
25465            {
25466                Ok(token) => token,
25467                Err(e) => match dlg.token(e) {
25468                    Ok(token) => token,
25469                    Err(e) => {
25470                        dlg.finished(false);
25471                        return Err(common::Error::MissingToken(e));
25472                    }
25473                },
25474            };
25475            request_value_reader
25476                .seek(std::io::SeekFrom::Start(0))
25477                .unwrap();
25478            let mut req_result = {
25479                let client = &self.hub.client;
25480                dlg.pre_request();
25481                let mut req_builder = hyper::Request::builder()
25482                    .method(hyper::Method::PUT)
25483                    .uri(url.as_str())
25484                    .header(USER_AGENT, self.hub._user_agent.clone());
25485
25486                if let Some(token) = token.as_ref() {
25487                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25488                }
25489
25490                let request = req_builder
25491                    .header(CONTENT_TYPE, json_mime_type.to_string())
25492                    .header(CONTENT_LENGTH, request_size as u64)
25493                    .body(common::to_body(
25494                        request_value_reader.get_ref().clone().into(),
25495                    ));
25496
25497                client.request(request.unwrap()).await
25498            };
25499
25500            match req_result {
25501                Err(err) => {
25502                    if let common::Retry::After(d) = dlg.http_error(&err) {
25503                        sleep(d).await;
25504                        continue;
25505                    }
25506                    dlg.finished(false);
25507                    return Err(common::Error::HttpError(err));
25508                }
25509                Ok(res) => {
25510                    let (mut parts, body) = res.into_parts();
25511                    let mut body = common::Body::new(body);
25512                    if !parts.status.is_success() {
25513                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25514                        let error = serde_json::from_str(&common::to_string(&bytes));
25515                        let response = common::to_response(parts, bytes.into());
25516
25517                        if let common::Retry::After(d) =
25518                            dlg.http_failure(&response, error.as_ref().ok())
25519                        {
25520                            sleep(d).await;
25521                            continue;
25522                        }
25523
25524                        dlg.finished(false);
25525
25526                        return Err(match error {
25527                            Ok(value) => common::Error::BadRequest(value),
25528                            _ => common::Error::Failure(response),
25529                        });
25530                    }
25531                    let response = {
25532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25533                        let encoded = common::to_string(&bytes);
25534                        match serde_json::from_str(&encoded) {
25535                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25536                            Err(error) => {
25537                                dlg.response_json_decode_error(&encoded, &error);
25538                                return Err(common::Error::JsonDecodeError(
25539                                    encoded.to_string(),
25540                                    error,
25541                                ));
25542                            }
25543                        }
25544                    };
25545
25546                    dlg.finished(true);
25547                    return Ok(response);
25548                }
25549            }
25550        }
25551    }
25552
25553    ///
25554    /// Sets the *request* property to the given value.
25555    ///
25556    /// Even though the property as already been set when instantiating this call,
25557    /// we provide this method for API completeness.
25558    pub fn request(
25559        mut self,
25560        new_value: AutoForwarding,
25561    ) -> UserSettingUpdateAutoForwardingCall<'a, C> {
25562        self._request = new_value;
25563        self
25564    }
25565    /// User's email address. The special value "me" can be used to indicate the authenticated user.
25566    ///
25567    /// Sets the *user id* path property to the given value.
25568    ///
25569    /// Even though the property as already been set when instantiating this call,
25570    /// we provide this method for API completeness.
25571    pub fn user_id(mut self, new_value: &str) -> UserSettingUpdateAutoForwardingCall<'a, C> {
25572        self._user_id = new_value.to_string();
25573        self
25574    }
25575    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25576    /// while executing the actual API request.
25577    ///
25578    /// ````text
25579    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25580    /// ````
25581    ///
25582    /// Sets the *delegate* property to the given value.
25583    pub fn delegate(
25584        mut self,
25585        new_value: &'a mut dyn common::Delegate,
25586    ) -> UserSettingUpdateAutoForwardingCall<'a, C> {
25587        self._delegate = Some(new_value);
25588        self
25589    }
25590
25591    /// Set any additional parameter of the query string used in the request.
25592    /// It should be used to set parameters which are not yet available through their own
25593    /// setters.
25594    ///
25595    /// Please note that this method must not be used to set any of the known parameters
25596    /// which have their own setter method. If done anyway, the request will fail.
25597    ///
25598    /// # Additional Parameters
25599    ///
25600    /// * *$.xgafv* (query-string) - V1 error format.
25601    /// * *access_token* (query-string) - OAuth access token.
25602    /// * *alt* (query-string) - Data format for response.
25603    /// * *callback* (query-string) - JSONP
25604    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25605    /// * *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.
25606    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25607    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25608    /// * *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.
25609    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25610    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25611    pub fn param<T>(mut self, name: T, value: T) -> UserSettingUpdateAutoForwardingCall<'a, C>
25612    where
25613        T: AsRef<str>,
25614    {
25615        self._additional_params
25616            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25617        self
25618    }
25619
25620    /// Identifies the authorization scope for the method you are building.
25621    ///
25622    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25623    /// [`Scope::SettingSharing`].
25624    ///
25625    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25626    /// tokens for more than one scope.
25627    ///
25628    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25629    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25630    /// sufficient, a read-write scope will do as well.
25631    pub fn add_scope<St>(mut self, scope: St) -> UserSettingUpdateAutoForwardingCall<'a, C>
25632    where
25633        St: AsRef<str>,
25634    {
25635        self._scopes.insert(String::from(scope.as_ref()));
25636        self
25637    }
25638    /// Identifies the authorization scope(s) for the method you are building.
25639    ///
25640    /// See [`Self::add_scope()`] for details.
25641    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingUpdateAutoForwardingCall<'a, C>
25642    where
25643        I: IntoIterator<Item = St>,
25644        St: AsRef<str>,
25645    {
25646        self._scopes
25647            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25648        self
25649    }
25650
25651    /// Removes all scopes, and no default scope will be used either.
25652    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25653    /// for details).
25654    pub fn clear_scopes(mut self) -> UserSettingUpdateAutoForwardingCall<'a, C> {
25655        self._scopes.clear();
25656        self
25657    }
25658}
25659
25660/// Updates IMAP settings.
25661///
25662/// A builder for the *settings.updateImap* method supported by a *user* resource.
25663/// It is not used directly, but through a [`UserMethods`] instance.
25664///
25665/// # Example
25666///
25667/// Instantiate a resource method builder
25668///
25669/// ```test_harness,no_run
25670/// # extern crate hyper;
25671/// # extern crate hyper_rustls;
25672/// # extern crate google_gmail1 as gmail1;
25673/// use gmail1::api::ImapSettings;
25674/// # async fn dox() {
25675/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25676///
25677/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25678/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25679/// #     .with_native_roots()
25680/// #     .unwrap()
25681/// #     .https_only()
25682/// #     .enable_http2()
25683/// #     .build();
25684///
25685/// # let executor = hyper_util::rt::TokioExecutor::new();
25686/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25687/// #     secret,
25688/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25689/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
25690/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
25691/// #     ),
25692/// # ).build().await.unwrap();
25693///
25694/// # let client = hyper_util::client::legacy::Client::builder(
25695/// #     hyper_util::rt::TokioExecutor::new()
25696/// # )
25697/// # .build(
25698/// #     hyper_rustls::HttpsConnectorBuilder::new()
25699/// #         .with_native_roots()
25700/// #         .unwrap()
25701/// #         .https_or_http()
25702/// #         .enable_http2()
25703/// #         .build()
25704/// # );
25705/// # let mut hub = Gmail::new(client, auth);
25706/// // As the method needs a request, you would usually fill it with the desired information
25707/// // into the respective structure. Some of the parts shown here might not be applicable !
25708/// // Values shown here are possibly random and not representative !
25709/// let mut req = ImapSettings::default();
25710///
25711/// // You can configure optional parameters by calling the respective setters at will, and
25712/// // execute the final call using `doit()`.
25713/// // Values shown here are possibly random and not representative !
25714/// let result = hub.users().settings_update_imap(req, "userId")
25715///              .doit().await;
25716/// # }
25717/// ```
25718pub struct UserSettingUpdateImapCall<'a, C>
25719where
25720    C: 'a,
25721{
25722    hub: &'a Gmail<C>,
25723    _request: ImapSettings,
25724    _user_id: String,
25725    _delegate: Option<&'a mut dyn common::Delegate>,
25726    _additional_params: HashMap<String, String>,
25727    _scopes: BTreeSet<String>,
25728}
25729
25730impl<'a, C> common::CallBuilder for UserSettingUpdateImapCall<'a, C> {}
25731
25732impl<'a, C> UserSettingUpdateImapCall<'a, C>
25733where
25734    C: common::Connector,
25735{
25736    /// Perform the operation you have build so far.
25737    pub async fn doit(mut self) -> common::Result<(common::Response, ImapSettings)> {
25738        use std::borrow::Cow;
25739        use std::io::{Read, Seek};
25740
25741        use common::{url::Params, ToParts};
25742        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25743
25744        let mut dd = common::DefaultDelegate;
25745        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25746        dlg.begin(common::MethodInfo {
25747            id: "gmail.users.settings.updateImap",
25748            http_method: hyper::Method::PUT,
25749        });
25750
25751        for &field in ["alt", "userId"].iter() {
25752            if self._additional_params.contains_key(field) {
25753                dlg.finished(false);
25754                return Err(common::Error::FieldClash(field));
25755            }
25756        }
25757
25758        let mut params = Params::with_capacity(4 + self._additional_params.len());
25759        params.push("userId", self._user_id);
25760
25761        params.extend(self._additional_params.iter());
25762
25763        params.push("alt", "json");
25764        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/imap";
25765        if self._scopes.is_empty() {
25766            self._scopes
25767                .insert(Scope::SettingBasic.as_ref().to_string());
25768        }
25769
25770        #[allow(clippy::single_element_loop)]
25771        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
25772            url = params.uri_replacement(url, param_name, find_this, false);
25773        }
25774        {
25775            let to_remove = ["userId"];
25776            params.remove_params(&to_remove);
25777        }
25778
25779        let url = params.parse_with_url(&url);
25780
25781        let mut json_mime_type = mime::APPLICATION_JSON;
25782        let mut request_value_reader = {
25783            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25784            common::remove_json_null_values(&mut value);
25785            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25786            serde_json::to_writer(&mut dst, &value).unwrap();
25787            dst
25788        };
25789        let request_size = request_value_reader
25790            .seek(std::io::SeekFrom::End(0))
25791            .unwrap();
25792        request_value_reader
25793            .seek(std::io::SeekFrom::Start(0))
25794            .unwrap();
25795
25796        loop {
25797            let token = match self
25798                .hub
25799                .auth
25800                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25801                .await
25802            {
25803                Ok(token) => token,
25804                Err(e) => match dlg.token(e) {
25805                    Ok(token) => token,
25806                    Err(e) => {
25807                        dlg.finished(false);
25808                        return Err(common::Error::MissingToken(e));
25809                    }
25810                },
25811            };
25812            request_value_reader
25813                .seek(std::io::SeekFrom::Start(0))
25814                .unwrap();
25815            let mut req_result = {
25816                let client = &self.hub.client;
25817                dlg.pre_request();
25818                let mut req_builder = hyper::Request::builder()
25819                    .method(hyper::Method::PUT)
25820                    .uri(url.as_str())
25821                    .header(USER_AGENT, self.hub._user_agent.clone());
25822
25823                if let Some(token) = token.as_ref() {
25824                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25825                }
25826
25827                let request = req_builder
25828                    .header(CONTENT_TYPE, json_mime_type.to_string())
25829                    .header(CONTENT_LENGTH, request_size as u64)
25830                    .body(common::to_body(
25831                        request_value_reader.get_ref().clone().into(),
25832                    ));
25833
25834                client.request(request.unwrap()).await
25835            };
25836
25837            match req_result {
25838                Err(err) => {
25839                    if let common::Retry::After(d) = dlg.http_error(&err) {
25840                        sleep(d).await;
25841                        continue;
25842                    }
25843                    dlg.finished(false);
25844                    return Err(common::Error::HttpError(err));
25845                }
25846                Ok(res) => {
25847                    let (mut parts, body) = res.into_parts();
25848                    let mut body = common::Body::new(body);
25849                    if !parts.status.is_success() {
25850                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25851                        let error = serde_json::from_str(&common::to_string(&bytes));
25852                        let response = common::to_response(parts, bytes.into());
25853
25854                        if let common::Retry::After(d) =
25855                            dlg.http_failure(&response, error.as_ref().ok())
25856                        {
25857                            sleep(d).await;
25858                            continue;
25859                        }
25860
25861                        dlg.finished(false);
25862
25863                        return Err(match error {
25864                            Ok(value) => common::Error::BadRequest(value),
25865                            _ => common::Error::Failure(response),
25866                        });
25867                    }
25868                    let response = {
25869                        let bytes = common::to_bytes(body).await.unwrap_or_default();
25870                        let encoded = common::to_string(&bytes);
25871                        match serde_json::from_str(&encoded) {
25872                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25873                            Err(error) => {
25874                                dlg.response_json_decode_error(&encoded, &error);
25875                                return Err(common::Error::JsonDecodeError(
25876                                    encoded.to_string(),
25877                                    error,
25878                                ));
25879                            }
25880                        }
25881                    };
25882
25883                    dlg.finished(true);
25884                    return Ok(response);
25885                }
25886            }
25887        }
25888    }
25889
25890    ///
25891    /// Sets the *request* property to the given value.
25892    ///
25893    /// Even though the property as already been set when instantiating this call,
25894    /// we provide this method for API completeness.
25895    pub fn request(mut self, new_value: ImapSettings) -> UserSettingUpdateImapCall<'a, C> {
25896        self._request = new_value;
25897        self
25898    }
25899    /// User's email address. The special value "me" can be used to indicate the authenticated user.
25900    ///
25901    /// Sets the *user id* path property to the given value.
25902    ///
25903    /// Even though the property as already been set when instantiating this call,
25904    /// we provide this method for API completeness.
25905    pub fn user_id(mut self, new_value: &str) -> UserSettingUpdateImapCall<'a, C> {
25906        self._user_id = new_value.to_string();
25907        self
25908    }
25909    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25910    /// while executing the actual API request.
25911    ///
25912    /// ````text
25913    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
25914    /// ````
25915    ///
25916    /// Sets the *delegate* property to the given value.
25917    pub fn delegate(
25918        mut self,
25919        new_value: &'a mut dyn common::Delegate,
25920    ) -> UserSettingUpdateImapCall<'a, C> {
25921        self._delegate = Some(new_value);
25922        self
25923    }
25924
25925    /// Set any additional parameter of the query string used in the request.
25926    /// It should be used to set parameters which are not yet available through their own
25927    /// setters.
25928    ///
25929    /// Please note that this method must not be used to set any of the known parameters
25930    /// which have their own setter method. If done anyway, the request will fail.
25931    ///
25932    /// # Additional Parameters
25933    ///
25934    /// * *$.xgafv* (query-string) - V1 error format.
25935    /// * *access_token* (query-string) - OAuth access token.
25936    /// * *alt* (query-string) - Data format for response.
25937    /// * *callback* (query-string) - JSONP
25938    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25939    /// * *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.
25940    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25941    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25942    /// * *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.
25943    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25944    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25945    pub fn param<T>(mut self, name: T, value: T) -> UserSettingUpdateImapCall<'a, C>
25946    where
25947        T: AsRef<str>,
25948    {
25949        self._additional_params
25950            .insert(name.as_ref().to_string(), value.as_ref().to_string());
25951        self
25952    }
25953
25954    /// Identifies the authorization scope for the method you are building.
25955    ///
25956    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25957    /// [`Scope::SettingBasic`].
25958    ///
25959    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25960    /// tokens for more than one scope.
25961    ///
25962    /// Usually there is more than one suitable scope to authorize an operation, some of which may
25963    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25964    /// sufficient, a read-write scope will do as well.
25965    pub fn add_scope<St>(mut self, scope: St) -> UserSettingUpdateImapCall<'a, C>
25966    where
25967        St: AsRef<str>,
25968    {
25969        self._scopes.insert(String::from(scope.as_ref()));
25970        self
25971    }
25972    /// Identifies the authorization scope(s) for the method you are building.
25973    ///
25974    /// See [`Self::add_scope()`] for details.
25975    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingUpdateImapCall<'a, C>
25976    where
25977        I: IntoIterator<Item = St>,
25978        St: AsRef<str>,
25979    {
25980        self._scopes
25981            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25982        self
25983    }
25984
25985    /// Removes all scopes, and no default scope will be used either.
25986    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25987    /// for details).
25988    pub fn clear_scopes(mut self) -> UserSettingUpdateImapCall<'a, C> {
25989        self._scopes.clear();
25990        self
25991    }
25992}
25993
25994/// Updates language settings. If successful, the return object contains the `displayLanguage` that was saved for the user, which may differ from the value passed into the request. This is because the requested `displayLanguage` may not be directly supported by Gmail but have a close variant that is, and so the variant may be chosen and saved instead.
25995///
25996/// A builder for the *settings.updateLanguage* method supported by a *user* resource.
25997/// It is not used directly, but through a [`UserMethods`] instance.
25998///
25999/// # Example
26000///
26001/// Instantiate a resource method builder
26002///
26003/// ```test_harness,no_run
26004/// # extern crate hyper;
26005/// # extern crate hyper_rustls;
26006/// # extern crate google_gmail1 as gmail1;
26007/// use gmail1::api::LanguageSettings;
26008/// # async fn dox() {
26009/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26010///
26011/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26012/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26013/// #     .with_native_roots()
26014/// #     .unwrap()
26015/// #     .https_only()
26016/// #     .enable_http2()
26017/// #     .build();
26018///
26019/// # let executor = hyper_util::rt::TokioExecutor::new();
26020/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26021/// #     secret,
26022/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26023/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26024/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26025/// #     ),
26026/// # ).build().await.unwrap();
26027///
26028/// # let client = hyper_util::client::legacy::Client::builder(
26029/// #     hyper_util::rt::TokioExecutor::new()
26030/// # )
26031/// # .build(
26032/// #     hyper_rustls::HttpsConnectorBuilder::new()
26033/// #         .with_native_roots()
26034/// #         .unwrap()
26035/// #         .https_or_http()
26036/// #         .enable_http2()
26037/// #         .build()
26038/// # );
26039/// # let mut hub = Gmail::new(client, auth);
26040/// // As the method needs a request, you would usually fill it with the desired information
26041/// // into the respective structure. Some of the parts shown here might not be applicable !
26042/// // Values shown here are possibly random and not representative !
26043/// let mut req = LanguageSettings::default();
26044///
26045/// // You can configure optional parameters by calling the respective setters at will, and
26046/// // execute the final call using `doit()`.
26047/// // Values shown here are possibly random and not representative !
26048/// let result = hub.users().settings_update_language(req, "userId")
26049///              .doit().await;
26050/// # }
26051/// ```
26052pub struct UserSettingUpdateLanguageCall<'a, C>
26053where
26054    C: 'a,
26055{
26056    hub: &'a Gmail<C>,
26057    _request: LanguageSettings,
26058    _user_id: String,
26059    _delegate: Option<&'a mut dyn common::Delegate>,
26060    _additional_params: HashMap<String, String>,
26061    _scopes: BTreeSet<String>,
26062}
26063
26064impl<'a, C> common::CallBuilder for UserSettingUpdateLanguageCall<'a, C> {}
26065
26066impl<'a, C> UserSettingUpdateLanguageCall<'a, C>
26067where
26068    C: common::Connector,
26069{
26070    /// Perform the operation you have build so far.
26071    pub async fn doit(mut self) -> common::Result<(common::Response, LanguageSettings)> {
26072        use std::borrow::Cow;
26073        use std::io::{Read, Seek};
26074
26075        use common::{url::Params, ToParts};
26076        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26077
26078        let mut dd = common::DefaultDelegate;
26079        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26080        dlg.begin(common::MethodInfo {
26081            id: "gmail.users.settings.updateLanguage",
26082            http_method: hyper::Method::PUT,
26083        });
26084
26085        for &field in ["alt", "userId"].iter() {
26086            if self._additional_params.contains_key(field) {
26087                dlg.finished(false);
26088                return Err(common::Error::FieldClash(field));
26089            }
26090        }
26091
26092        let mut params = Params::with_capacity(4 + self._additional_params.len());
26093        params.push("userId", self._user_id);
26094
26095        params.extend(self._additional_params.iter());
26096
26097        params.push("alt", "json");
26098        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/language";
26099        if self._scopes.is_empty() {
26100            self._scopes
26101                .insert(Scope::SettingBasic.as_ref().to_string());
26102        }
26103
26104        #[allow(clippy::single_element_loop)]
26105        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
26106            url = params.uri_replacement(url, param_name, find_this, false);
26107        }
26108        {
26109            let to_remove = ["userId"];
26110            params.remove_params(&to_remove);
26111        }
26112
26113        let url = params.parse_with_url(&url);
26114
26115        let mut json_mime_type = mime::APPLICATION_JSON;
26116        let mut request_value_reader = {
26117            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26118            common::remove_json_null_values(&mut value);
26119            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26120            serde_json::to_writer(&mut dst, &value).unwrap();
26121            dst
26122        };
26123        let request_size = request_value_reader
26124            .seek(std::io::SeekFrom::End(0))
26125            .unwrap();
26126        request_value_reader
26127            .seek(std::io::SeekFrom::Start(0))
26128            .unwrap();
26129
26130        loop {
26131            let token = match self
26132                .hub
26133                .auth
26134                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26135                .await
26136            {
26137                Ok(token) => token,
26138                Err(e) => match dlg.token(e) {
26139                    Ok(token) => token,
26140                    Err(e) => {
26141                        dlg.finished(false);
26142                        return Err(common::Error::MissingToken(e));
26143                    }
26144                },
26145            };
26146            request_value_reader
26147                .seek(std::io::SeekFrom::Start(0))
26148                .unwrap();
26149            let mut req_result = {
26150                let client = &self.hub.client;
26151                dlg.pre_request();
26152                let mut req_builder = hyper::Request::builder()
26153                    .method(hyper::Method::PUT)
26154                    .uri(url.as_str())
26155                    .header(USER_AGENT, self.hub._user_agent.clone());
26156
26157                if let Some(token) = token.as_ref() {
26158                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26159                }
26160
26161                let request = req_builder
26162                    .header(CONTENT_TYPE, json_mime_type.to_string())
26163                    .header(CONTENT_LENGTH, request_size as u64)
26164                    .body(common::to_body(
26165                        request_value_reader.get_ref().clone().into(),
26166                    ));
26167
26168                client.request(request.unwrap()).await
26169            };
26170
26171            match req_result {
26172                Err(err) => {
26173                    if let common::Retry::After(d) = dlg.http_error(&err) {
26174                        sleep(d).await;
26175                        continue;
26176                    }
26177                    dlg.finished(false);
26178                    return Err(common::Error::HttpError(err));
26179                }
26180                Ok(res) => {
26181                    let (mut parts, body) = res.into_parts();
26182                    let mut body = common::Body::new(body);
26183                    if !parts.status.is_success() {
26184                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26185                        let error = serde_json::from_str(&common::to_string(&bytes));
26186                        let response = common::to_response(parts, bytes.into());
26187
26188                        if let common::Retry::After(d) =
26189                            dlg.http_failure(&response, error.as_ref().ok())
26190                        {
26191                            sleep(d).await;
26192                            continue;
26193                        }
26194
26195                        dlg.finished(false);
26196
26197                        return Err(match error {
26198                            Ok(value) => common::Error::BadRequest(value),
26199                            _ => common::Error::Failure(response),
26200                        });
26201                    }
26202                    let response = {
26203                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26204                        let encoded = common::to_string(&bytes);
26205                        match serde_json::from_str(&encoded) {
26206                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26207                            Err(error) => {
26208                                dlg.response_json_decode_error(&encoded, &error);
26209                                return Err(common::Error::JsonDecodeError(
26210                                    encoded.to_string(),
26211                                    error,
26212                                ));
26213                            }
26214                        }
26215                    };
26216
26217                    dlg.finished(true);
26218                    return Ok(response);
26219                }
26220            }
26221        }
26222    }
26223
26224    ///
26225    /// Sets the *request* property to the given value.
26226    ///
26227    /// Even though the property as already been set when instantiating this call,
26228    /// we provide this method for API completeness.
26229    pub fn request(mut self, new_value: LanguageSettings) -> UserSettingUpdateLanguageCall<'a, C> {
26230        self._request = new_value;
26231        self
26232    }
26233    /// User's email address. The special value "me" can be used to indicate the authenticated user.
26234    ///
26235    /// Sets the *user id* path property to the given value.
26236    ///
26237    /// Even though the property as already been set when instantiating this call,
26238    /// we provide this method for API completeness.
26239    pub fn user_id(mut self, new_value: &str) -> UserSettingUpdateLanguageCall<'a, C> {
26240        self._user_id = new_value.to_string();
26241        self
26242    }
26243    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26244    /// while executing the actual API request.
26245    ///
26246    /// ````text
26247    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26248    /// ````
26249    ///
26250    /// Sets the *delegate* property to the given value.
26251    pub fn delegate(
26252        mut self,
26253        new_value: &'a mut dyn common::Delegate,
26254    ) -> UserSettingUpdateLanguageCall<'a, C> {
26255        self._delegate = Some(new_value);
26256        self
26257    }
26258
26259    /// Set any additional parameter of the query string used in the request.
26260    /// It should be used to set parameters which are not yet available through their own
26261    /// setters.
26262    ///
26263    /// Please note that this method must not be used to set any of the known parameters
26264    /// which have their own setter method. If done anyway, the request will fail.
26265    ///
26266    /// # Additional Parameters
26267    ///
26268    /// * *$.xgafv* (query-string) - V1 error format.
26269    /// * *access_token* (query-string) - OAuth access token.
26270    /// * *alt* (query-string) - Data format for response.
26271    /// * *callback* (query-string) - JSONP
26272    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26273    /// * *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.
26274    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26275    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26276    /// * *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.
26277    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26278    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26279    pub fn param<T>(mut self, name: T, value: T) -> UserSettingUpdateLanguageCall<'a, C>
26280    where
26281        T: AsRef<str>,
26282    {
26283        self._additional_params
26284            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26285        self
26286    }
26287
26288    /// Identifies the authorization scope for the method you are building.
26289    ///
26290    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26291    /// [`Scope::SettingBasic`].
26292    ///
26293    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26294    /// tokens for more than one scope.
26295    ///
26296    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26297    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26298    /// sufficient, a read-write scope will do as well.
26299    pub fn add_scope<St>(mut self, scope: St) -> UserSettingUpdateLanguageCall<'a, C>
26300    where
26301        St: AsRef<str>,
26302    {
26303        self._scopes.insert(String::from(scope.as_ref()));
26304        self
26305    }
26306    /// Identifies the authorization scope(s) for the method you are building.
26307    ///
26308    /// See [`Self::add_scope()`] for details.
26309    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingUpdateLanguageCall<'a, C>
26310    where
26311        I: IntoIterator<Item = St>,
26312        St: AsRef<str>,
26313    {
26314        self._scopes
26315            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26316        self
26317    }
26318
26319    /// Removes all scopes, and no default scope will be used either.
26320    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26321    /// for details).
26322    pub fn clear_scopes(mut self) -> UserSettingUpdateLanguageCall<'a, C> {
26323        self._scopes.clear();
26324        self
26325    }
26326}
26327
26328/// Updates POP settings.
26329///
26330/// A builder for the *settings.updatePop* method supported by a *user* resource.
26331/// It is not used directly, but through a [`UserMethods`] instance.
26332///
26333/// # Example
26334///
26335/// Instantiate a resource method builder
26336///
26337/// ```test_harness,no_run
26338/// # extern crate hyper;
26339/// # extern crate hyper_rustls;
26340/// # extern crate google_gmail1 as gmail1;
26341/// use gmail1::api::PopSettings;
26342/// # async fn dox() {
26343/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26344///
26345/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26346/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26347/// #     .with_native_roots()
26348/// #     .unwrap()
26349/// #     .https_only()
26350/// #     .enable_http2()
26351/// #     .build();
26352///
26353/// # let executor = hyper_util::rt::TokioExecutor::new();
26354/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26355/// #     secret,
26356/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26357/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26358/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26359/// #     ),
26360/// # ).build().await.unwrap();
26361///
26362/// # let client = hyper_util::client::legacy::Client::builder(
26363/// #     hyper_util::rt::TokioExecutor::new()
26364/// # )
26365/// # .build(
26366/// #     hyper_rustls::HttpsConnectorBuilder::new()
26367/// #         .with_native_roots()
26368/// #         .unwrap()
26369/// #         .https_or_http()
26370/// #         .enable_http2()
26371/// #         .build()
26372/// # );
26373/// # let mut hub = Gmail::new(client, auth);
26374/// // As the method needs a request, you would usually fill it with the desired information
26375/// // into the respective structure. Some of the parts shown here might not be applicable !
26376/// // Values shown here are possibly random and not representative !
26377/// let mut req = PopSettings::default();
26378///
26379/// // You can configure optional parameters by calling the respective setters at will, and
26380/// // execute the final call using `doit()`.
26381/// // Values shown here are possibly random and not representative !
26382/// let result = hub.users().settings_update_pop(req, "userId")
26383///              .doit().await;
26384/// # }
26385/// ```
26386pub struct UserSettingUpdatePopCall<'a, C>
26387where
26388    C: 'a,
26389{
26390    hub: &'a Gmail<C>,
26391    _request: PopSettings,
26392    _user_id: String,
26393    _delegate: Option<&'a mut dyn common::Delegate>,
26394    _additional_params: HashMap<String, String>,
26395    _scopes: BTreeSet<String>,
26396}
26397
26398impl<'a, C> common::CallBuilder for UserSettingUpdatePopCall<'a, C> {}
26399
26400impl<'a, C> UserSettingUpdatePopCall<'a, C>
26401where
26402    C: common::Connector,
26403{
26404    /// Perform the operation you have build so far.
26405    pub async fn doit(mut self) -> common::Result<(common::Response, PopSettings)> {
26406        use std::borrow::Cow;
26407        use std::io::{Read, Seek};
26408
26409        use common::{url::Params, ToParts};
26410        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26411
26412        let mut dd = common::DefaultDelegate;
26413        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26414        dlg.begin(common::MethodInfo {
26415            id: "gmail.users.settings.updatePop",
26416            http_method: hyper::Method::PUT,
26417        });
26418
26419        for &field in ["alt", "userId"].iter() {
26420            if self._additional_params.contains_key(field) {
26421                dlg.finished(false);
26422                return Err(common::Error::FieldClash(field));
26423            }
26424        }
26425
26426        let mut params = Params::with_capacity(4 + self._additional_params.len());
26427        params.push("userId", self._user_id);
26428
26429        params.extend(self._additional_params.iter());
26430
26431        params.push("alt", "json");
26432        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/pop";
26433        if self._scopes.is_empty() {
26434            self._scopes
26435                .insert(Scope::SettingBasic.as_ref().to_string());
26436        }
26437
26438        #[allow(clippy::single_element_loop)]
26439        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
26440            url = params.uri_replacement(url, param_name, find_this, false);
26441        }
26442        {
26443            let to_remove = ["userId"];
26444            params.remove_params(&to_remove);
26445        }
26446
26447        let url = params.parse_with_url(&url);
26448
26449        let mut json_mime_type = mime::APPLICATION_JSON;
26450        let mut request_value_reader = {
26451            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26452            common::remove_json_null_values(&mut value);
26453            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26454            serde_json::to_writer(&mut dst, &value).unwrap();
26455            dst
26456        };
26457        let request_size = request_value_reader
26458            .seek(std::io::SeekFrom::End(0))
26459            .unwrap();
26460        request_value_reader
26461            .seek(std::io::SeekFrom::Start(0))
26462            .unwrap();
26463
26464        loop {
26465            let token = match self
26466                .hub
26467                .auth
26468                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26469                .await
26470            {
26471                Ok(token) => token,
26472                Err(e) => match dlg.token(e) {
26473                    Ok(token) => token,
26474                    Err(e) => {
26475                        dlg.finished(false);
26476                        return Err(common::Error::MissingToken(e));
26477                    }
26478                },
26479            };
26480            request_value_reader
26481                .seek(std::io::SeekFrom::Start(0))
26482                .unwrap();
26483            let mut req_result = {
26484                let client = &self.hub.client;
26485                dlg.pre_request();
26486                let mut req_builder = hyper::Request::builder()
26487                    .method(hyper::Method::PUT)
26488                    .uri(url.as_str())
26489                    .header(USER_AGENT, self.hub._user_agent.clone());
26490
26491                if let Some(token) = token.as_ref() {
26492                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26493                }
26494
26495                let request = req_builder
26496                    .header(CONTENT_TYPE, json_mime_type.to_string())
26497                    .header(CONTENT_LENGTH, request_size as u64)
26498                    .body(common::to_body(
26499                        request_value_reader.get_ref().clone().into(),
26500                    ));
26501
26502                client.request(request.unwrap()).await
26503            };
26504
26505            match req_result {
26506                Err(err) => {
26507                    if let common::Retry::After(d) = dlg.http_error(&err) {
26508                        sleep(d).await;
26509                        continue;
26510                    }
26511                    dlg.finished(false);
26512                    return Err(common::Error::HttpError(err));
26513                }
26514                Ok(res) => {
26515                    let (mut parts, body) = res.into_parts();
26516                    let mut body = common::Body::new(body);
26517                    if !parts.status.is_success() {
26518                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26519                        let error = serde_json::from_str(&common::to_string(&bytes));
26520                        let response = common::to_response(parts, bytes.into());
26521
26522                        if let common::Retry::After(d) =
26523                            dlg.http_failure(&response, error.as_ref().ok())
26524                        {
26525                            sleep(d).await;
26526                            continue;
26527                        }
26528
26529                        dlg.finished(false);
26530
26531                        return Err(match error {
26532                            Ok(value) => common::Error::BadRequest(value),
26533                            _ => common::Error::Failure(response),
26534                        });
26535                    }
26536                    let response = {
26537                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26538                        let encoded = common::to_string(&bytes);
26539                        match serde_json::from_str(&encoded) {
26540                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26541                            Err(error) => {
26542                                dlg.response_json_decode_error(&encoded, &error);
26543                                return Err(common::Error::JsonDecodeError(
26544                                    encoded.to_string(),
26545                                    error,
26546                                ));
26547                            }
26548                        }
26549                    };
26550
26551                    dlg.finished(true);
26552                    return Ok(response);
26553                }
26554            }
26555        }
26556    }
26557
26558    ///
26559    /// Sets the *request* property to the given value.
26560    ///
26561    /// Even though the property as already been set when instantiating this call,
26562    /// we provide this method for API completeness.
26563    pub fn request(mut self, new_value: PopSettings) -> UserSettingUpdatePopCall<'a, C> {
26564        self._request = new_value;
26565        self
26566    }
26567    /// User's email address. The special value "me" can be used to indicate the authenticated user.
26568    ///
26569    /// Sets the *user id* path property to the given value.
26570    ///
26571    /// Even though the property as already been set when instantiating this call,
26572    /// we provide this method for API completeness.
26573    pub fn user_id(mut self, new_value: &str) -> UserSettingUpdatePopCall<'a, C> {
26574        self._user_id = new_value.to_string();
26575        self
26576    }
26577    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26578    /// while executing the actual API request.
26579    ///
26580    /// ````text
26581    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26582    /// ````
26583    ///
26584    /// Sets the *delegate* property to the given value.
26585    pub fn delegate(
26586        mut self,
26587        new_value: &'a mut dyn common::Delegate,
26588    ) -> UserSettingUpdatePopCall<'a, C> {
26589        self._delegate = Some(new_value);
26590        self
26591    }
26592
26593    /// Set any additional parameter of the query string used in the request.
26594    /// It should be used to set parameters which are not yet available through their own
26595    /// setters.
26596    ///
26597    /// Please note that this method must not be used to set any of the known parameters
26598    /// which have their own setter method. If done anyway, the request will fail.
26599    ///
26600    /// # Additional Parameters
26601    ///
26602    /// * *$.xgafv* (query-string) - V1 error format.
26603    /// * *access_token* (query-string) - OAuth access token.
26604    /// * *alt* (query-string) - Data format for response.
26605    /// * *callback* (query-string) - JSONP
26606    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26607    /// * *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.
26608    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26609    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26610    /// * *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.
26611    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26612    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26613    pub fn param<T>(mut self, name: T, value: T) -> UserSettingUpdatePopCall<'a, C>
26614    where
26615        T: AsRef<str>,
26616    {
26617        self._additional_params
26618            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26619        self
26620    }
26621
26622    /// Identifies the authorization scope for the method you are building.
26623    ///
26624    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26625    /// [`Scope::SettingBasic`].
26626    ///
26627    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26628    /// tokens for more than one scope.
26629    ///
26630    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26631    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26632    /// sufficient, a read-write scope will do as well.
26633    pub fn add_scope<St>(mut self, scope: St) -> UserSettingUpdatePopCall<'a, C>
26634    where
26635        St: AsRef<str>,
26636    {
26637        self._scopes.insert(String::from(scope.as_ref()));
26638        self
26639    }
26640    /// Identifies the authorization scope(s) for the method you are building.
26641    ///
26642    /// See [`Self::add_scope()`] for details.
26643    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingUpdatePopCall<'a, C>
26644    where
26645        I: IntoIterator<Item = St>,
26646        St: AsRef<str>,
26647    {
26648        self._scopes
26649            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26650        self
26651    }
26652
26653    /// Removes all scopes, and no default scope will be used either.
26654    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26655    /// for details).
26656    pub fn clear_scopes(mut self) -> UserSettingUpdatePopCall<'a, C> {
26657        self._scopes.clear();
26658        self
26659    }
26660}
26661
26662/// Updates vacation responder settings.
26663///
26664/// A builder for the *settings.updateVacation* method supported by a *user* resource.
26665/// It is not used directly, but through a [`UserMethods`] instance.
26666///
26667/// # Example
26668///
26669/// Instantiate a resource method builder
26670///
26671/// ```test_harness,no_run
26672/// # extern crate hyper;
26673/// # extern crate hyper_rustls;
26674/// # extern crate google_gmail1 as gmail1;
26675/// use gmail1::api::VacationSettings;
26676/// # async fn dox() {
26677/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26678///
26679/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26680/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26681/// #     .with_native_roots()
26682/// #     .unwrap()
26683/// #     .https_only()
26684/// #     .enable_http2()
26685/// #     .build();
26686///
26687/// # let executor = hyper_util::rt::TokioExecutor::new();
26688/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26689/// #     secret,
26690/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26691/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
26692/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
26693/// #     ),
26694/// # ).build().await.unwrap();
26695///
26696/// # let client = hyper_util::client::legacy::Client::builder(
26697/// #     hyper_util::rt::TokioExecutor::new()
26698/// # )
26699/// # .build(
26700/// #     hyper_rustls::HttpsConnectorBuilder::new()
26701/// #         .with_native_roots()
26702/// #         .unwrap()
26703/// #         .https_or_http()
26704/// #         .enable_http2()
26705/// #         .build()
26706/// # );
26707/// # let mut hub = Gmail::new(client, auth);
26708/// // As the method needs a request, you would usually fill it with the desired information
26709/// // into the respective structure. Some of the parts shown here might not be applicable !
26710/// // Values shown here are possibly random and not representative !
26711/// let mut req = VacationSettings::default();
26712///
26713/// // You can configure optional parameters by calling the respective setters at will, and
26714/// // execute the final call using `doit()`.
26715/// // Values shown here are possibly random and not representative !
26716/// let result = hub.users().settings_update_vacation(req, "userId")
26717///              .doit().await;
26718/// # }
26719/// ```
26720pub struct UserSettingUpdateVacationCall<'a, C>
26721where
26722    C: 'a,
26723{
26724    hub: &'a Gmail<C>,
26725    _request: VacationSettings,
26726    _user_id: String,
26727    _delegate: Option<&'a mut dyn common::Delegate>,
26728    _additional_params: HashMap<String, String>,
26729    _scopes: BTreeSet<String>,
26730}
26731
26732impl<'a, C> common::CallBuilder for UserSettingUpdateVacationCall<'a, C> {}
26733
26734impl<'a, C> UserSettingUpdateVacationCall<'a, C>
26735where
26736    C: common::Connector,
26737{
26738    /// Perform the operation you have build so far.
26739    pub async fn doit(mut self) -> common::Result<(common::Response, VacationSettings)> {
26740        use std::borrow::Cow;
26741        use std::io::{Read, Seek};
26742
26743        use common::{url::Params, ToParts};
26744        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26745
26746        let mut dd = common::DefaultDelegate;
26747        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26748        dlg.begin(common::MethodInfo {
26749            id: "gmail.users.settings.updateVacation",
26750            http_method: hyper::Method::PUT,
26751        });
26752
26753        for &field in ["alt", "userId"].iter() {
26754            if self._additional_params.contains_key(field) {
26755                dlg.finished(false);
26756                return Err(common::Error::FieldClash(field));
26757            }
26758        }
26759
26760        let mut params = Params::with_capacity(4 + self._additional_params.len());
26761        params.push("userId", self._user_id);
26762
26763        params.extend(self._additional_params.iter());
26764
26765        params.push("alt", "json");
26766        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/settings/vacation";
26767        if self._scopes.is_empty() {
26768            self._scopes
26769                .insert(Scope::SettingBasic.as_ref().to_string());
26770        }
26771
26772        #[allow(clippy::single_element_loop)]
26773        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
26774            url = params.uri_replacement(url, param_name, find_this, false);
26775        }
26776        {
26777            let to_remove = ["userId"];
26778            params.remove_params(&to_remove);
26779        }
26780
26781        let url = params.parse_with_url(&url);
26782
26783        let mut json_mime_type = mime::APPLICATION_JSON;
26784        let mut request_value_reader = {
26785            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26786            common::remove_json_null_values(&mut value);
26787            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26788            serde_json::to_writer(&mut dst, &value).unwrap();
26789            dst
26790        };
26791        let request_size = request_value_reader
26792            .seek(std::io::SeekFrom::End(0))
26793            .unwrap();
26794        request_value_reader
26795            .seek(std::io::SeekFrom::Start(0))
26796            .unwrap();
26797
26798        loop {
26799            let token = match self
26800                .hub
26801                .auth
26802                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26803                .await
26804            {
26805                Ok(token) => token,
26806                Err(e) => match dlg.token(e) {
26807                    Ok(token) => token,
26808                    Err(e) => {
26809                        dlg.finished(false);
26810                        return Err(common::Error::MissingToken(e));
26811                    }
26812                },
26813            };
26814            request_value_reader
26815                .seek(std::io::SeekFrom::Start(0))
26816                .unwrap();
26817            let mut req_result = {
26818                let client = &self.hub.client;
26819                dlg.pre_request();
26820                let mut req_builder = hyper::Request::builder()
26821                    .method(hyper::Method::PUT)
26822                    .uri(url.as_str())
26823                    .header(USER_AGENT, self.hub._user_agent.clone());
26824
26825                if let Some(token) = token.as_ref() {
26826                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26827                }
26828
26829                let request = req_builder
26830                    .header(CONTENT_TYPE, json_mime_type.to_string())
26831                    .header(CONTENT_LENGTH, request_size as u64)
26832                    .body(common::to_body(
26833                        request_value_reader.get_ref().clone().into(),
26834                    ));
26835
26836                client.request(request.unwrap()).await
26837            };
26838
26839            match req_result {
26840                Err(err) => {
26841                    if let common::Retry::After(d) = dlg.http_error(&err) {
26842                        sleep(d).await;
26843                        continue;
26844                    }
26845                    dlg.finished(false);
26846                    return Err(common::Error::HttpError(err));
26847                }
26848                Ok(res) => {
26849                    let (mut parts, body) = res.into_parts();
26850                    let mut body = common::Body::new(body);
26851                    if !parts.status.is_success() {
26852                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26853                        let error = serde_json::from_str(&common::to_string(&bytes));
26854                        let response = common::to_response(parts, bytes.into());
26855
26856                        if let common::Retry::After(d) =
26857                            dlg.http_failure(&response, error.as_ref().ok())
26858                        {
26859                            sleep(d).await;
26860                            continue;
26861                        }
26862
26863                        dlg.finished(false);
26864
26865                        return Err(match error {
26866                            Ok(value) => common::Error::BadRequest(value),
26867                            _ => common::Error::Failure(response),
26868                        });
26869                    }
26870                    let response = {
26871                        let bytes = common::to_bytes(body).await.unwrap_or_default();
26872                        let encoded = common::to_string(&bytes);
26873                        match serde_json::from_str(&encoded) {
26874                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26875                            Err(error) => {
26876                                dlg.response_json_decode_error(&encoded, &error);
26877                                return Err(common::Error::JsonDecodeError(
26878                                    encoded.to_string(),
26879                                    error,
26880                                ));
26881                            }
26882                        }
26883                    };
26884
26885                    dlg.finished(true);
26886                    return Ok(response);
26887                }
26888            }
26889        }
26890    }
26891
26892    ///
26893    /// Sets the *request* property to the given value.
26894    ///
26895    /// Even though the property as already been set when instantiating this call,
26896    /// we provide this method for API completeness.
26897    pub fn request(mut self, new_value: VacationSettings) -> UserSettingUpdateVacationCall<'a, C> {
26898        self._request = new_value;
26899        self
26900    }
26901    /// User's email address. The special value "me" can be used to indicate the authenticated user.
26902    ///
26903    /// Sets the *user id* path property to the given value.
26904    ///
26905    /// Even though the property as already been set when instantiating this call,
26906    /// we provide this method for API completeness.
26907    pub fn user_id(mut self, new_value: &str) -> UserSettingUpdateVacationCall<'a, C> {
26908        self._user_id = new_value.to_string();
26909        self
26910    }
26911    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26912    /// while executing the actual API request.
26913    ///
26914    /// ````text
26915    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
26916    /// ````
26917    ///
26918    /// Sets the *delegate* property to the given value.
26919    pub fn delegate(
26920        mut self,
26921        new_value: &'a mut dyn common::Delegate,
26922    ) -> UserSettingUpdateVacationCall<'a, C> {
26923        self._delegate = Some(new_value);
26924        self
26925    }
26926
26927    /// Set any additional parameter of the query string used in the request.
26928    /// It should be used to set parameters which are not yet available through their own
26929    /// setters.
26930    ///
26931    /// Please note that this method must not be used to set any of the known parameters
26932    /// which have their own setter method. If done anyway, the request will fail.
26933    ///
26934    /// # Additional Parameters
26935    ///
26936    /// * *$.xgafv* (query-string) - V1 error format.
26937    /// * *access_token* (query-string) - OAuth access token.
26938    /// * *alt* (query-string) - Data format for response.
26939    /// * *callback* (query-string) - JSONP
26940    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26941    /// * *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.
26942    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26943    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26944    /// * *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.
26945    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26946    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26947    pub fn param<T>(mut self, name: T, value: T) -> UserSettingUpdateVacationCall<'a, C>
26948    where
26949        T: AsRef<str>,
26950    {
26951        self._additional_params
26952            .insert(name.as_ref().to_string(), value.as_ref().to_string());
26953        self
26954    }
26955
26956    /// Identifies the authorization scope for the method you are building.
26957    ///
26958    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26959    /// [`Scope::SettingBasic`].
26960    ///
26961    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26962    /// tokens for more than one scope.
26963    ///
26964    /// Usually there is more than one suitable scope to authorize an operation, some of which may
26965    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26966    /// sufficient, a read-write scope will do as well.
26967    pub fn add_scope<St>(mut self, scope: St) -> UserSettingUpdateVacationCall<'a, C>
26968    where
26969        St: AsRef<str>,
26970    {
26971        self._scopes.insert(String::from(scope.as_ref()));
26972        self
26973    }
26974    /// Identifies the authorization scope(s) for the method you are building.
26975    ///
26976    /// See [`Self::add_scope()`] for details.
26977    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserSettingUpdateVacationCall<'a, C>
26978    where
26979        I: IntoIterator<Item = St>,
26980        St: AsRef<str>,
26981    {
26982        self._scopes
26983            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26984        self
26985    }
26986
26987    /// Removes all scopes, and no default scope will be used either.
26988    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26989    /// for details).
26990    pub fn clear_scopes(mut self) -> UserSettingUpdateVacationCall<'a, C> {
26991        self._scopes.clear();
26992        self
26993    }
26994}
26995
26996/// Immediately and permanently deletes the specified thread. Any messages that belong to the thread are also deleted. This operation cannot be undone. Prefer `threads.trash` instead.
26997///
26998/// A builder for the *threads.delete* method supported by a *user* resource.
26999/// It is not used directly, but through a [`UserMethods`] instance.
27000///
27001/// # Example
27002///
27003/// Instantiate a resource method builder
27004///
27005/// ```test_harness,no_run
27006/// # extern crate hyper;
27007/// # extern crate hyper_rustls;
27008/// # extern crate google_gmail1 as gmail1;
27009/// # async fn dox() {
27010/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27011///
27012/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27013/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27014/// #     .with_native_roots()
27015/// #     .unwrap()
27016/// #     .https_only()
27017/// #     .enable_http2()
27018/// #     .build();
27019///
27020/// # let executor = hyper_util::rt::TokioExecutor::new();
27021/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27022/// #     secret,
27023/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27024/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27025/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27026/// #     ),
27027/// # ).build().await.unwrap();
27028///
27029/// # let client = hyper_util::client::legacy::Client::builder(
27030/// #     hyper_util::rt::TokioExecutor::new()
27031/// # )
27032/// # .build(
27033/// #     hyper_rustls::HttpsConnectorBuilder::new()
27034/// #         .with_native_roots()
27035/// #         .unwrap()
27036/// #         .https_or_http()
27037/// #         .enable_http2()
27038/// #         .build()
27039/// # );
27040/// # let mut hub = Gmail::new(client, auth);
27041/// // You can configure optional parameters by calling the respective setters at will, and
27042/// // execute the final call using `doit()`.
27043/// // Values shown here are possibly random and not representative !
27044/// let result = hub.users().threads_delete("userId", "id")
27045///              .doit().await;
27046/// # }
27047/// ```
27048pub struct UserThreadDeleteCall<'a, C>
27049where
27050    C: 'a,
27051{
27052    hub: &'a Gmail<C>,
27053    _user_id: String,
27054    _id: String,
27055    _delegate: Option<&'a mut dyn common::Delegate>,
27056    _additional_params: HashMap<String, String>,
27057    _scopes: BTreeSet<String>,
27058}
27059
27060impl<'a, C> common::CallBuilder for UserThreadDeleteCall<'a, C> {}
27061
27062impl<'a, C> UserThreadDeleteCall<'a, C>
27063where
27064    C: common::Connector,
27065{
27066    /// Perform the operation you have build so far.
27067    pub async fn doit(mut self) -> common::Result<common::Response> {
27068        use std::borrow::Cow;
27069        use std::io::{Read, Seek};
27070
27071        use common::{url::Params, ToParts};
27072        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27073
27074        let mut dd = common::DefaultDelegate;
27075        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27076        dlg.begin(common::MethodInfo {
27077            id: "gmail.users.threads.delete",
27078            http_method: hyper::Method::DELETE,
27079        });
27080
27081        for &field in ["userId", "id"].iter() {
27082            if self._additional_params.contains_key(field) {
27083                dlg.finished(false);
27084                return Err(common::Error::FieldClash(field));
27085            }
27086        }
27087
27088        let mut params = Params::with_capacity(3 + self._additional_params.len());
27089        params.push("userId", self._user_id);
27090        params.push("id", self._id);
27091
27092        params.extend(self._additional_params.iter());
27093
27094        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads/{id}";
27095        if self._scopes.is_empty() {
27096            self._scopes.insert(Scope::Gmai.as_ref().to_string());
27097        }
27098
27099        #[allow(clippy::single_element_loop)]
27100        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
27101            url = params.uri_replacement(url, param_name, find_this, false);
27102        }
27103        {
27104            let to_remove = ["id", "userId"];
27105            params.remove_params(&to_remove);
27106        }
27107
27108        let url = params.parse_with_url(&url);
27109
27110        loop {
27111            let token = match self
27112                .hub
27113                .auth
27114                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27115                .await
27116            {
27117                Ok(token) => token,
27118                Err(e) => match dlg.token(e) {
27119                    Ok(token) => token,
27120                    Err(e) => {
27121                        dlg.finished(false);
27122                        return Err(common::Error::MissingToken(e));
27123                    }
27124                },
27125            };
27126            let mut req_result = {
27127                let client = &self.hub.client;
27128                dlg.pre_request();
27129                let mut req_builder = hyper::Request::builder()
27130                    .method(hyper::Method::DELETE)
27131                    .uri(url.as_str())
27132                    .header(USER_AGENT, self.hub._user_agent.clone());
27133
27134                if let Some(token) = token.as_ref() {
27135                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27136                }
27137
27138                let request = req_builder
27139                    .header(CONTENT_LENGTH, 0_u64)
27140                    .body(common::to_body::<String>(None));
27141
27142                client.request(request.unwrap()).await
27143            };
27144
27145            match req_result {
27146                Err(err) => {
27147                    if let common::Retry::After(d) = dlg.http_error(&err) {
27148                        sleep(d).await;
27149                        continue;
27150                    }
27151                    dlg.finished(false);
27152                    return Err(common::Error::HttpError(err));
27153                }
27154                Ok(res) => {
27155                    let (mut parts, body) = res.into_parts();
27156                    let mut body = common::Body::new(body);
27157                    if !parts.status.is_success() {
27158                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27159                        let error = serde_json::from_str(&common::to_string(&bytes));
27160                        let response = common::to_response(parts, bytes.into());
27161
27162                        if let common::Retry::After(d) =
27163                            dlg.http_failure(&response, error.as_ref().ok())
27164                        {
27165                            sleep(d).await;
27166                            continue;
27167                        }
27168
27169                        dlg.finished(false);
27170
27171                        return Err(match error {
27172                            Ok(value) => common::Error::BadRequest(value),
27173                            _ => common::Error::Failure(response),
27174                        });
27175                    }
27176                    let response = common::Response::from_parts(parts, body);
27177
27178                    dlg.finished(true);
27179                    return Ok(response);
27180                }
27181            }
27182        }
27183    }
27184
27185    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
27186    ///
27187    /// Sets the *user id* path property to the given value.
27188    ///
27189    /// Even though the property as already been set when instantiating this call,
27190    /// we provide this method for API completeness.
27191    pub fn user_id(mut self, new_value: &str) -> UserThreadDeleteCall<'a, C> {
27192        self._user_id = new_value.to_string();
27193        self
27194    }
27195    /// ID of the Thread to delete.
27196    ///
27197    /// Sets the *id* path property to the given value.
27198    ///
27199    /// Even though the property as already been set when instantiating this call,
27200    /// we provide this method for API completeness.
27201    pub fn id(mut self, new_value: &str) -> UserThreadDeleteCall<'a, C> {
27202        self._id = new_value.to_string();
27203        self
27204    }
27205    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27206    /// while executing the actual API request.
27207    ///
27208    /// ````text
27209    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27210    /// ````
27211    ///
27212    /// Sets the *delegate* property to the given value.
27213    pub fn delegate(
27214        mut self,
27215        new_value: &'a mut dyn common::Delegate,
27216    ) -> UserThreadDeleteCall<'a, C> {
27217        self._delegate = Some(new_value);
27218        self
27219    }
27220
27221    /// Set any additional parameter of the query string used in the request.
27222    /// It should be used to set parameters which are not yet available through their own
27223    /// setters.
27224    ///
27225    /// Please note that this method must not be used to set any of the known parameters
27226    /// which have their own setter method. If done anyway, the request will fail.
27227    ///
27228    /// # Additional Parameters
27229    ///
27230    /// * *$.xgafv* (query-string) - V1 error format.
27231    /// * *access_token* (query-string) - OAuth access token.
27232    /// * *alt* (query-string) - Data format for response.
27233    /// * *callback* (query-string) - JSONP
27234    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27235    /// * *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.
27236    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27237    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27238    /// * *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.
27239    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27240    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27241    pub fn param<T>(mut self, name: T, value: T) -> UserThreadDeleteCall<'a, C>
27242    where
27243        T: AsRef<str>,
27244    {
27245        self._additional_params
27246            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27247        self
27248    }
27249
27250    /// Identifies the authorization scope for the method you are building.
27251    ///
27252    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27253    /// [`Scope::Gmai`].
27254    ///
27255    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27256    /// tokens for more than one scope.
27257    ///
27258    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27259    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27260    /// sufficient, a read-write scope will do as well.
27261    pub fn add_scope<St>(mut self, scope: St) -> UserThreadDeleteCall<'a, C>
27262    where
27263        St: AsRef<str>,
27264    {
27265        self._scopes.insert(String::from(scope.as_ref()));
27266        self
27267    }
27268    /// Identifies the authorization scope(s) for the method you are building.
27269    ///
27270    /// See [`Self::add_scope()`] for details.
27271    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadDeleteCall<'a, C>
27272    where
27273        I: IntoIterator<Item = St>,
27274        St: AsRef<str>,
27275    {
27276        self._scopes
27277            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27278        self
27279    }
27280
27281    /// Removes all scopes, and no default scope will be used either.
27282    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27283    /// for details).
27284    pub fn clear_scopes(mut self) -> UserThreadDeleteCall<'a, C> {
27285        self._scopes.clear();
27286        self
27287    }
27288}
27289
27290/// Gets the specified thread.
27291///
27292/// A builder for the *threads.get* method supported by a *user* resource.
27293/// It is not used directly, but through a [`UserMethods`] instance.
27294///
27295/// # Example
27296///
27297/// Instantiate a resource method builder
27298///
27299/// ```test_harness,no_run
27300/// # extern crate hyper;
27301/// # extern crate hyper_rustls;
27302/// # extern crate google_gmail1 as gmail1;
27303/// # async fn dox() {
27304/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27305///
27306/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27307/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27308/// #     .with_native_roots()
27309/// #     .unwrap()
27310/// #     .https_only()
27311/// #     .enable_http2()
27312/// #     .build();
27313///
27314/// # let executor = hyper_util::rt::TokioExecutor::new();
27315/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27316/// #     secret,
27317/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27318/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27319/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27320/// #     ),
27321/// # ).build().await.unwrap();
27322///
27323/// # let client = hyper_util::client::legacy::Client::builder(
27324/// #     hyper_util::rt::TokioExecutor::new()
27325/// # )
27326/// # .build(
27327/// #     hyper_rustls::HttpsConnectorBuilder::new()
27328/// #         .with_native_roots()
27329/// #         .unwrap()
27330/// #         .https_or_http()
27331/// #         .enable_http2()
27332/// #         .build()
27333/// # );
27334/// # let mut hub = Gmail::new(client, auth);
27335/// // You can configure optional parameters by calling the respective setters at will, and
27336/// // execute the final call using `doit()`.
27337/// // Values shown here are possibly random and not representative !
27338/// let result = hub.users().threads_get("userId", "id")
27339///              .add_metadata_headers("takimata")
27340///              .format("Lorem")
27341///              .doit().await;
27342/// # }
27343/// ```
27344pub struct UserThreadGetCall<'a, C>
27345where
27346    C: 'a,
27347{
27348    hub: &'a Gmail<C>,
27349    _user_id: String,
27350    _id: String,
27351    _metadata_headers: Vec<String>,
27352    _format: Option<String>,
27353    _delegate: Option<&'a mut dyn common::Delegate>,
27354    _additional_params: HashMap<String, String>,
27355    _scopes: BTreeSet<String>,
27356}
27357
27358impl<'a, C> common::CallBuilder for UserThreadGetCall<'a, C> {}
27359
27360impl<'a, C> UserThreadGetCall<'a, C>
27361where
27362    C: common::Connector,
27363{
27364    /// Perform the operation you have build so far.
27365    pub async fn doit(mut self) -> common::Result<(common::Response, Thread)> {
27366        use std::borrow::Cow;
27367        use std::io::{Read, Seek};
27368
27369        use common::{url::Params, ToParts};
27370        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27371
27372        let mut dd = common::DefaultDelegate;
27373        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27374        dlg.begin(common::MethodInfo {
27375            id: "gmail.users.threads.get",
27376            http_method: hyper::Method::GET,
27377        });
27378
27379        for &field in ["alt", "userId", "id", "metadataHeaders", "format"].iter() {
27380            if self._additional_params.contains_key(field) {
27381                dlg.finished(false);
27382                return Err(common::Error::FieldClash(field));
27383            }
27384        }
27385
27386        let mut params = Params::with_capacity(6 + self._additional_params.len());
27387        params.push("userId", self._user_id);
27388        params.push("id", self._id);
27389        if !self._metadata_headers.is_empty() {
27390            for f in self._metadata_headers.iter() {
27391                params.push("metadataHeaders", f);
27392            }
27393        }
27394        if let Some(value) = self._format.as_ref() {
27395            params.push("format", value);
27396        }
27397
27398        params.extend(self._additional_params.iter());
27399
27400        params.push("alt", "json");
27401        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads/{id}";
27402        if self._scopes.is_empty() {
27403            self._scopes
27404                .insert(Scope::AddonCurrentMessageReadonly.as_ref().to_string());
27405        }
27406
27407        #[allow(clippy::single_element_loop)]
27408        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
27409            url = params.uri_replacement(url, param_name, find_this, false);
27410        }
27411        {
27412            let to_remove = ["id", "userId"];
27413            params.remove_params(&to_remove);
27414        }
27415
27416        let url = params.parse_with_url(&url);
27417
27418        loop {
27419            let token = match self
27420                .hub
27421                .auth
27422                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27423                .await
27424            {
27425                Ok(token) => token,
27426                Err(e) => match dlg.token(e) {
27427                    Ok(token) => token,
27428                    Err(e) => {
27429                        dlg.finished(false);
27430                        return Err(common::Error::MissingToken(e));
27431                    }
27432                },
27433            };
27434            let mut req_result = {
27435                let client = &self.hub.client;
27436                dlg.pre_request();
27437                let mut req_builder = hyper::Request::builder()
27438                    .method(hyper::Method::GET)
27439                    .uri(url.as_str())
27440                    .header(USER_AGENT, self.hub._user_agent.clone());
27441
27442                if let Some(token) = token.as_ref() {
27443                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27444                }
27445
27446                let request = req_builder
27447                    .header(CONTENT_LENGTH, 0_u64)
27448                    .body(common::to_body::<String>(None));
27449
27450                client.request(request.unwrap()).await
27451            };
27452
27453            match req_result {
27454                Err(err) => {
27455                    if let common::Retry::After(d) = dlg.http_error(&err) {
27456                        sleep(d).await;
27457                        continue;
27458                    }
27459                    dlg.finished(false);
27460                    return Err(common::Error::HttpError(err));
27461                }
27462                Ok(res) => {
27463                    let (mut parts, body) = res.into_parts();
27464                    let mut body = common::Body::new(body);
27465                    if !parts.status.is_success() {
27466                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27467                        let error = serde_json::from_str(&common::to_string(&bytes));
27468                        let response = common::to_response(parts, bytes.into());
27469
27470                        if let common::Retry::After(d) =
27471                            dlg.http_failure(&response, error.as_ref().ok())
27472                        {
27473                            sleep(d).await;
27474                            continue;
27475                        }
27476
27477                        dlg.finished(false);
27478
27479                        return Err(match error {
27480                            Ok(value) => common::Error::BadRequest(value),
27481                            _ => common::Error::Failure(response),
27482                        });
27483                    }
27484                    let response = {
27485                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27486                        let encoded = common::to_string(&bytes);
27487                        match serde_json::from_str(&encoded) {
27488                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27489                            Err(error) => {
27490                                dlg.response_json_decode_error(&encoded, &error);
27491                                return Err(common::Error::JsonDecodeError(
27492                                    encoded.to_string(),
27493                                    error,
27494                                ));
27495                            }
27496                        }
27497                    };
27498
27499                    dlg.finished(true);
27500                    return Ok(response);
27501                }
27502            }
27503        }
27504    }
27505
27506    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
27507    ///
27508    /// Sets the *user id* path property to the given value.
27509    ///
27510    /// Even though the property as already been set when instantiating this call,
27511    /// we provide this method for API completeness.
27512    pub fn user_id(mut self, new_value: &str) -> UserThreadGetCall<'a, C> {
27513        self._user_id = new_value.to_string();
27514        self
27515    }
27516    /// The ID of the thread to retrieve.
27517    ///
27518    /// Sets the *id* path property to the given value.
27519    ///
27520    /// Even though the property as already been set when instantiating this call,
27521    /// we provide this method for API completeness.
27522    pub fn id(mut self, new_value: &str) -> UserThreadGetCall<'a, C> {
27523        self._id = new_value.to_string();
27524        self
27525    }
27526    /// When given and format is METADATA, only include headers specified.
27527    ///
27528    /// Append the given value to the *metadata headers* query property.
27529    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
27530    pub fn add_metadata_headers(mut self, new_value: &str) -> UserThreadGetCall<'a, C> {
27531        self._metadata_headers.push(new_value.to_string());
27532        self
27533    }
27534    /// The format to return the messages in.
27535    ///
27536    /// Sets the *format* query property to the given value.
27537    pub fn format(mut self, new_value: &str) -> UserThreadGetCall<'a, C> {
27538        self._format = Some(new_value.to_string());
27539        self
27540    }
27541    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27542    /// while executing the actual API request.
27543    ///
27544    /// ````text
27545    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27546    /// ````
27547    ///
27548    /// Sets the *delegate* property to the given value.
27549    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserThreadGetCall<'a, C> {
27550        self._delegate = Some(new_value);
27551        self
27552    }
27553
27554    /// Set any additional parameter of the query string used in the request.
27555    /// It should be used to set parameters which are not yet available through their own
27556    /// setters.
27557    ///
27558    /// Please note that this method must not be used to set any of the known parameters
27559    /// which have their own setter method. If done anyway, the request will fail.
27560    ///
27561    /// # Additional Parameters
27562    ///
27563    /// * *$.xgafv* (query-string) - V1 error format.
27564    /// * *access_token* (query-string) - OAuth access token.
27565    /// * *alt* (query-string) - Data format for response.
27566    /// * *callback* (query-string) - JSONP
27567    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27568    /// * *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.
27569    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27570    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27571    /// * *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.
27572    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27573    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27574    pub fn param<T>(mut self, name: T, value: T) -> UserThreadGetCall<'a, C>
27575    where
27576        T: AsRef<str>,
27577    {
27578        self._additional_params
27579            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27580        self
27581    }
27582
27583    /// Identifies the authorization scope for the method you are building.
27584    ///
27585    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27586    /// [`Scope::AddonCurrentMessageReadonly`].
27587    ///
27588    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27589    /// tokens for more than one scope.
27590    ///
27591    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27592    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27593    /// sufficient, a read-write scope will do as well.
27594    pub fn add_scope<St>(mut self, scope: St) -> UserThreadGetCall<'a, C>
27595    where
27596        St: AsRef<str>,
27597    {
27598        self._scopes.insert(String::from(scope.as_ref()));
27599        self
27600    }
27601    /// Identifies the authorization scope(s) for the method you are building.
27602    ///
27603    /// See [`Self::add_scope()`] for details.
27604    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadGetCall<'a, C>
27605    where
27606        I: IntoIterator<Item = St>,
27607        St: AsRef<str>,
27608    {
27609        self._scopes
27610            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27611        self
27612    }
27613
27614    /// Removes all scopes, and no default scope will be used either.
27615    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27616    /// for details).
27617    pub fn clear_scopes(mut self) -> UserThreadGetCall<'a, C> {
27618        self._scopes.clear();
27619        self
27620    }
27621}
27622
27623/// Lists the threads in the user's mailbox.
27624///
27625/// A builder for the *threads.list* method supported by a *user* resource.
27626/// It is not used directly, but through a [`UserMethods`] instance.
27627///
27628/// # Example
27629///
27630/// Instantiate a resource method builder
27631///
27632/// ```test_harness,no_run
27633/// # extern crate hyper;
27634/// # extern crate hyper_rustls;
27635/// # extern crate google_gmail1 as gmail1;
27636/// # async fn dox() {
27637/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27638///
27639/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27640/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27641/// #     .with_native_roots()
27642/// #     .unwrap()
27643/// #     .https_only()
27644/// #     .enable_http2()
27645/// #     .build();
27646///
27647/// # let executor = hyper_util::rt::TokioExecutor::new();
27648/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27649/// #     secret,
27650/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27651/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
27652/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
27653/// #     ),
27654/// # ).build().await.unwrap();
27655///
27656/// # let client = hyper_util::client::legacy::Client::builder(
27657/// #     hyper_util::rt::TokioExecutor::new()
27658/// # )
27659/// # .build(
27660/// #     hyper_rustls::HttpsConnectorBuilder::new()
27661/// #         .with_native_roots()
27662/// #         .unwrap()
27663/// #         .https_or_http()
27664/// #         .enable_http2()
27665/// #         .build()
27666/// # );
27667/// # let mut hub = Gmail::new(client, auth);
27668/// // You can configure optional parameters by calling the respective setters at will, and
27669/// // execute the final call using `doit()`.
27670/// // Values shown here are possibly random and not representative !
27671/// let result = hub.users().threads_list("userId")
27672///              .q("At")
27673///              .page_token("dolor")
27674///              .max_results(79)
27675///              .add_label_ids("sit")
27676///              .include_spam_trash(false)
27677///              .doit().await;
27678/// # }
27679/// ```
27680pub struct UserThreadListCall<'a, C>
27681where
27682    C: 'a,
27683{
27684    hub: &'a Gmail<C>,
27685    _user_id: String,
27686    _q: Option<String>,
27687    _page_token: Option<String>,
27688    _max_results: Option<u32>,
27689    _label_ids: Vec<String>,
27690    _include_spam_trash: Option<bool>,
27691    _delegate: Option<&'a mut dyn common::Delegate>,
27692    _additional_params: HashMap<String, String>,
27693    _scopes: BTreeSet<String>,
27694}
27695
27696impl<'a, C> common::CallBuilder for UserThreadListCall<'a, C> {}
27697
27698impl<'a, C> UserThreadListCall<'a, C>
27699where
27700    C: common::Connector,
27701{
27702    /// Perform the operation you have build so far.
27703    pub async fn doit(mut self) -> common::Result<(common::Response, ListThreadsResponse)> {
27704        use std::borrow::Cow;
27705        use std::io::{Read, Seek};
27706
27707        use common::{url::Params, ToParts};
27708        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27709
27710        let mut dd = common::DefaultDelegate;
27711        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27712        dlg.begin(common::MethodInfo {
27713            id: "gmail.users.threads.list",
27714            http_method: hyper::Method::GET,
27715        });
27716
27717        for &field in [
27718            "alt",
27719            "userId",
27720            "q",
27721            "pageToken",
27722            "maxResults",
27723            "labelIds",
27724            "includeSpamTrash",
27725        ]
27726        .iter()
27727        {
27728            if self._additional_params.contains_key(field) {
27729                dlg.finished(false);
27730                return Err(common::Error::FieldClash(field));
27731            }
27732        }
27733
27734        let mut params = Params::with_capacity(8 + self._additional_params.len());
27735        params.push("userId", self._user_id);
27736        if let Some(value) = self._q.as_ref() {
27737            params.push("q", value);
27738        }
27739        if let Some(value) = self._page_token.as_ref() {
27740            params.push("pageToken", value);
27741        }
27742        if let Some(value) = self._max_results.as_ref() {
27743            params.push("maxResults", value.to_string());
27744        }
27745        if !self._label_ids.is_empty() {
27746            for f in self._label_ids.iter() {
27747                params.push("labelIds", f);
27748            }
27749        }
27750        if let Some(value) = self._include_spam_trash.as_ref() {
27751            params.push("includeSpamTrash", value.to_string());
27752        }
27753
27754        params.extend(self._additional_params.iter());
27755
27756        params.push("alt", "json");
27757        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads";
27758        if self._scopes.is_empty() {
27759            self._scopes.insert(Scope::Readonly.as_ref().to_string());
27760        }
27761
27762        #[allow(clippy::single_element_loop)]
27763        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
27764            url = params.uri_replacement(url, param_name, find_this, false);
27765        }
27766        {
27767            let to_remove = ["userId"];
27768            params.remove_params(&to_remove);
27769        }
27770
27771        let url = params.parse_with_url(&url);
27772
27773        loop {
27774            let token = match self
27775                .hub
27776                .auth
27777                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27778                .await
27779            {
27780                Ok(token) => token,
27781                Err(e) => match dlg.token(e) {
27782                    Ok(token) => token,
27783                    Err(e) => {
27784                        dlg.finished(false);
27785                        return Err(common::Error::MissingToken(e));
27786                    }
27787                },
27788            };
27789            let mut req_result = {
27790                let client = &self.hub.client;
27791                dlg.pre_request();
27792                let mut req_builder = hyper::Request::builder()
27793                    .method(hyper::Method::GET)
27794                    .uri(url.as_str())
27795                    .header(USER_AGENT, self.hub._user_agent.clone());
27796
27797                if let Some(token) = token.as_ref() {
27798                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27799                }
27800
27801                let request = req_builder
27802                    .header(CONTENT_LENGTH, 0_u64)
27803                    .body(common::to_body::<String>(None));
27804
27805                client.request(request.unwrap()).await
27806            };
27807
27808            match req_result {
27809                Err(err) => {
27810                    if let common::Retry::After(d) = dlg.http_error(&err) {
27811                        sleep(d).await;
27812                        continue;
27813                    }
27814                    dlg.finished(false);
27815                    return Err(common::Error::HttpError(err));
27816                }
27817                Ok(res) => {
27818                    let (mut parts, body) = res.into_parts();
27819                    let mut body = common::Body::new(body);
27820                    if !parts.status.is_success() {
27821                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27822                        let error = serde_json::from_str(&common::to_string(&bytes));
27823                        let response = common::to_response(parts, bytes.into());
27824
27825                        if let common::Retry::After(d) =
27826                            dlg.http_failure(&response, error.as_ref().ok())
27827                        {
27828                            sleep(d).await;
27829                            continue;
27830                        }
27831
27832                        dlg.finished(false);
27833
27834                        return Err(match error {
27835                            Ok(value) => common::Error::BadRequest(value),
27836                            _ => common::Error::Failure(response),
27837                        });
27838                    }
27839                    let response = {
27840                        let bytes = common::to_bytes(body).await.unwrap_or_default();
27841                        let encoded = common::to_string(&bytes);
27842                        match serde_json::from_str(&encoded) {
27843                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27844                            Err(error) => {
27845                                dlg.response_json_decode_error(&encoded, &error);
27846                                return Err(common::Error::JsonDecodeError(
27847                                    encoded.to_string(),
27848                                    error,
27849                                ));
27850                            }
27851                        }
27852                    };
27853
27854                    dlg.finished(true);
27855                    return Ok(response);
27856                }
27857            }
27858        }
27859    }
27860
27861    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
27862    ///
27863    /// Sets the *user id* path property to the given value.
27864    ///
27865    /// Even though the property as already been set when instantiating this call,
27866    /// we provide this method for API completeness.
27867    pub fn user_id(mut self, new_value: &str) -> UserThreadListCall<'a, C> {
27868        self._user_id = new_value.to_string();
27869        self
27870    }
27871    /// Only return threads matching the specified query. Supports the same query format as the Gmail search box. For example, `"from:someuser@example.com rfc822msgid: is:unread"`. Parameter cannot be used when accessing the api using the gmail.metadata scope.
27872    ///
27873    /// Sets the *q* query property to the given value.
27874    pub fn q(mut self, new_value: &str) -> UserThreadListCall<'a, C> {
27875        self._q = Some(new_value.to_string());
27876        self
27877    }
27878    /// Page token to retrieve a specific page of results in the list.
27879    ///
27880    /// Sets the *page token* query property to the given value.
27881    pub fn page_token(mut self, new_value: &str) -> UserThreadListCall<'a, C> {
27882        self._page_token = Some(new_value.to_string());
27883        self
27884    }
27885    /// Maximum number of threads to return. This field defaults to 100. The maximum allowed value for this field is 500.
27886    ///
27887    /// Sets the *max results* query property to the given value.
27888    pub fn max_results(mut self, new_value: u32) -> UserThreadListCall<'a, C> {
27889        self._max_results = Some(new_value);
27890        self
27891    }
27892    /// Only return threads with labels that match all of the specified label IDs.
27893    ///
27894    /// Append the given value to the *label ids* query property.
27895    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
27896    pub fn add_label_ids(mut self, new_value: &str) -> UserThreadListCall<'a, C> {
27897        self._label_ids.push(new_value.to_string());
27898        self
27899    }
27900    /// Include threads from `SPAM` and `TRASH` in the results.
27901    ///
27902    /// Sets the *include spam trash* query property to the given value.
27903    pub fn include_spam_trash(mut self, new_value: bool) -> UserThreadListCall<'a, C> {
27904        self._include_spam_trash = Some(new_value);
27905        self
27906    }
27907    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27908    /// while executing the actual API request.
27909    ///
27910    /// ````text
27911    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
27912    /// ````
27913    ///
27914    /// Sets the *delegate* property to the given value.
27915    pub fn delegate(
27916        mut self,
27917        new_value: &'a mut dyn common::Delegate,
27918    ) -> UserThreadListCall<'a, C> {
27919        self._delegate = Some(new_value);
27920        self
27921    }
27922
27923    /// Set any additional parameter of the query string used in the request.
27924    /// It should be used to set parameters which are not yet available through their own
27925    /// setters.
27926    ///
27927    /// Please note that this method must not be used to set any of the known parameters
27928    /// which have their own setter method. If done anyway, the request will fail.
27929    ///
27930    /// # Additional Parameters
27931    ///
27932    /// * *$.xgafv* (query-string) - V1 error format.
27933    /// * *access_token* (query-string) - OAuth access token.
27934    /// * *alt* (query-string) - Data format for response.
27935    /// * *callback* (query-string) - JSONP
27936    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27937    /// * *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.
27938    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27939    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27940    /// * *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.
27941    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27942    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27943    pub fn param<T>(mut self, name: T, value: T) -> UserThreadListCall<'a, C>
27944    where
27945        T: AsRef<str>,
27946    {
27947        self._additional_params
27948            .insert(name.as_ref().to_string(), value.as_ref().to_string());
27949        self
27950    }
27951
27952    /// Identifies the authorization scope for the method you are building.
27953    ///
27954    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27955    /// [`Scope::Readonly`].
27956    ///
27957    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27958    /// tokens for more than one scope.
27959    ///
27960    /// Usually there is more than one suitable scope to authorize an operation, some of which may
27961    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27962    /// sufficient, a read-write scope will do as well.
27963    pub fn add_scope<St>(mut self, scope: St) -> UserThreadListCall<'a, C>
27964    where
27965        St: AsRef<str>,
27966    {
27967        self._scopes.insert(String::from(scope.as_ref()));
27968        self
27969    }
27970    /// Identifies the authorization scope(s) for the method you are building.
27971    ///
27972    /// See [`Self::add_scope()`] for details.
27973    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadListCall<'a, C>
27974    where
27975        I: IntoIterator<Item = St>,
27976        St: AsRef<str>,
27977    {
27978        self._scopes
27979            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27980        self
27981    }
27982
27983    /// Removes all scopes, and no default scope will be used either.
27984    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27985    /// for details).
27986    pub fn clear_scopes(mut self) -> UserThreadListCall<'a, C> {
27987        self._scopes.clear();
27988        self
27989    }
27990}
27991
27992/// Modifies the labels applied to the thread. This applies to all messages in the thread.
27993///
27994/// A builder for the *threads.modify* method supported by a *user* resource.
27995/// It is not used directly, but through a [`UserMethods`] instance.
27996///
27997/// # Example
27998///
27999/// Instantiate a resource method builder
28000///
28001/// ```test_harness,no_run
28002/// # extern crate hyper;
28003/// # extern crate hyper_rustls;
28004/// # extern crate google_gmail1 as gmail1;
28005/// use gmail1::api::ModifyThreadRequest;
28006/// # async fn dox() {
28007/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28008///
28009/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28010/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28011/// #     .with_native_roots()
28012/// #     .unwrap()
28013/// #     .https_only()
28014/// #     .enable_http2()
28015/// #     .build();
28016///
28017/// # let executor = hyper_util::rt::TokioExecutor::new();
28018/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28019/// #     secret,
28020/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28021/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28022/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28023/// #     ),
28024/// # ).build().await.unwrap();
28025///
28026/// # let client = hyper_util::client::legacy::Client::builder(
28027/// #     hyper_util::rt::TokioExecutor::new()
28028/// # )
28029/// # .build(
28030/// #     hyper_rustls::HttpsConnectorBuilder::new()
28031/// #         .with_native_roots()
28032/// #         .unwrap()
28033/// #         .https_or_http()
28034/// #         .enable_http2()
28035/// #         .build()
28036/// # );
28037/// # let mut hub = Gmail::new(client, auth);
28038/// // As the method needs a request, you would usually fill it with the desired information
28039/// // into the respective structure. Some of the parts shown here might not be applicable !
28040/// // Values shown here are possibly random and not representative !
28041/// let mut req = ModifyThreadRequest::default();
28042///
28043/// // You can configure optional parameters by calling the respective setters at will, and
28044/// // execute the final call using `doit()`.
28045/// // Values shown here are possibly random and not representative !
28046/// let result = hub.users().threads_modify(req, "userId", "id")
28047///              .doit().await;
28048/// # }
28049/// ```
28050pub struct UserThreadModifyCall<'a, C>
28051where
28052    C: 'a,
28053{
28054    hub: &'a Gmail<C>,
28055    _request: ModifyThreadRequest,
28056    _user_id: String,
28057    _id: String,
28058    _delegate: Option<&'a mut dyn common::Delegate>,
28059    _additional_params: HashMap<String, String>,
28060    _scopes: BTreeSet<String>,
28061}
28062
28063impl<'a, C> common::CallBuilder for UserThreadModifyCall<'a, C> {}
28064
28065impl<'a, C> UserThreadModifyCall<'a, C>
28066where
28067    C: common::Connector,
28068{
28069    /// Perform the operation you have build so far.
28070    pub async fn doit(mut self) -> common::Result<(common::Response, Thread)> {
28071        use std::borrow::Cow;
28072        use std::io::{Read, Seek};
28073
28074        use common::{url::Params, ToParts};
28075        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28076
28077        let mut dd = common::DefaultDelegate;
28078        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28079        dlg.begin(common::MethodInfo {
28080            id: "gmail.users.threads.modify",
28081            http_method: hyper::Method::POST,
28082        });
28083
28084        for &field in ["alt", "userId", "id"].iter() {
28085            if self._additional_params.contains_key(field) {
28086                dlg.finished(false);
28087                return Err(common::Error::FieldClash(field));
28088            }
28089        }
28090
28091        let mut params = Params::with_capacity(5 + self._additional_params.len());
28092        params.push("userId", self._user_id);
28093        params.push("id", self._id);
28094
28095        params.extend(self._additional_params.iter());
28096
28097        params.push("alt", "json");
28098        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads/{id}/modify";
28099        if self._scopes.is_empty() {
28100            self._scopes.insert(Scope::Gmai.as_ref().to_string());
28101        }
28102
28103        #[allow(clippy::single_element_loop)]
28104        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
28105            url = params.uri_replacement(url, param_name, find_this, false);
28106        }
28107        {
28108            let to_remove = ["id", "userId"];
28109            params.remove_params(&to_remove);
28110        }
28111
28112        let url = params.parse_with_url(&url);
28113
28114        let mut json_mime_type = mime::APPLICATION_JSON;
28115        let mut request_value_reader = {
28116            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28117            common::remove_json_null_values(&mut value);
28118            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28119            serde_json::to_writer(&mut dst, &value).unwrap();
28120            dst
28121        };
28122        let request_size = request_value_reader
28123            .seek(std::io::SeekFrom::End(0))
28124            .unwrap();
28125        request_value_reader
28126            .seek(std::io::SeekFrom::Start(0))
28127            .unwrap();
28128
28129        loop {
28130            let token = match self
28131                .hub
28132                .auth
28133                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28134                .await
28135            {
28136                Ok(token) => token,
28137                Err(e) => match dlg.token(e) {
28138                    Ok(token) => token,
28139                    Err(e) => {
28140                        dlg.finished(false);
28141                        return Err(common::Error::MissingToken(e));
28142                    }
28143                },
28144            };
28145            request_value_reader
28146                .seek(std::io::SeekFrom::Start(0))
28147                .unwrap();
28148            let mut req_result = {
28149                let client = &self.hub.client;
28150                dlg.pre_request();
28151                let mut req_builder = hyper::Request::builder()
28152                    .method(hyper::Method::POST)
28153                    .uri(url.as_str())
28154                    .header(USER_AGENT, self.hub._user_agent.clone());
28155
28156                if let Some(token) = token.as_ref() {
28157                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28158                }
28159
28160                let request = req_builder
28161                    .header(CONTENT_TYPE, json_mime_type.to_string())
28162                    .header(CONTENT_LENGTH, request_size as u64)
28163                    .body(common::to_body(
28164                        request_value_reader.get_ref().clone().into(),
28165                    ));
28166
28167                client.request(request.unwrap()).await
28168            };
28169
28170            match req_result {
28171                Err(err) => {
28172                    if let common::Retry::After(d) = dlg.http_error(&err) {
28173                        sleep(d).await;
28174                        continue;
28175                    }
28176                    dlg.finished(false);
28177                    return Err(common::Error::HttpError(err));
28178                }
28179                Ok(res) => {
28180                    let (mut parts, body) = res.into_parts();
28181                    let mut body = common::Body::new(body);
28182                    if !parts.status.is_success() {
28183                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28184                        let error = serde_json::from_str(&common::to_string(&bytes));
28185                        let response = common::to_response(parts, bytes.into());
28186
28187                        if let common::Retry::After(d) =
28188                            dlg.http_failure(&response, error.as_ref().ok())
28189                        {
28190                            sleep(d).await;
28191                            continue;
28192                        }
28193
28194                        dlg.finished(false);
28195
28196                        return Err(match error {
28197                            Ok(value) => common::Error::BadRequest(value),
28198                            _ => common::Error::Failure(response),
28199                        });
28200                    }
28201                    let response = {
28202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28203                        let encoded = common::to_string(&bytes);
28204                        match serde_json::from_str(&encoded) {
28205                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28206                            Err(error) => {
28207                                dlg.response_json_decode_error(&encoded, &error);
28208                                return Err(common::Error::JsonDecodeError(
28209                                    encoded.to_string(),
28210                                    error,
28211                                ));
28212                            }
28213                        }
28214                    };
28215
28216                    dlg.finished(true);
28217                    return Ok(response);
28218                }
28219            }
28220        }
28221    }
28222
28223    ///
28224    /// Sets the *request* property to the given value.
28225    ///
28226    /// Even though the property as already been set when instantiating this call,
28227    /// we provide this method for API completeness.
28228    pub fn request(mut self, new_value: ModifyThreadRequest) -> UserThreadModifyCall<'a, C> {
28229        self._request = new_value;
28230        self
28231    }
28232    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
28233    ///
28234    /// Sets the *user id* path property to the given value.
28235    ///
28236    /// Even though the property as already been set when instantiating this call,
28237    /// we provide this method for API completeness.
28238    pub fn user_id(mut self, new_value: &str) -> UserThreadModifyCall<'a, C> {
28239        self._user_id = new_value.to_string();
28240        self
28241    }
28242    /// The ID of the thread to modify.
28243    ///
28244    /// Sets the *id* path property to the given value.
28245    ///
28246    /// Even though the property as already been set when instantiating this call,
28247    /// we provide this method for API completeness.
28248    pub fn id(mut self, new_value: &str) -> UserThreadModifyCall<'a, C> {
28249        self._id = new_value.to_string();
28250        self
28251    }
28252    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28253    /// while executing the actual API request.
28254    ///
28255    /// ````text
28256    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28257    /// ````
28258    ///
28259    /// Sets the *delegate* property to the given value.
28260    pub fn delegate(
28261        mut self,
28262        new_value: &'a mut dyn common::Delegate,
28263    ) -> UserThreadModifyCall<'a, C> {
28264        self._delegate = Some(new_value);
28265        self
28266    }
28267
28268    /// Set any additional parameter of the query string used in the request.
28269    /// It should be used to set parameters which are not yet available through their own
28270    /// setters.
28271    ///
28272    /// Please note that this method must not be used to set any of the known parameters
28273    /// which have their own setter method. If done anyway, the request will fail.
28274    ///
28275    /// # Additional Parameters
28276    ///
28277    /// * *$.xgafv* (query-string) - V1 error format.
28278    /// * *access_token* (query-string) - OAuth access token.
28279    /// * *alt* (query-string) - Data format for response.
28280    /// * *callback* (query-string) - JSONP
28281    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28282    /// * *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.
28283    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28284    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28285    /// * *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.
28286    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28287    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28288    pub fn param<T>(mut self, name: T, value: T) -> UserThreadModifyCall<'a, C>
28289    where
28290        T: AsRef<str>,
28291    {
28292        self._additional_params
28293            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28294        self
28295    }
28296
28297    /// Identifies the authorization scope for the method you are building.
28298    ///
28299    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28300    /// [`Scope::Gmai`].
28301    ///
28302    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28303    /// tokens for more than one scope.
28304    ///
28305    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28306    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28307    /// sufficient, a read-write scope will do as well.
28308    pub fn add_scope<St>(mut self, scope: St) -> UserThreadModifyCall<'a, C>
28309    where
28310        St: AsRef<str>,
28311    {
28312        self._scopes.insert(String::from(scope.as_ref()));
28313        self
28314    }
28315    /// Identifies the authorization scope(s) for the method you are building.
28316    ///
28317    /// See [`Self::add_scope()`] for details.
28318    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadModifyCall<'a, C>
28319    where
28320        I: IntoIterator<Item = St>,
28321        St: AsRef<str>,
28322    {
28323        self._scopes
28324            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28325        self
28326    }
28327
28328    /// Removes all scopes, and no default scope will be used either.
28329    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28330    /// for details).
28331    pub fn clear_scopes(mut self) -> UserThreadModifyCall<'a, C> {
28332        self._scopes.clear();
28333        self
28334    }
28335}
28336
28337/// Moves the specified thread to the trash. Any messages that belong to the thread are also moved to the trash.
28338///
28339/// A builder for the *threads.trash* method supported by a *user* resource.
28340/// It is not used directly, but through a [`UserMethods`] instance.
28341///
28342/// # Example
28343///
28344/// Instantiate a resource method builder
28345///
28346/// ```test_harness,no_run
28347/// # extern crate hyper;
28348/// # extern crate hyper_rustls;
28349/// # extern crate google_gmail1 as gmail1;
28350/// # async fn dox() {
28351/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28352///
28353/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28354/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28355/// #     .with_native_roots()
28356/// #     .unwrap()
28357/// #     .https_only()
28358/// #     .enable_http2()
28359/// #     .build();
28360///
28361/// # let executor = hyper_util::rt::TokioExecutor::new();
28362/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28363/// #     secret,
28364/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28365/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28366/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28367/// #     ),
28368/// # ).build().await.unwrap();
28369///
28370/// # let client = hyper_util::client::legacy::Client::builder(
28371/// #     hyper_util::rt::TokioExecutor::new()
28372/// # )
28373/// # .build(
28374/// #     hyper_rustls::HttpsConnectorBuilder::new()
28375/// #         .with_native_roots()
28376/// #         .unwrap()
28377/// #         .https_or_http()
28378/// #         .enable_http2()
28379/// #         .build()
28380/// # );
28381/// # let mut hub = Gmail::new(client, auth);
28382/// // You can configure optional parameters by calling the respective setters at will, and
28383/// // execute the final call using `doit()`.
28384/// // Values shown here are possibly random and not representative !
28385/// let result = hub.users().threads_trash("userId", "id")
28386///              .doit().await;
28387/// # }
28388/// ```
28389pub struct UserThreadTrashCall<'a, C>
28390where
28391    C: 'a,
28392{
28393    hub: &'a Gmail<C>,
28394    _user_id: String,
28395    _id: String,
28396    _delegate: Option<&'a mut dyn common::Delegate>,
28397    _additional_params: HashMap<String, String>,
28398    _scopes: BTreeSet<String>,
28399}
28400
28401impl<'a, C> common::CallBuilder for UserThreadTrashCall<'a, C> {}
28402
28403impl<'a, C> UserThreadTrashCall<'a, C>
28404where
28405    C: common::Connector,
28406{
28407    /// Perform the operation you have build so far.
28408    pub async fn doit(mut self) -> common::Result<(common::Response, Thread)> {
28409        use std::borrow::Cow;
28410        use std::io::{Read, Seek};
28411
28412        use common::{url::Params, ToParts};
28413        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28414
28415        let mut dd = common::DefaultDelegate;
28416        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28417        dlg.begin(common::MethodInfo {
28418            id: "gmail.users.threads.trash",
28419            http_method: hyper::Method::POST,
28420        });
28421
28422        for &field in ["alt", "userId", "id"].iter() {
28423            if self._additional_params.contains_key(field) {
28424                dlg.finished(false);
28425                return Err(common::Error::FieldClash(field));
28426            }
28427        }
28428
28429        let mut params = Params::with_capacity(4 + self._additional_params.len());
28430        params.push("userId", self._user_id);
28431        params.push("id", self._id);
28432
28433        params.extend(self._additional_params.iter());
28434
28435        params.push("alt", "json");
28436        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads/{id}/trash";
28437        if self._scopes.is_empty() {
28438            self._scopes.insert(Scope::Gmai.as_ref().to_string());
28439        }
28440
28441        #[allow(clippy::single_element_loop)]
28442        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
28443            url = params.uri_replacement(url, param_name, find_this, false);
28444        }
28445        {
28446            let to_remove = ["id", "userId"];
28447            params.remove_params(&to_remove);
28448        }
28449
28450        let url = params.parse_with_url(&url);
28451
28452        loop {
28453            let token = match self
28454                .hub
28455                .auth
28456                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28457                .await
28458            {
28459                Ok(token) => token,
28460                Err(e) => match dlg.token(e) {
28461                    Ok(token) => token,
28462                    Err(e) => {
28463                        dlg.finished(false);
28464                        return Err(common::Error::MissingToken(e));
28465                    }
28466                },
28467            };
28468            let mut req_result = {
28469                let client = &self.hub.client;
28470                dlg.pre_request();
28471                let mut req_builder = hyper::Request::builder()
28472                    .method(hyper::Method::POST)
28473                    .uri(url.as_str())
28474                    .header(USER_AGENT, self.hub._user_agent.clone());
28475
28476                if let Some(token) = token.as_ref() {
28477                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28478                }
28479
28480                let request = req_builder
28481                    .header(CONTENT_LENGTH, 0_u64)
28482                    .body(common::to_body::<String>(None));
28483
28484                client.request(request.unwrap()).await
28485            };
28486
28487            match req_result {
28488                Err(err) => {
28489                    if let common::Retry::After(d) = dlg.http_error(&err) {
28490                        sleep(d).await;
28491                        continue;
28492                    }
28493                    dlg.finished(false);
28494                    return Err(common::Error::HttpError(err));
28495                }
28496                Ok(res) => {
28497                    let (mut parts, body) = res.into_parts();
28498                    let mut body = common::Body::new(body);
28499                    if !parts.status.is_success() {
28500                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28501                        let error = serde_json::from_str(&common::to_string(&bytes));
28502                        let response = common::to_response(parts, bytes.into());
28503
28504                        if let common::Retry::After(d) =
28505                            dlg.http_failure(&response, error.as_ref().ok())
28506                        {
28507                            sleep(d).await;
28508                            continue;
28509                        }
28510
28511                        dlg.finished(false);
28512
28513                        return Err(match error {
28514                            Ok(value) => common::Error::BadRequest(value),
28515                            _ => common::Error::Failure(response),
28516                        });
28517                    }
28518                    let response = {
28519                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28520                        let encoded = common::to_string(&bytes);
28521                        match serde_json::from_str(&encoded) {
28522                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28523                            Err(error) => {
28524                                dlg.response_json_decode_error(&encoded, &error);
28525                                return Err(common::Error::JsonDecodeError(
28526                                    encoded.to_string(),
28527                                    error,
28528                                ));
28529                            }
28530                        }
28531                    };
28532
28533                    dlg.finished(true);
28534                    return Ok(response);
28535                }
28536            }
28537        }
28538    }
28539
28540    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
28541    ///
28542    /// Sets the *user id* path property to the given value.
28543    ///
28544    /// Even though the property as already been set when instantiating this call,
28545    /// we provide this method for API completeness.
28546    pub fn user_id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C> {
28547        self._user_id = new_value.to_string();
28548        self
28549    }
28550    /// The ID of the thread to Trash.
28551    ///
28552    /// Sets the *id* path property to the given value.
28553    ///
28554    /// Even though the property as already been set when instantiating this call,
28555    /// we provide this method for API completeness.
28556    pub fn id(mut self, new_value: &str) -> UserThreadTrashCall<'a, C> {
28557        self._id = new_value.to_string();
28558        self
28559    }
28560    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28561    /// while executing the actual API request.
28562    ///
28563    /// ````text
28564    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28565    /// ````
28566    ///
28567    /// Sets the *delegate* property to the given value.
28568    pub fn delegate(
28569        mut self,
28570        new_value: &'a mut dyn common::Delegate,
28571    ) -> UserThreadTrashCall<'a, C> {
28572        self._delegate = Some(new_value);
28573        self
28574    }
28575
28576    /// Set any additional parameter of the query string used in the request.
28577    /// It should be used to set parameters which are not yet available through their own
28578    /// setters.
28579    ///
28580    /// Please note that this method must not be used to set any of the known parameters
28581    /// which have their own setter method. If done anyway, the request will fail.
28582    ///
28583    /// # Additional Parameters
28584    ///
28585    /// * *$.xgafv* (query-string) - V1 error format.
28586    /// * *access_token* (query-string) - OAuth access token.
28587    /// * *alt* (query-string) - Data format for response.
28588    /// * *callback* (query-string) - JSONP
28589    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28590    /// * *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.
28591    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28592    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28593    /// * *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.
28594    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28595    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28596    pub fn param<T>(mut self, name: T, value: T) -> UserThreadTrashCall<'a, C>
28597    where
28598        T: AsRef<str>,
28599    {
28600        self._additional_params
28601            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28602        self
28603    }
28604
28605    /// Identifies the authorization scope for the method you are building.
28606    ///
28607    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28608    /// [`Scope::Gmai`].
28609    ///
28610    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28611    /// tokens for more than one scope.
28612    ///
28613    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28614    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28615    /// sufficient, a read-write scope will do as well.
28616    pub fn add_scope<St>(mut self, scope: St) -> UserThreadTrashCall<'a, C>
28617    where
28618        St: AsRef<str>,
28619    {
28620        self._scopes.insert(String::from(scope.as_ref()));
28621        self
28622    }
28623    /// Identifies the authorization scope(s) for the method you are building.
28624    ///
28625    /// See [`Self::add_scope()`] for details.
28626    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadTrashCall<'a, C>
28627    where
28628        I: IntoIterator<Item = St>,
28629        St: AsRef<str>,
28630    {
28631        self._scopes
28632            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28633        self
28634    }
28635
28636    /// Removes all scopes, and no default scope will be used either.
28637    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28638    /// for details).
28639    pub fn clear_scopes(mut self) -> UserThreadTrashCall<'a, C> {
28640        self._scopes.clear();
28641        self
28642    }
28643}
28644
28645/// Removes the specified thread from the trash. Any messages that belong to the thread are also removed from the trash.
28646///
28647/// A builder for the *threads.untrash* method supported by a *user* resource.
28648/// It is not used directly, but through a [`UserMethods`] instance.
28649///
28650/// # Example
28651///
28652/// Instantiate a resource method builder
28653///
28654/// ```test_harness,no_run
28655/// # extern crate hyper;
28656/// # extern crate hyper_rustls;
28657/// # extern crate google_gmail1 as gmail1;
28658/// # async fn dox() {
28659/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28660///
28661/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28662/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28663/// #     .with_native_roots()
28664/// #     .unwrap()
28665/// #     .https_only()
28666/// #     .enable_http2()
28667/// #     .build();
28668///
28669/// # let executor = hyper_util::rt::TokioExecutor::new();
28670/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28671/// #     secret,
28672/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28673/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28674/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28675/// #     ),
28676/// # ).build().await.unwrap();
28677///
28678/// # let client = hyper_util::client::legacy::Client::builder(
28679/// #     hyper_util::rt::TokioExecutor::new()
28680/// # )
28681/// # .build(
28682/// #     hyper_rustls::HttpsConnectorBuilder::new()
28683/// #         .with_native_roots()
28684/// #         .unwrap()
28685/// #         .https_or_http()
28686/// #         .enable_http2()
28687/// #         .build()
28688/// # );
28689/// # let mut hub = Gmail::new(client, auth);
28690/// // You can configure optional parameters by calling the respective setters at will, and
28691/// // execute the final call using `doit()`.
28692/// // Values shown here are possibly random and not representative !
28693/// let result = hub.users().threads_untrash("userId", "id")
28694///              .doit().await;
28695/// # }
28696/// ```
28697pub struct UserThreadUntrashCall<'a, C>
28698where
28699    C: 'a,
28700{
28701    hub: &'a Gmail<C>,
28702    _user_id: String,
28703    _id: String,
28704    _delegate: Option<&'a mut dyn common::Delegate>,
28705    _additional_params: HashMap<String, String>,
28706    _scopes: BTreeSet<String>,
28707}
28708
28709impl<'a, C> common::CallBuilder for UserThreadUntrashCall<'a, C> {}
28710
28711impl<'a, C> UserThreadUntrashCall<'a, C>
28712where
28713    C: common::Connector,
28714{
28715    /// Perform the operation you have build so far.
28716    pub async fn doit(mut self) -> common::Result<(common::Response, Thread)> {
28717        use std::borrow::Cow;
28718        use std::io::{Read, Seek};
28719
28720        use common::{url::Params, ToParts};
28721        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28722
28723        let mut dd = common::DefaultDelegate;
28724        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28725        dlg.begin(common::MethodInfo {
28726            id: "gmail.users.threads.untrash",
28727            http_method: hyper::Method::POST,
28728        });
28729
28730        for &field in ["alt", "userId", "id"].iter() {
28731            if self._additional_params.contains_key(field) {
28732                dlg.finished(false);
28733                return Err(common::Error::FieldClash(field));
28734            }
28735        }
28736
28737        let mut params = Params::with_capacity(4 + self._additional_params.len());
28738        params.push("userId", self._user_id);
28739        params.push("id", self._id);
28740
28741        params.extend(self._additional_params.iter());
28742
28743        params.push("alt", "json");
28744        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/threads/{id}/untrash";
28745        if self._scopes.is_empty() {
28746            self._scopes.insert(Scope::Gmai.as_ref().to_string());
28747        }
28748
28749        #[allow(clippy::single_element_loop)]
28750        for &(find_this, param_name) in [("{userId}", "userId"), ("{id}", "id")].iter() {
28751            url = params.uri_replacement(url, param_name, find_this, false);
28752        }
28753        {
28754            let to_remove = ["id", "userId"];
28755            params.remove_params(&to_remove);
28756        }
28757
28758        let url = params.parse_with_url(&url);
28759
28760        loop {
28761            let token = match self
28762                .hub
28763                .auth
28764                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28765                .await
28766            {
28767                Ok(token) => token,
28768                Err(e) => match dlg.token(e) {
28769                    Ok(token) => token,
28770                    Err(e) => {
28771                        dlg.finished(false);
28772                        return Err(common::Error::MissingToken(e));
28773                    }
28774                },
28775            };
28776            let mut req_result = {
28777                let client = &self.hub.client;
28778                dlg.pre_request();
28779                let mut req_builder = hyper::Request::builder()
28780                    .method(hyper::Method::POST)
28781                    .uri(url.as_str())
28782                    .header(USER_AGENT, self.hub._user_agent.clone());
28783
28784                if let Some(token) = token.as_ref() {
28785                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28786                }
28787
28788                let request = req_builder
28789                    .header(CONTENT_LENGTH, 0_u64)
28790                    .body(common::to_body::<String>(None));
28791
28792                client.request(request.unwrap()).await
28793            };
28794
28795            match req_result {
28796                Err(err) => {
28797                    if let common::Retry::After(d) = dlg.http_error(&err) {
28798                        sleep(d).await;
28799                        continue;
28800                    }
28801                    dlg.finished(false);
28802                    return Err(common::Error::HttpError(err));
28803                }
28804                Ok(res) => {
28805                    let (mut parts, body) = res.into_parts();
28806                    let mut body = common::Body::new(body);
28807                    if !parts.status.is_success() {
28808                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28809                        let error = serde_json::from_str(&common::to_string(&bytes));
28810                        let response = common::to_response(parts, bytes.into());
28811
28812                        if let common::Retry::After(d) =
28813                            dlg.http_failure(&response, error.as_ref().ok())
28814                        {
28815                            sleep(d).await;
28816                            continue;
28817                        }
28818
28819                        dlg.finished(false);
28820
28821                        return Err(match error {
28822                            Ok(value) => common::Error::BadRequest(value),
28823                            _ => common::Error::Failure(response),
28824                        });
28825                    }
28826                    let response = {
28827                        let bytes = common::to_bytes(body).await.unwrap_or_default();
28828                        let encoded = common::to_string(&bytes);
28829                        match serde_json::from_str(&encoded) {
28830                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28831                            Err(error) => {
28832                                dlg.response_json_decode_error(&encoded, &error);
28833                                return Err(common::Error::JsonDecodeError(
28834                                    encoded.to_string(),
28835                                    error,
28836                                ));
28837                            }
28838                        }
28839                    };
28840
28841                    dlg.finished(true);
28842                    return Ok(response);
28843                }
28844            }
28845        }
28846    }
28847
28848    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
28849    ///
28850    /// Sets the *user id* path property to the given value.
28851    ///
28852    /// Even though the property as already been set when instantiating this call,
28853    /// we provide this method for API completeness.
28854    pub fn user_id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C> {
28855        self._user_id = new_value.to_string();
28856        self
28857    }
28858    /// The ID of the thread to remove from Trash.
28859    ///
28860    /// Sets the *id* path property to the given value.
28861    ///
28862    /// Even though the property as already been set when instantiating this call,
28863    /// we provide this method for API completeness.
28864    pub fn id(mut self, new_value: &str) -> UserThreadUntrashCall<'a, C> {
28865        self._id = new_value.to_string();
28866        self
28867    }
28868    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28869    /// while executing the actual API request.
28870    ///
28871    /// ````text
28872    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
28873    /// ````
28874    ///
28875    /// Sets the *delegate* property to the given value.
28876    pub fn delegate(
28877        mut self,
28878        new_value: &'a mut dyn common::Delegate,
28879    ) -> UserThreadUntrashCall<'a, C> {
28880        self._delegate = Some(new_value);
28881        self
28882    }
28883
28884    /// Set any additional parameter of the query string used in the request.
28885    /// It should be used to set parameters which are not yet available through their own
28886    /// setters.
28887    ///
28888    /// Please note that this method must not be used to set any of the known parameters
28889    /// which have their own setter method. If done anyway, the request will fail.
28890    ///
28891    /// # Additional Parameters
28892    ///
28893    /// * *$.xgafv* (query-string) - V1 error format.
28894    /// * *access_token* (query-string) - OAuth access token.
28895    /// * *alt* (query-string) - Data format for response.
28896    /// * *callback* (query-string) - JSONP
28897    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28898    /// * *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.
28899    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28900    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28901    /// * *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.
28902    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28903    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28904    pub fn param<T>(mut self, name: T, value: T) -> UserThreadUntrashCall<'a, C>
28905    where
28906        T: AsRef<str>,
28907    {
28908        self._additional_params
28909            .insert(name.as_ref().to_string(), value.as_ref().to_string());
28910        self
28911    }
28912
28913    /// Identifies the authorization scope for the method you are building.
28914    ///
28915    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28916    /// [`Scope::Gmai`].
28917    ///
28918    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28919    /// tokens for more than one scope.
28920    ///
28921    /// Usually there is more than one suitable scope to authorize an operation, some of which may
28922    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28923    /// sufficient, a read-write scope will do as well.
28924    pub fn add_scope<St>(mut self, scope: St) -> UserThreadUntrashCall<'a, C>
28925    where
28926        St: AsRef<str>,
28927    {
28928        self._scopes.insert(String::from(scope.as_ref()));
28929        self
28930    }
28931    /// Identifies the authorization scope(s) for the method you are building.
28932    ///
28933    /// See [`Self::add_scope()`] for details.
28934    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserThreadUntrashCall<'a, C>
28935    where
28936        I: IntoIterator<Item = St>,
28937        St: AsRef<str>,
28938    {
28939        self._scopes
28940            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28941        self
28942    }
28943
28944    /// Removes all scopes, and no default scope will be used either.
28945    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28946    /// for details).
28947    pub fn clear_scopes(mut self) -> UserThreadUntrashCall<'a, C> {
28948        self._scopes.clear();
28949        self
28950    }
28951}
28952
28953/// Gets the current user's Gmail profile.
28954///
28955/// A builder for the *getProfile* method supported by a *user* resource.
28956/// It is not used directly, but through a [`UserMethods`] instance.
28957///
28958/// # Example
28959///
28960/// Instantiate a resource method builder
28961///
28962/// ```test_harness,no_run
28963/// # extern crate hyper;
28964/// # extern crate hyper_rustls;
28965/// # extern crate google_gmail1 as gmail1;
28966/// # async fn dox() {
28967/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28968///
28969/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28970/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28971/// #     .with_native_roots()
28972/// #     .unwrap()
28973/// #     .https_only()
28974/// #     .enable_http2()
28975/// #     .build();
28976///
28977/// # let executor = hyper_util::rt::TokioExecutor::new();
28978/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28979/// #     secret,
28980/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28981/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
28982/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
28983/// #     ),
28984/// # ).build().await.unwrap();
28985///
28986/// # let client = hyper_util::client::legacy::Client::builder(
28987/// #     hyper_util::rt::TokioExecutor::new()
28988/// # )
28989/// # .build(
28990/// #     hyper_rustls::HttpsConnectorBuilder::new()
28991/// #         .with_native_roots()
28992/// #         .unwrap()
28993/// #         .https_or_http()
28994/// #         .enable_http2()
28995/// #         .build()
28996/// # );
28997/// # let mut hub = Gmail::new(client, auth);
28998/// // You can configure optional parameters by calling the respective setters at will, and
28999/// // execute the final call using `doit()`.
29000/// // Values shown here are possibly random and not representative !
29001/// let result = hub.users().get_profile("userId")
29002///              .doit().await;
29003/// # }
29004/// ```
29005pub struct UserGetProfileCall<'a, C>
29006where
29007    C: 'a,
29008{
29009    hub: &'a Gmail<C>,
29010    _user_id: String,
29011    _delegate: Option<&'a mut dyn common::Delegate>,
29012    _additional_params: HashMap<String, String>,
29013    _scopes: BTreeSet<String>,
29014}
29015
29016impl<'a, C> common::CallBuilder for UserGetProfileCall<'a, C> {}
29017
29018impl<'a, C> UserGetProfileCall<'a, C>
29019where
29020    C: common::Connector,
29021{
29022    /// Perform the operation you have build so far.
29023    pub async fn doit(mut self) -> common::Result<(common::Response, Profile)> {
29024        use std::borrow::Cow;
29025        use std::io::{Read, Seek};
29026
29027        use common::{url::Params, ToParts};
29028        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29029
29030        let mut dd = common::DefaultDelegate;
29031        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29032        dlg.begin(common::MethodInfo {
29033            id: "gmail.users.getProfile",
29034            http_method: hyper::Method::GET,
29035        });
29036
29037        for &field in ["alt", "userId"].iter() {
29038            if self._additional_params.contains_key(field) {
29039                dlg.finished(false);
29040                return Err(common::Error::FieldClash(field));
29041            }
29042        }
29043
29044        let mut params = Params::with_capacity(3 + self._additional_params.len());
29045        params.push("userId", self._user_id);
29046
29047        params.extend(self._additional_params.iter());
29048
29049        params.push("alt", "json");
29050        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/profile";
29051        if self._scopes.is_empty() {
29052            self._scopes.insert(Scope::Readonly.as_ref().to_string());
29053        }
29054
29055        #[allow(clippy::single_element_loop)]
29056        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
29057            url = params.uri_replacement(url, param_name, find_this, false);
29058        }
29059        {
29060            let to_remove = ["userId"];
29061            params.remove_params(&to_remove);
29062        }
29063
29064        let url = params.parse_with_url(&url);
29065
29066        loop {
29067            let token = match self
29068                .hub
29069                .auth
29070                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29071                .await
29072            {
29073                Ok(token) => token,
29074                Err(e) => match dlg.token(e) {
29075                    Ok(token) => token,
29076                    Err(e) => {
29077                        dlg.finished(false);
29078                        return Err(common::Error::MissingToken(e));
29079                    }
29080                },
29081            };
29082            let mut req_result = {
29083                let client = &self.hub.client;
29084                dlg.pre_request();
29085                let mut req_builder = hyper::Request::builder()
29086                    .method(hyper::Method::GET)
29087                    .uri(url.as_str())
29088                    .header(USER_AGENT, self.hub._user_agent.clone());
29089
29090                if let Some(token) = token.as_ref() {
29091                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29092                }
29093
29094                let request = req_builder
29095                    .header(CONTENT_LENGTH, 0_u64)
29096                    .body(common::to_body::<String>(None));
29097
29098                client.request(request.unwrap()).await
29099            };
29100
29101            match req_result {
29102                Err(err) => {
29103                    if let common::Retry::After(d) = dlg.http_error(&err) {
29104                        sleep(d).await;
29105                        continue;
29106                    }
29107                    dlg.finished(false);
29108                    return Err(common::Error::HttpError(err));
29109                }
29110                Ok(res) => {
29111                    let (mut parts, body) = res.into_parts();
29112                    let mut body = common::Body::new(body);
29113                    if !parts.status.is_success() {
29114                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29115                        let error = serde_json::from_str(&common::to_string(&bytes));
29116                        let response = common::to_response(parts, bytes.into());
29117
29118                        if let common::Retry::After(d) =
29119                            dlg.http_failure(&response, error.as_ref().ok())
29120                        {
29121                            sleep(d).await;
29122                            continue;
29123                        }
29124
29125                        dlg.finished(false);
29126
29127                        return Err(match error {
29128                            Ok(value) => common::Error::BadRequest(value),
29129                            _ => common::Error::Failure(response),
29130                        });
29131                    }
29132                    let response = {
29133                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29134                        let encoded = common::to_string(&bytes);
29135                        match serde_json::from_str(&encoded) {
29136                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29137                            Err(error) => {
29138                                dlg.response_json_decode_error(&encoded, &error);
29139                                return Err(common::Error::JsonDecodeError(
29140                                    encoded.to_string(),
29141                                    error,
29142                                ));
29143                            }
29144                        }
29145                    };
29146
29147                    dlg.finished(true);
29148                    return Ok(response);
29149                }
29150            }
29151        }
29152    }
29153
29154    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
29155    ///
29156    /// Sets the *user id* path property to the given value.
29157    ///
29158    /// Even though the property as already been set when instantiating this call,
29159    /// we provide this method for API completeness.
29160    pub fn user_id(mut self, new_value: &str) -> UserGetProfileCall<'a, C> {
29161        self._user_id = new_value.to_string();
29162        self
29163    }
29164    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29165    /// while executing the actual API request.
29166    ///
29167    /// ````text
29168    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29169    /// ````
29170    ///
29171    /// Sets the *delegate* property to the given value.
29172    pub fn delegate(
29173        mut self,
29174        new_value: &'a mut dyn common::Delegate,
29175    ) -> UserGetProfileCall<'a, C> {
29176        self._delegate = Some(new_value);
29177        self
29178    }
29179
29180    /// Set any additional parameter of the query string used in the request.
29181    /// It should be used to set parameters which are not yet available through their own
29182    /// setters.
29183    ///
29184    /// Please note that this method must not be used to set any of the known parameters
29185    /// which have their own setter method. If done anyway, the request will fail.
29186    ///
29187    /// # Additional Parameters
29188    ///
29189    /// * *$.xgafv* (query-string) - V1 error format.
29190    /// * *access_token* (query-string) - OAuth access token.
29191    /// * *alt* (query-string) - Data format for response.
29192    /// * *callback* (query-string) - JSONP
29193    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29194    /// * *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.
29195    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29196    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29197    /// * *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.
29198    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29199    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29200    pub fn param<T>(mut self, name: T, value: T) -> UserGetProfileCall<'a, C>
29201    where
29202        T: AsRef<str>,
29203    {
29204        self._additional_params
29205            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29206        self
29207    }
29208
29209    /// Identifies the authorization scope for the method you are building.
29210    ///
29211    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29212    /// [`Scope::Readonly`].
29213    ///
29214    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29215    /// tokens for more than one scope.
29216    ///
29217    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29218    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29219    /// sufficient, a read-write scope will do as well.
29220    pub fn add_scope<St>(mut self, scope: St) -> UserGetProfileCall<'a, C>
29221    where
29222        St: AsRef<str>,
29223    {
29224        self._scopes.insert(String::from(scope.as_ref()));
29225        self
29226    }
29227    /// Identifies the authorization scope(s) for the method you are building.
29228    ///
29229    /// See [`Self::add_scope()`] for details.
29230    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserGetProfileCall<'a, C>
29231    where
29232        I: IntoIterator<Item = St>,
29233        St: AsRef<str>,
29234    {
29235        self._scopes
29236            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29237        self
29238    }
29239
29240    /// Removes all scopes, and no default scope will be used either.
29241    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29242    /// for details).
29243    pub fn clear_scopes(mut self) -> UserGetProfileCall<'a, C> {
29244        self._scopes.clear();
29245        self
29246    }
29247}
29248
29249/// Stop receiving push notifications for the given user mailbox.
29250///
29251/// A builder for the *stop* method supported by a *user* resource.
29252/// It is not used directly, but through a [`UserMethods`] instance.
29253///
29254/// # Example
29255///
29256/// Instantiate a resource method builder
29257///
29258/// ```test_harness,no_run
29259/// # extern crate hyper;
29260/// # extern crate hyper_rustls;
29261/// # extern crate google_gmail1 as gmail1;
29262/// # async fn dox() {
29263/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29264///
29265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29267/// #     .with_native_roots()
29268/// #     .unwrap()
29269/// #     .https_only()
29270/// #     .enable_http2()
29271/// #     .build();
29272///
29273/// # let executor = hyper_util::rt::TokioExecutor::new();
29274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29275/// #     secret,
29276/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29277/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29278/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29279/// #     ),
29280/// # ).build().await.unwrap();
29281///
29282/// # let client = hyper_util::client::legacy::Client::builder(
29283/// #     hyper_util::rt::TokioExecutor::new()
29284/// # )
29285/// # .build(
29286/// #     hyper_rustls::HttpsConnectorBuilder::new()
29287/// #         .with_native_roots()
29288/// #         .unwrap()
29289/// #         .https_or_http()
29290/// #         .enable_http2()
29291/// #         .build()
29292/// # );
29293/// # let mut hub = Gmail::new(client, auth);
29294/// // You can configure optional parameters by calling the respective setters at will, and
29295/// // execute the final call using `doit()`.
29296/// // Values shown here are possibly random and not representative !
29297/// let result = hub.users().stop("userId")
29298///              .doit().await;
29299/// # }
29300/// ```
29301pub struct UserStopCall<'a, C>
29302where
29303    C: 'a,
29304{
29305    hub: &'a Gmail<C>,
29306    _user_id: String,
29307    _delegate: Option<&'a mut dyn common::Delegate>,
29308    _additional_params: HashMap<String, String>,
29309    _scopes: BTreeSet<String>,
29310}
29311
29312impl<'a, C> common::CallBuilder for UserStopCall<'a, C> {}
29313
29314impl<'a, C> UserStopCall<'a, C>
29315where
29316    C: common::Connector,
29317{
29318    /// Perform the operation you have build so far.
29319    pub async fn doit(mut self) -> common::Result<common::Response> {
29320        use std::borrow::Cow;
29321        use std::io::{Read, Seek};
29322
29323        use common::{url::Params, ToParts};
29324        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29325
29326        let mut dd = common::DefaultDelegate;
29327        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29328        dlg.begin(common::MethodInfo {
29329            id: "gmail.users.stop",
29330            http_method: hyper::Method::POST,
29331        });
29332
29333        for &field in ["userId"].iter() {
29334            if self._additional_params.contains_key(field) {
29335                dlg.finished(false);
29336                return Err(common::Error::FieldClash(field));
29337            }
29338        }
29339
29340        let mut params = Params::with_capacity(2 + self._additional_params.len());
29341        params.push("userId", self._user_id);
29342
29343        params.extend(self._additional_params.iter());
29344
29345        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/stop";
29346        if self._scopes.is_empty() {
29347            self._scopes.insert(Scope::Readonly.as_ref().to_string());
29348        }
29349
29350        #[allow(clippy::single_element_loop)]
29351        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
29352            url = params.uri_replacement(url, param_name, find_this, false);
29353        }
29354        {
29355            let to_remove = ["userId"];
29356            params.remove_params(&to_remove);
29357        }
29358
29359        let url = params.parse_with_url(&url);
29360
29361        loop {
29362            let token = match self
29363                .hub
29364                .auth
29365                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29366                .await
29367            {
29368                Ok(token) => token,
29369                Err(e) => match dlg.token(e) {
29370                    Ok(token) => token,
29371                    Err(e) => {
29372                        dlg.finished(false);
29373                        return Err(common::Error::MissingToken(e));
29374                    }
29375                },
29376            };
29377            let mut req_result = {
29378                let client = &self.hub.client;
29379                dlg.pre_request();
29380                let mut req_builder = hyper::Request::builder()
29381                    .method(hyper::Method::POST)
29382                    .uri(url.as_str())
29383                    .header(USER_AGENT, self.hub._user_agent.clone());
29384
29385                if let Some(token) = token.as_ref() {
29386                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29387                }
29388
29389                let request = req_builder
29390                    .header(CONTENT_LENGTH, 0_u64)
29391                    .body(common::to_body::<String>(None));
29392
29393                client.request(request.unwrap()).await
29394            };
29395
29396            match req_result {
29397                Err(err) => {
29398                    if let common::Retry::After(d) = dlg.http_error(&err) {
29399                        sleep(d).await;
29400                        continue;
29401                    }
29402                    dlg.finished(false);
29403                    return Err(common::Error::HttpError(err));
29404                }
29405                Ok(res) => {
29406                    let (mut parts, body) = res.into_parts();
29407                    let mut body = common::Body::new(body);
29408                    if !parts.status.is_success() {
29409                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29410                        let error = serde_json::from_str(&common::to_string(&bytes));
29411                        let response = common::to_response(parts, bytes.into());
29412
29413                        if let common::Retry::After(d) =
29414                            dlg.http_failure(&response, error.as_ref().ok())
29415                        {
29416                            sleep(d).await;
29417                            continue;
29418                        }
29419
29420                        dlg.finished(false);
29421
29422                        return Err(match error {
29423                            Ok(value) => common::Error::BadRequest(value),
29424                            _ => common::Error::Failure(response),
29425                        });
29426                    }
29427                    let response = common::Response::from_parts(parts, body);
29428
29429                    dlg.finished(true);
29430                    return Ok(response);
29431                }
29432            }
29433        }
29434    }
29435
29436    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
29437    ///
29438    /// Sets the *user id* path property to the given value.
29439    ///
29440    /// Even though the property as already been set when instantiating this call,
29441    /// we provide this method for API completeness.
29442    pub fn user_id(mut self, new_value: &str) -> UserStopCall<'a, C> {
29443        self._user_id = new_value.to_string();
29444        self
29445    }
29446    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29447    /// while executing the actual API request.
29448    ///
29449    /// ````text
29450    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29451    /// ````
29452    ///
29453    /// Sets the *delegate* property to the given value.
29454    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserStopCall<'a, C> {
29455        self._delegate = Some(new_value);
29456        self
29457    }
29458
29459    /// Set any additional parameter of the query string used in the request.
29460    /// It should be used to set parameters which are not yet available through their own
29461    /// setters.
29462    ///
29463    /// Please note that this method must not be used to set any of the known parameters
29464    /// which have their own setter method. If done anyway, the request will fail.
29465    ///
29466    /// # Additional Parameters
29467    ///
29468    /// * *$.xgafv* (query-string) - V1 error format.
29469    /// * *access_token* (query-string) - OAuth access token.
29470    /// * *alt* (query-string) - Data format for response.
29471    /// * *callback* (query-string) - JSONP
29472    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29473    /// * *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.
29474    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29475    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29476    /// * *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.
29477    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29478    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29479    pub fn param<T>(mut self, name: T, value: T) -> UserStopCall<'a, C>
29480    where
29481        T: AsRef<str>,
29482    {
29483        self._additional_params
29484            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29485        self
29486    }
29487
29488    /// Identifies the authorization scope for the method you are building.
29489    ///
29490    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29491    /// [`Scope::Readonly`].
29492    ///
29493    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29494    /// tokens for more than one scope.
29495    ///
29496    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29497    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29498    /// sufficient, a read-write scope will do as well.
29499    pub fn add_scope<St>(mut self, scope: St) -> UserStopCall<'a, C>
29500    where
29501        St: AsRef<str>,
29502    {
29503        self._scopes.insert(String::from(scope.as_ref()));
29504        self
29505    }
29506    /// Identifies the authorization scope(s) for the method you are building.
29507    ///
29508    /// See [`Self::add_scope()`] for details.
29509    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserStopCall<'a, C>
29510    where
29511        I: IntoIterator<Item = St>,
29512        St: AsRef<str>,
29513    {
29514        self._scopes
29515            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29516        self
29517    }
29518
29519    /// Removes all scopes, and no default scope will be used either.
29520    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29521    /// for details).
29522    pub fn clear_scopes(mut self) -> UserStopCall<'a, C> {
29523        self._scopes.clear();
29524        self
29525    }
29526}
29527
29528/// Set up or update a push notification watch on the given user mailbox.
29529///
29530/// A builder for the *watch* method supported by a *user* resource.
29531/// It is not used directly, but through a [`UserMethods`] instance.
29532///
29533/// # Example
29534///
29535/// Instantiate a resource method builder
29536///
29537/// ```test_harness,no_run
29538/// # extern crate hyper;
29539/// # extern crate hyper_rustls;
29540/// # extern crate google_gmail1 as gmail1;
29541/// use gmail1::api::WatchRequest;
29542/// # async fn dox() {
29543/// # use gmail1::{Gmail, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29544///
29545/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29546/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29547/// #     .with_native_roots()
29548/// #     .unwrap()
29549/// #     .https_only()
29550/// #     .enable_http2()
29551/// #     .build();
29552///
29553/// # let executor = hyper_util::rt::TokioExecutor::new();
29554/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29555/// #     secret,
29556/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29557/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
29558/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
29559/// #     ),
29560/// # ).build().await.unwrap();
29561///
29562/// # let client = hyper_util::client::legacy::Client::builder(
29563/// #     hyper_util::rt::TokioExecutor::new()
29564/// # )
29565/// # .build(
29566/// #     hyper_rustls::HttpsConnectorBuilder::new()
29567/// #         .with_native_roots()
29568/// #         .unwrap()
29569/// #         .https_or_http()
29570/// #         .enable_http2()
29571/// #         .build()
29572/// # );
29573/// # let mut hub = Gmail::new(client, auth);
29574/// // As the method needs a request, you would usually fill it with the desired information
29575/// // into the respective structure. Some of the parts shown here might not be applicable !
29576/// // Values shown here are possibly random and not representative !
29577/// let mut req = WatchRequest::default();
29578///
29579/// // You can configure optional parameters by calling the respective setters at will, and
29580/// // execute the final call using `doit()`.
29581/// // Values shown here are possibly random and not representative !
29582/// let result = hub.users().watch(req, "userId")
29583///              .doit().await;
29584/// # }
29585/// ```
29586pub struct UserWatchCall<'a, C>
29587where
29588    C: 'a,
29589{
29590    hub: &'a Gmail<C>,
29591    _request: WatchRequest,
29592    _user_id: String,
29593    _delegate: Option<&'a mut dyn common::Delegate>,
29594    _additional_params: HashMap<String, String>,
29595    _scopes: BTreeSet<String>,
29596}
29597
29598impl<'a, C> common::CallBuilder for UserWatchCall<'a, C> {}
29599
29600impl<'a, C> UserWatchCall<'a, C>
29601where
29602    C: common::Connector,
29603{
29604    /// Perform the operation you have build so far.
29605    pub async fn doit(mut self) -> common::Result<(common::Response, WatchResponse)> {
29606        use std::borrow::Cow;
29607        use std::io::{Read, Seek};
29608
29609        use common::{url::Params, ToParts};
29610        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29611
29612        let mut dd = common::DefaultDelegate;
29613        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29614        dlg.begin(common::MethodInfo {
29615            id: "gmail.users.watch",
29616            http_method: hyper::Method::POST,
29617        });
29618
29619        for &field in ["alt", "userId"].iter() {
29620            if self._additional_params.contains_key(field) {
29621                dlg.finished(false);
29622                return Err(common::Error::FieldClash(field));
29623            }
29624        }
29625
29626        let mut params = Params::with_capacity(4 + self._additional_params.len());
29627        params.push("userId", self._user_id);
29628
29629        params.extend(self._additional_params.iter());
29630
29631        params.push("alt", "json");
29632        let mut url = self.hub._base_url.clone() + "gmail/v1/users/{userId}/watch";
29633        if self._scopes.is_empty() {
29634            self._scopes.insert(Scope::Readonly.as_ref().to_string());
29635        }
29636
29637        #[allow(clippy::single_element_loop)]
29638        for &(find_this, param_name) in [("{userId}", "userId")].iter() {
29639            url = params.uri_replacement(url, param_name, find_this, false);
29640        }
29641        {
29642            let to_remove = ["userId"];
29643            params.remove_params(&to_remove);
29644        }
29645
29646        let url = params.parse_with_url(&url);
29647
29648        let mut json_mime_type = mime::APPLICATION_JSON;
29649        let mut request_value_reader = {
29650            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
29651            common::remove_json_null_values(&mut value);
29652            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
29653            serde_json::to_writer(&mut dst, &value).unwrap();
29654            dst
29655        };
29656        let request_size = request_value_reader
29657            .seek(std::io::SeekFrom::End(0))
29658            .unwrap();
29659        request_value_reader
29660            .seek(std::io::SeekFrom::Start(0))
29661            .unwrap();
29662
29663        loop {
29664            let token = match self
29665                .hub
29666                .auth
29667                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29668                .await
29669            {
29670                Ok(token) => token,
29671                Err(e) => match dlg.token(e) {
29672                    Ok(token) => token,
29673                    Err(e) => {
29674                        dlg.finished(false);
29675                        return Err(common::Error::MissingToken(e));
29676                    }
29677                },
29678            };
29679            request_value_reader
29680                .seek(std::io::SeekFrom::Start(0))
29681                .unwrap();
29682            let mut req_result = {
29683                let client = &self.hub.client;
29684                dlg.pre_request();
29685                let mut req_builder = hyper::Request::builder()
29686                    .method(hyper::Method::POST)
29687                    .uri(url.as_str())
29688                    .header(USER_AGENT, self.hub._user_agent.clone());
29689
29690                if let Some(token) = token.as_ref() {
29691                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29692                }
29693
29694                let request = req_builder
29695                    .header(CONTENT_TYPE, json_mime_type.to_string())
29696                    .header(CONTENT_LENGTH, request_size as u64)
29697                    .body(common::to_body(
29698                        request_value_reader.get_ref().clone().into(),
29699                    ));
29700
29701                client.request(request.unwrap()).await
29702            };
29703
29704            match req_result {
29705                Err(err) => {
29706                    if let common::Retry::After(d) = dlg.http_error(&err) {
29707                        sleep(d).await;
29708                        continue;
29709                    }
29710                    dlg.finished(false);
29711                    return Err(common::Error::HttpError(err));
29712                }
29713                Ok(res) => {
29714                    let (mut parts, body) = res.into_parts();
29715                    let mut body = common::Body::new(body);
29716                    if !parts.status.is_success() {
29717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29718                        let error = serde_json::from_str(&common::to_string(&bytes));
29719                        let response = common::to_response(parts, bytes.into());
29720
29721                        if let common::Retry::After(d) =
29722                            dlg.http_failure(&response, error.as_ref().ok())
29723                        {
29724                            sleep(d).await;
29725                            continue;
29726                        }
29727
29728                        dlg.finished(false);
29729
29730                        return Err(match error {
29731                            Ok(value) => common::Error::BadRequest(value),
29732                            _ => common::Error::Failure(response),
29733                        });
29734                    }
29735                    let response = {
29736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
29737                        let encoded = common::to_string(&bytes);
29738                        match serde_json::from_str(&encoded) {
29739                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29740                            Err(error) => {
29741                                dlg.response_json_decode_error(&encoded, &error);
29742                                return Err(common::Error::JsonDecodeError(
29743                                    encoded.to_string(),
29744                                    error,
29745                                ));
29746                            }
29747                        }
29748                    };
29749
29750                    dlg.finished(true);
29751                    return Ok(response);
29752                }
29753            }
29754        }
29755    }
29756
29757    ///
29758    /// Sets the *request* property to the given value.
29759    ///
29760    /// Even though the property as already been set when instantiating this call,
29761    /// we provide this method for API completeness.
29762    pub fn request(mut self, new_value: WatchRequest) -> UserWatchCall<'a, C> {
29763        self._request = new_value;
29764        self
29765    }
29766    /// The user's email address. The special value `me` can be used to indicate the authenticated user.
29767    ///
29768    /// Sets the *user id* path property to the given value.
29769    ///
29770    /// Even though the property as already been set when instantiating this call,
29771    /// we provide this method for API completeness.
29772    pub fn user_id(mut self, new_value: &str) -> UserWatchCall<'a, C> {
29773        self._user_id = new_value.to_string();
29774        self
29775    }
29776    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29777    /// while executing the actual API request.
29778    ///
29779    /// ````text
29780    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
29781    /// ````
29782    ///
29783    /// Sets the *delegate* property to the given value.
29784    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> UserWatchCall<'a, C> {
29785        self._delegate = Some(new_value);
29786        self
29787    }
29788
29789    /// Set any additional parameter of the query string used in the request.
29790    /// It should be used to set parameters which are not yet available through their own
29791    /// setters.
29792    ///
29793    /// Please note that this method must not be used to set any of the known parameters
29794    /// which have their own setter method. If done anyway, the request will fail.
29795    ///
29796    /// # Additional Parameters
29797    ///
29798    /// * *$.xgafv* (query-string) - V1 error format.
29799    /// * *access_token* (query-string) - OAuth access token.
29800    /// * *alt* (query-string) - Data format for response.
29801    /// * *callback* (query-string) - JSONP
29802    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29803    /// * *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.
29804    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29805    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29806    /// * *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.
29807    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29808    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29809    pub fn param<T>(mut self, name: T, value: T) -> UserWatchCall<'a, C>
29810    where
29811        T: AsRef<str>,
29812    {
29813        self._additional_params
29814            .insert(name.as_ref().to_string(), value.as_ref().to_string());
29815        self
29816    }
29817
29818    /// Identifies the authorization scope for the method you are building.
29819    ///
29820    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29821    /// [`Scope::Readonly`].
29822    ///
29823    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29824    /// tokens for more than one scope.
29825    ///
29826    /// Usually there is more than one suitable scope to authorize an operation, some of which may
29827    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29828    /// sufficient, a read-write scope will do as well.
29829    pub fn add_scope<St>(mut self, scope: St) -> UserWatchCall<'a, C>
29830    where
29831        St: AsRef<str>,
29832    {
29833        self._scopes.insert(String::from(scope.as_ref()));
29834        self
29835    }
29836    /// Identifies the authorization scope(s) for the method you are building.
29837    ///
29838    /// See [`Self::add_scope()`] for details.
29839    pub fn add_scopes<I, St>(mut self, scopes: I) -> UserWatchCall<'a, C>
29840    where
29841        I: IntoIterator<Item = St>,
29842        St: AsRef<str>,
29843    {
29844        self._scopes
29845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29846        self
29847    }
29848
29849    /// Removes all scopes, and no default scope will be used either.
29850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29851    /// for details).
29852    pub fn clear_scopes(mut self) -> UserWatchCall<'a, C> {
29853        self._scopes.clear();
29854        self
29855    }
29856}