google_mirror1/
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    /// View your location
17    GlasLocation,
18
19    /// View and manage your Glass timeline
20    GlasTimeline,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::GlasLocation => "https://www.googleapis.com/auth/glass.location",
27            Scope::GlasTimeline => "https://www.googleapis.com/auth/glass.timeline",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::GlasLocation
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all Mirror related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_mirror1 as mirror1;
53/// use mirror1::api::Contact;
54/// use mirror1::{Result, Error};
55/// # async fn dox() {
56/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = Mirror::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = Contact::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.contacts().patch(req, "id")
103///              .doit().await;
104///
105/// match result {
106///     Err(e) => match e {
107///         // The Error enum provides details about what exactly happened.
108///         // You can also just use its `Debug`, `Display` or `Error` traits
109///          Error::HttpError(_)
110///         |Error::Io(_)
111///         |Error::MissingAPIKey
112///         |Error::MissingToken(_)
113///         |Error::Cancelled
114///         |Error::UploadSizeLimitExceeded(_, _)
115///         |Error::Failure(_)
116///         |Error::BadRequest(_)
117///         |Error::FieldClash(_)
118///         |Error::JsonDecodeError(_, _) => println!("{}", e),
119///     },
120///     Ok(res) => println!("Success: {:?}", res),
121/// }
122/// # }
123/// ```
124#[derive(Clone)]
125pub struct Mirror<C> {
126    pub client: common::Client<C>,
127    pub auth: Box<dyn common::GetToken>,
128    _user_agent: String,
129    _base_url: String,
130    _root_url: String,
131}
132
133impl<C> common::Hub for Mirror<C> {}
134
135impl<'a, C> Mirror<C> {
136    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Mirror<C> {
137        Mirror {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://www.googleapis.com/mirror/v1/".to_string(),
142            _root_url: "https://www.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn accounts(&'a self) -> AccountMethods<'a, C> {
147        AccountMethods { hub: self }
148    }
149    pub fn contacts(&'a self) -> ContactMethods<'a, C> {
150        ContactMethods { hub: self }
151    }
152    pub fn locations(&'a self) -> LocationMethods<'a, C> {
153        LocationMethods { hub: self }
154    }
155    pub fn settings(&'a self) -> SettingMethods<'a, C> {
156        SettingMethods { hub: self }
157    }
158    pub fn subscriptions(&'a self) -> SubscriptionMethods<'a, C> {
159        SubscriptionMethods { hub: self }
160    }
161    pub fn timeline(&'a self) -> TimelineMethods<'a, C> {
162        TimelineMethods { hub: self }
163    }
164
165    /// Set the user-agent header field to use in all requests to the server.
166    /// It defaults to `google-api-rust-client/7.0.0`.
167    ///
168    /// Returns the previously set user-agent.
169    pub fn user_agent(&mut self, agent_name: String) -> String {
170        std::mem::replace(&mut self._user_agent, agent_name)
171    }
172
173    /// Set the base url to use in all requests to the server.
174    /// It defaults to `https://www.googleapis.com/mirror/v1/`.
175    ///
176    /// Returns the previously set base url.
177    pub fn base_url(&mut self, new_base_url: String) -> String {
178        std::mem::replace(&mut self._base_url, new_base_url)
179    }
180
181    /// Set the root url to use in all requests to the server.
182    /// It defaults to `https://www.googleapis.com/`.
183    ///
184    /// Returns the previously set root url.
185    pub fn root_url(&mut self, new_root_url: String) -> String {
186        std::mem::replace(&mut self._root_url, new_root_url)
187    }
188}
189
190// ############
191// SCHEMAS ###
192// ##########
193/// Represents an account passed into the Account Manager on Glass.
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [insert accounts](AccountInsertCall) (request|response)
201#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
202#[serde_with::serde_as]
203#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
204pub struct Account {
205    /// no description provided
206    #[serde(rename = "authTokens")]
207    pub auth_tokens: Option<Vec<AuthToken>>,
208    /// no description provided
209    pub features: Option<Vec<String>>,
210    /// no description provided
211    pub password: Option<String>,
212    /// no description provided
213    #[serde(rename = "userData")]
214    pub user_data: Option<Vec<UserData>>,
215}
216
217impl common::RequestValue for Account {}
218impl common::Resource for Account {}
219impl common::ResponseResult for Account {}
220
221/// Represents media content, such as a photo, that can be attached to a timeline item.
222///
223/// # Activities
224///
225/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
226/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
227///
228/// * [attachments get timeline](TimelineAttachmentGetCall) (response)
229/// * [attachments insert timeline](TimelineAttachmentInsertCall) (response)
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct Attachment {
234    /// The MIME type of the attachment.
235    #[serde(rename = "contentType")]
236    pub content_type: Option<String>,
237    /// The URL for the content.
238    #[serde(rename = "contentUrl")]
239    pub content_url: Option<String>,
240    /// The ID of the attachment.
241    pub id: Option<String>,
242    /// Indicates that the contentUrl is not available because the attachment content is still being processed. If the caller wishes to retrieve the content, it should try again later.
243    #[serde(rename = "isProcessingContent")]
244    pub is_processing_content: Option<bool>,
245}
246
247impl common::ResponseResult for Attachment {}
248
249/// A list of Attachments. This is the response from the server to GET requests on the attachments collection.
250///
251/// # Activities
252///
253/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
254/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
255///
256/// * [attachments list timeline](TimelineAttachmentListCall) (response)
257#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
258#[serde_with::serde_as]
259#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
260pub struct AttachmentsListResponse {
261    /// The list of attachments.
262    pub items: Option<Vec<Attachment>>,
263    /// The type of resource. This is always mirror#attachmentsList.
264    pub kind: Option<String>,
265}
266
267impl common::ResponseResult for AttachmentsListResponse {}
268
269/// There is no detailed description.
270///
271/// This type is not used in any activity, and only used as *part* of another schema.
272///
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct AuthToken {
277    /// no description provided
278    #[serde(rename = "authToken")]
279    pub auth_token: Option<String>,
280    /// no description provided
281    #[serde(rename = "type")]
282    pub type_: Option<String>,
283}
284
285impl common::Part for AuthToken {}
286
287/// A single menu command that is part of a Contact.
288///
289/// This type is not used in any activity, and only used as *part* of another schema.
290///
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct Command {
295    /// The type of operation this command corresponds to. Allowed values are:  
296    /// - TAKE_A_NOTE - Shares a timeline item with the transcription of user speech from the "Take a note" voice menu command.  
297    /// - POST_AN_UPDATE - Shares a timeline item with the transcription of user speech from the "Post an update" voice menu command.
298    #[serde(rename = "type")]
299    pub type_: Option<String>,
300}
301
302impl common::Part for Command {}
303
304/// A person or group that can be used as a creator or a contact.
305///
306/// # Activities
307///
308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
310///
311/// * [delete contacts](ContactDeleteCall) (none)
312/// * [get contacts](ContactGetCall) (response)
313/// * [insert contacts](ContactInsertCall) (request|response)
314/// * [list contacts](ContactListCall) (none)
315/// * [patch contacts](ContactPatchCall) (request|response)
316/// * [update contacts](ContactUpdateCall) (request|response)
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct Contact {
321    /// A list of voice menu commands that a contact can handle. Glass shows up to three contacts for each voice menu command. If there are more than that, the three contacts with the highest priority are shown for that particular command.
322    #[serde(rename = "acceptCommands")]
323    pub accept_commands: Option<Vec<Command>>,
324    /// A list of MIME types that a contact supports. The contact will be shown to the user if any of its acceptTypes matches any of the types of the attachments on the item. If no acceptTypes are given, the contact will be shown for all items.
325    #[serde(rename = "acceptTypes")]
326    pub accept_types: Option<Vec<String>>,
327    /// The name to display for this contact.
328    #[serde(rename = "displayName")]
329    pub display_name: Option<String>,
330    /// An ID for this contact. This is generated by the application and is treated as an opaque token.
331    pub id: Option<String>,
332    /// Set of image URLs to display for a contact. Most contacts will have a single image, but a "group" contact may include up to 8 image URLs and they will be resized and cropped into a mosaic on the client.
333    #[serde(rename = "imageUrls")]
334    pub image_urls: Option<Vec<String>>,
335    /// The type of resource. This is always mirror#contact.
336    pub kind: Option<String>,
337    /// Primary phone number for the contact. This can be a fully-qualified number, with country calling code and area code, or a local number.
338    #[serde(rename = "phoneNumber")]
339    pub phone_number: Option<String>,
340    /// Priority for the contact to determine ordering in a list of contacts. Contacts with higher priorities will be shown before ones with lower priorities.
341    pub priority: Option<u32>,
342    /// A list of sharing features that a contact can handle. Allowed values are:  
343    /// - ADD_CAPTION
344    #[serde(rename = "sharingFeatures")]
345    pub sharing_features: Option<Vec<String>>,
346    /// The ID of the application that created this contact. This is populated by the API
347    pub source: Option<String>,
348    /// Name of this contact as it should be pronounced. If this contact's name must be spoken as part of a voice disambiguation menu, this name is used as the expected pronunciation. This is useful for contact names with unpronounceable characters or whose display spelling is otherwise not phonetic.
349    #[serde(rename = "speakableName")]
350    pub speakable_name: Option<String>,
351    /// The type for this contact. This is used for sorting in UIs. Allowed values are:  
352    /// - INDIVIDUAL - Represents a single person. This is the default.
353    /// - GROUP - Represents more than a single person.
354    #[serde(rename = "type")]
355    pub type_: Option<String>,
356}
357
358impl common::RequestValue for Contact {}
359impl common::Resource for Contact {}
360impl common::ResponseResult for Contact {}
361
362/// A list of Contacts representing contacts. This is the response from the server to GET requests on the contacts collection.
363///
364/// # Activities
365///
366/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
367/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
368///
369/// * [list contacts](ContactListCall) (response)
370#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
371#[serde_with::serde_as]
372#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
373pub struct ContactsListResponse {
374    /// Contact list.
375    pub items: Option<Vec<Contact>>,
376    /// The type of resource. This is always mirror#contacts.
377    pub kind: Option<String>,
378}
379
380impl common::ResponseResult for ContactsListResponse {}
381
382/// A geographic location that can be associated with a timeline item.
383///
384/// # Activities
385///
386/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
387/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
388///
389/// * [get locations](LocationGetCall) (response)
390/// * [list locations](LocationListCall) (none)
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct Location {
395    /// The accuracy of the location fix in meters.
396    pub accuracy: Option<f64>,
397    /// The full address of the location.
398    pub address: Option<String>,
399    /// The name to be displayed. This may be a business name or a user-defined place, such as "Home".
400    #[serde(rename = "displayName")]
401    pub display_name: Option<String>,
402    /// The ID of the location.
403    pub id: Option<String>,
404    /// The type of resource. This is always mirror#location.
405    pub kind: Option<String>,
406    /// The latitude, in degrees.
407    pub latitude: Option<f64>,
408    /// The longitude, in degrees.
409    pub longitude: Option<f64>,
410    /// The time at which this location was captured, formatted according to RFC 3339.
411    pub timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
412}
413
414impl common::Resource for Location {}
415impl common::ResponseResult for Location {}
416
417/// A list of Locations. This is the response from the server to GET requests on the locations collection.
418///
419/// # Activities
420///
421/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
422/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
423///
424/// * [list locations](LocationListCall) (response)
425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
426#[serde_with::serde_as]
427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
428pub struct LocationsListResponse {
429    /// The list of locations.
430    pub items: Option<Vec<Location>>,
431    /// The type of resource. This is always mirror#locationsList.
432    pub kind: Option<String>,
433}
434
435impl common::ResponseResult for LocationsListResponse {}
436
437/// A custom menu item that can be presented to the user by a timeline item.
438///
439/// This type is not used in any activity, and only used as *part* of another schema.
440///
441#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
442#[serde_with::serde_as]
443#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
444pub struct MenuItem {
445    /// Controls the behavior when the user picks the menu option. Allowed values are:  
446    /// - CUSTOM - Custom action set by the service. When the user selects this menuItem, the API triggers a notification to your callbackUrl with the userActions.type set to CUSTOM and the userActions.payload set to the ID of this menu item. This is the default value.
447    /// - Built-in actions:  
448    /// - REPLY - Initiate a reply to the timeline item using the voice recording UI. The creator attribute must be set in the timeline item for this menu to be available.
449    /// - REPLY_ALL - Same behavior as REPLY. The original timeline item's recipients will be added to the reply item.
450    /// - DELETE - Delete the timeline item.
451    /// - SHARE - Share the timeline item with the available contacts.
452    /// - READ_ALOUD - Read the timeline item's speakableText aloud; if this field is not set, read the text field; if none of those fields are set, this menu item is ignored.
453    /// - GET_MEDIA_INPUT - Allow users to provide media payloads to Glassware from a menu item (currently, only transcribed text from voice input is supported). Subscribe to notifications when users invoke this menu item to receive the timeline item ID. Retrieve the media from the timeline item in the payload property.
454    /// - VOICE_CALL - Initiate a phone call using the timeline item's creator.phoneNumber attribute as recipient.
455    /// - NAVIGATE - Navigate to the timeline item's location.
456    /// - TOGGLE_PINNED - Toggle the isPinned state of the timeline item.
457    /// - OPEN_URI - Open the payload of the menu item in the browser.
458    /// - PLAY_VIDEO - Open the payload of the menu item in the Glass video player.
459    /// - SEND_MESSAGE - Initiate sending a message to the timeline item's creator:  
460    /// - If the creator.phoneNumber is set and Glass is connected to an Android phone, the message is an SMS.
461    /// - Otherwise, if the creator.email is set, the message is an email.
462    pub action: Option<String>,
463    /// The ContextualMenus.Command associated with this MenuItem (e.g. READ_ALOUD). The voice label for this command will be displayed in the voice menu and the touch label will be displayed in the touch menu. Note that the default menu value's display name will be overriden if you specify this property. Values that do not correspond to a ContextualMenus.Command name will be ignored.
464    pub contextual_command: Option<String>,
465    /// The ID for this menu item. This is generated by the application and is treated as an opaque token.
466    pub id: Option<String>,
467    /// A generic payload whose meaning changes depending on this MenuItem's action.  
468    /// - When the action is OPEN_URI, the payload is the URL of the website to view.
469    /// - When the action is PLAY_VIDEO, the payload is the streaming URL of the video
470    /// - When the action is GET_MEDIA_INPUT, the payload is the text transcription of a user's speech input
471    pub payload: Option<String>,
472    /// If set to true on a CUSTOM menu item, that item will be removed from the menu after it is selected.
473    #[serde(rename = "removeWhenSelected")]
474    pub remove_when_selected: Option<bool>,
475    /// For CUSTOM items, a list of values controlling the appearance of the menu item in each of its states. A value for the DEFAULT state must be provided. If the PENDING or CONFIRMED states are missing, they will not be shown.
476    pub values: Option<Vec<MenuValue>>,
477}
478
479impl common::Part for MenuItem {}
480
481/// A single value that is part of a MenuItem.
482///
483/// This type is not used in any activity, and only used as *part* of another schema.
484///
485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
486#[serde_with::serde_as]
487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
488pub struct MenuValue {
489    /// The name to display for the menu item. If you specify this property for a built-in menu item, the default contextual voice command for that menu item is not shown.
490    #[serde(rename = "displayName")]
491    pub display_name: Option<String>,
492    /// URL of an icon to display with the menu item.
493    #[serde(rename = "iconUrl")]
494    pub icon_url: Option<String>,
495    /// The state that this value applies to. Allowed values are:  
496    /// - DEFAULT - Default value shown when displayed in the menuItems list.
497    /// - PENDING - Value shown when the menuItem has been selected by the user but can still be cancelled.
498    /// - CONFIRMED - Value shown when the menuItem has been selected by the user and can no longer be cancelled.
499    pub state: Option<String>,
500}
501
502impl common::Part for MenuValue {}
503
504/// A notification delivered by the API.
505///
506/// This type is not used in any activity, and only used as *part* of another schema.
507///
508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
509#[serde_with::serde_as]
510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
511pub struct Notification {
512    /// The collection that generated the notification.
513    pub collection: Option<String>,
514    /// The ID of the item that generated the notification.
515    #[serde(rename = "itemId")]
516    pub item_id: Option<String>,
517    /// The type of operation that generated the notification.
518    pub operation: Option<String>,
519    /// A list of actions taken by the user that triggered the notification.
520    #[serde(rename = "userActions")]
521    pub user_actions: Option<Vec<UserAction>>,
522    /// The user token provided by the service when it subscribed for notifications.
523    #[serde(rename = "userToken")]
524    pub user_token: Option<String>,
525    /// The secret verify token provided by the service when it subscribed for notifications.
526    #[serde(rename = "verifyToken")]
527    pub verify_token: Option<String>,
528}
529
530impl common::Part for Notification {}
531
532/// Controls how notifications for a timeline item are presented to the user.
533///
534/// This type is not used in any activity, and only used as *part* of another schema.
535///
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct NotificationConfig {
540    /// The time at which the notification should be delivered.
541    #[serde(rename = "deliveryTime")]
542    pub delivery_time: Option<chrono::DateTime<chrono::offset::Utc>>,
543    /// Describes how important the notification is. Allowed values are:  
544    /// - DEFAULT - Notifications of default importance. A chime will be played to alert users.
545    pub level: Option<String>,
546}
547
548impl common::Part for NotificationConfig {}
549
550/// A setting for Glass.
551///
552/// # Activities
553///
554/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
555/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
556///
557/// * [get settings](SettingGetCall) (response)
558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
559#[serde_with::serde_as]
560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
561pub struct Setting {
562    /// The setting's ID. The following IDs are valid:  
563    /// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.  
564    /// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
565    pub id: Option<String>,
566    /// The type of resource. This is always mirror#setting.
567    pub kind: Option<String>,
568    /// The setting value, as a string.
569    pub value: Option<String>,
570}
571
572impl common::Resource for Setting {}
573impl common::ResponseResult for Setting {}
574
575/// A subscription to events on a collection.
576///
577/// # Activities
578///
579/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
580/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
581///
582/// * [delete subscriptions](SubscriptionDeleteCall) (none)
583/// * [insert subscriptions](SubscriptionInsertCall) (request|response)
584/// * [list subscriptions](SubscriptionListCall) (none)
585/// * [update subscriptions](SubscriptionUpdateCall) (request|response)
586#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
587#[serde_with::serde_as]
588#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
589pub struct Subscription {
590    /// The URL where notifications should be delivered (must start with https://).
591    #[serde(rename = "callbackUrl")]
592    pub callback_url: Option<String>,
593    /// The collection to subscribe to. Allowed values are:  
594    /// - timeline - Changes in the timeline including insertion, deletion, and updates.
595    /// - locations - Location updates.
596    /// - settings - Settings updates.
597    pub collection: Option<String>,
598    /// The ID of the subscription.
599    pub id: Option<String>,
600    /// The type of resource. This is always mirror#subscription.
601    pub kind: Option<String>,
602    /// Container object for notifications. This is not populated in the Subscription resource.
603    pub notification: Option<Notification>,
604    /// A list of operations that should be subscribed to. An empty list indicates that all operations on the collection should be subscribed to. Allowed values are:  
605    /// - UPDATE - The item has been updated.
606    /// - INSERT - A new item has been inserted.
607    /// - DELETE - The item has been deleted.
608    /// - MENU_ACTION - A custom menu item has been triggered by the user.
609    pub operation: Option<Vec<String>>,
610    /// The time at which this subscription was last modified, formatted according to RFC 3339.
611    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
612    /// An opaque token sent to the subscriber in notifications so that it can determine the ID of the user.
613    #[serde(rename = "userToken")]
614    pub user_token: Option<String>,
615    /// A secret token sent to the subscriber in notifications so that it can verify that the notification was generated by Google.
616    #[serde(rename = "verifyToken")]
617    pub verify_token: Option<String>,
618}
619
620impl common::RequestValue for Subscription {}
621impl common::Resource for Subscription {}
622impl common::ResponseResult for Subscription {}
623
624/// A list of Subscriptions. This is the response from the server to GET requests on the subscription collection.
625///
626/// # Activities
627///
628/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
629/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
630///
631/// * [list subscriptions](SubscriptionListCall) (response)
632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
633#[serde_with::serde_as]
634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
635pub struct SubscriptionsListResponse {
636    /// The list of subscriptions.
637    pub items: Option<Vec<Subscription>>,
638    /// The type of resource. This is always mirror#subscriptionsList.
639    pub kind: Option<String>,
640}
641
642impl common::ResponseResult for SubscriptionsListResponse {}
643
644/// Each item in the user’s timeline is represented as a TimelineItem JSON structure, described below.
645///
646/// # Activities
647///
648/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
649/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
650///
651/// * [get timeline](TimelineGetCall) (response)
652/// * [insert timeline](TimelineInsertCall) (request|response)
653/// * [patch timeline](TimelinePatchCall) (request|response)
654/// * [update timeline](TimelineUpdateCall) (request|response)
655#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
656#[serde_with::serde_as]
657#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
658pub struct TimelineItem {
659    /// A list of media attachments associated with this item. As a convenience, you can refer to attachments in your HTML payloads with the attachment or cid scheme. For example:  
660    /// - attachment: <img src="attachment:attachment_index"> where attachment_index is the 0-based index of this array.
661    /// - cid: <img src="cid:attachment_id"> where attachment_id is the ID of the attachment.
662    pub attachments: Option<Vec<Attachment>>,
663    /// The bundle ID for this item. Services can specify a bundleId to group many items together. They appear under a single top-level item on the device.
664    #[serde(rename = "bundleId")]
665    pub bundle_id: Option<String>,
666    /// A canonical URL pointing to the canonical/high quality version of the data represented by the timeline item.
667    #[serde(rename = "canonicalUrl")]
668    pub canonical_url: Option<String>,
669    /// The time at which this item was created, formatted according to RFC 3339.
670    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
671    /// The user or group that created this item.
672    pub creator: Option<Contact>,
673    /// The time that should be displayed when this item is viewed in the timeline, formatted according to RFC 3339. This user's timeline is sorted chronologically on display time, so this will also determine where the item is displayed in the timeline. If not set by the service, the display time defaults to the updated time.
674    #[serde(rename = "displayTime")]
675    pub display_time: Option<chrono::DateTime<chrono::offset::Utc>>,
676    /// ETag for this item.
677    pub etag: Option<String>,
678    /// HTML content for this item. If both text and html are provided for an item, the html will be rendered in the timeline.
679    /// Allowed HTML elements - You can use these elements in your timeline cards.
680    ///  
681    /// - Headers: h1, h2, h3, h4, h5, h6
682    /// - Images: img
683    /// - Lists: li, ol, ul
684    /// - HTML5 semantics: article, aside, details, figure, figcaption, footer, header, nav, section, summary, time
685    /// - Structural: blockquote, br, div, hr, p, span
686    /// - Style: b, big, center, em, i, u, s, small, strike, strong, style, sub, sup
687    /// - Tables: table, tbody, td, tfoot, th, thead, tr  
688    /// Blocked HTML elements: These elements and their contents are removed from HTML payloads.
689    ///  
690    /// - Document headers: head, title
691    /// - Embeds: audio, embed, object, source, video
692    /// - Frames: frame, frameset
693    /// - Scripting: applet, script  
694    /// Other elements: Any elements that aren't listed are removed, but their contents are preserved.
695    pub html: Option<String>,
696    /// The ID of the timeline item. This is unique within a user's timeline.
697    pub id: Option<String>,
698    /// If this item was generated as a reply to another item, this field will be set to the ID of the item being replied to. This can be used to attach a reply to the appropriate conversation or post.
699    #[serde(rename = "inReplyTo")]
700    pub in_reply_to: Option<String>,
701    /// Whether this item is a bundle cover.
702    ///
703    /// If an item is marked as a bundle cover, it will be the entry point to the bundle of items that have the same bundleId as that item. It will be shown only on the main timeline — not within the opened bundle.
704    ///
705    /// On the main timeline, items that are shown are:  
706    /// - Items that have isBundleCover set to true  
707    /// - Items that do not have a bundleId  In a bundle sub-timeline, items that are shown are:  
708    /// - Items that have the bundleId in question AND isBundleCover set to false
709    #[serde(rename = "isBundleCover")]
710    pub is_bundle_cover: Option<bool>,
711    /// When true, indicates this item is deleted, and only the ID property is set.
712    #[serde(rename = "isDeleted")]
713    pub is_deleted: Option<bool>,
714    /// When true, indicates this item is pinned, which means it's grouped alongside "active" items like navigation and hangouts, on the opposite side of the home screen from historical (non-pinned) timeline items. You can allow the user to toggle the value of this property with the TOGGLE_PINNED built-in menu item.
715    #[serde(rename = "isPinned")]
716    pub is_pinned: Option<bool>,
717    /// The type of resource. This is always mirror#timelineItem.
718    pub kind: Option<String>,
719    /// The geographic location associated with this item.
720    pub location: Option<Location>,
721    /// A list of menu items that will be presented to the user when this item is selected in the timeline.
722    #[serde(rename = "menuItems")]
723    pub menu_items: Option<Vec<MenuItem>>,
724    /// Controls how notifications for this item are presented on the device. If this is missing, no notification will be generated.
725    pub notification: Option<NotificationConfig>,
726    /// For pinned items, this determines the order in which the item is displayed in the timeline, with a higher score appearing closer to the clock. Note: setting this field is currently not supported.
727    #[serde(rename = "pinScore")]
728    pub pin_score: Option<i32>,
729    /// A list of users or groups that this item has been shared with.
730    pub recipients: Option<Vec<Contact>>,
731    /// A URL that can be used to retrieve this item.
732    #[serde(rename = "selfLink")]
733    pub self_link: Option<String>,
734    /// Opaque string you can use to map a timeline item to data in your own service.
735    #[serde(rename = "sourceItemId")]
736    pub source_item_id: Option<String>,
737    /// The speakable version of the content of this item. Along with the READ_ALOUD menu item, use this field to provide text that would be clearer when read aloud, or to provide extended information to what is displayed visually on Glass.
738    ///
739    /// Glassware should also specify the speakableType field, which will be spoken before this text in cases where the additional context is useful, for example when the user requests that the item be read aloud following a notification.
740    #[serde(rename = "speakableText")]
741    pub speakable_text: Option<String>,
742    /// A speakable description of the type of this item. This will be announced to the user prior to reading the content of the item in cases where the additional context is useful, for example when the user requests that the item be read aloud following a notification.
743    ///
744    /// This should be a short, simple noun phrase such as "Email", "Text message", or "Daily Planet News Update".
745    ///
746    /// Glassware are encouraged to populate this field for every timeline item, even if the item does not contain speakableText or text so that the user can learn the type of the item without looking at the screen.
747    #[serde(rename = "speakableType")]
748    pub speakable_type: Option<String>,
749    /// Text content of this item.
750    pub text: Option<String>,
751    /// The title of this item.
752    pub title: Option<String>,
753    /// The time at which this item was last modified, formatted according to RFC 3339.
754    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
755}
756
757impl common::RequestValue for TimelineItem {}
758impl common::ResponseResult for TimelineItem {}
759
760/// A list of timeline items. This is the response from the server to GET requests on the timeline collection.
761///
762/// # Activities
763///
764/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
765/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
766///
767/// * [list timeline](TimelineListCall) (response)
768#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
769#[serde_with::serde_as]
770#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
771pub struct TimelineListResponse {
772    /// Items in the timeline.
773    pub items: Option<Vec<TimelineItem>>,
774    /// The type of resource. This is always mirror#timeline.
775    pub kind: Option<String>,
776    /// The next page token. Provide this as the pageToken parameter in the request to retrieve the next page of results.
777    #[serde(rename = "nextPageToken")]
778    pub next_page_token: Option<String>,
779}
780
781impl common::ResponseResult for TimelineListResponse {}
782
783/// Represents an action taken by the user that triggered a notification.
784///
785/// This type is not used in any activity, and only used as *part* of another schema.
786///
787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
788#[serde_with::serde_as]
789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
790pub struct UserAction {
791    /// An optional payload for the action.
792    ///
793    /// For actions of type CUSTOM, this is the ID of the custom menu item that was selected.
794    pub payload: Option<String>,
795    /// The type of action. The value of this can be:  
796    /// - SHARE - the user shared an item.
797    /// - REPLY - the user replied to an item.
798    /// - REPLY_ALL - the user replied to all recipients of an item.
799    /// - CUSTOM - the user selected a custom menu item on the timeline item.
800    /// - DELETE - the user deleted the item.
801    /// - PIN - the user pinned the item.
802    /// - UNPIN - the user unpinned the item.
803    /// - LAUNCH - the user initiated a voice command.  In the future, additional types may be added. UserActions with unrecognized types should be ignored.
804    #[serde(rename = "type")]
805    pub type_: Option<String>,
806}
807
808impl common::Part for UserAction {}
809
810/// There is no detailed description.
811///
812/// This type is not used in any activity, and only used as *part* of another schema.
813///
814#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
815#[serde_with::serde_as]
816#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
817pub struct UserData {
818    /// no description provided
819    pub key: Option<String>,
820    /// no description provided
821    pub value: Option<String>,
822}
823
824impl common::Part for UserData {}
825
826// ###################
827// MethodBuilders ###
828// #################
829
830/// A builder providing access to all methods supported on *account* resources.
831/// It is not used directly, but through the [`Mirror`] hub.
832///
833/// # Example
834///
835/// Instantiate a resource builder
836///
837/// ```test_harness,no_run
838/// extern crate hyper;
839/// extern crate hyper_rustls;
840/// extern crate google_mirror1 as mirror1;
841///
842/// # async fn dox() {
843/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
844///
845/// let secret: yup_oauth2::ApplicationSecret = Default::default();
846/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
847///     .with_native_roots()
848///     .unwrap()
849///     .https_only()
850///     .enable_http2()
851///     .build();
852///
853/// let executor = hyper_util::rt::TokioExecutor::new();
854/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
855///     secret,
856///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
857///     yup_oauth2::client::CustomHyperClientBuilder::from(
858///         hyper_util::client::legacy::Client::builder(executor).build(connector),
859///     ),
860/// ).build().await.unwrap();
861///
862/// let client = hyper_util::client::legacy::Client::builder(
863///     hyper_util::rt::TokioExecutor::new()
864/// )
865/// .build(
866///     hyper_rustls::HttpsConnectorBuilder::new()
867///         .with_native_roots()
868///         .unwrap()
869///         .https_or_http()
870///         .enable_http2()
871///         .build()
872/// );
873/// let mut hub = Mirror::new(client, auth);
874/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
875/// // like `insert(...)`
876/// // to build up your call.
877/// let rb = hub.accounts();
878/// # }
879/// ```
880pub struct AccountMethods<'a, C>
881where
882    C: 'a,
883{
884    hub: &'a Mirror<C>,
885}
886
887impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
888
889impl<'a, C> AccountMethods<'a, C> {
890    /// Create a builder to help you perform the following task:
891    ///
892    /// Inserts a new account for a user
893    ///
894    /// # Arguments
895    ///
896    /// * `request` - No description provided.
897    /// * `userToken` - The ID for the user.
898    /// * `accountType` - Account type to be passed to Android Account Manager.
899    /// * `accountName` - The name of the account to be passed to the Android Account Manager.
900    pub fn insert(
901        &self,
902        request: Account,
903        user_token: &str,
904        account_type: &str,
905        account_name: &str,
906    ) -> AccountInsertCall<'a, C> {
907        AccountInsertCall {
908            hub: self.hub,
909            _request: request,
910            _user_token: user_token.to_string(),
911            _account_type: account_type.to_string(),
912            _account_name: account_name.to_string(),
913            _delegate: Default::default(),
914            _additional_params: Default::default(),
915        }
916    }
917}
918
919/// A builder providing access to all methods supported on *contact* resources.
920/// It is not used directly, but through the [`Mirror`] hub.
921///
922/// # Example
923///
924/// Instantiate a resource builder
925///
926/// ```test_harness,no_run
927/// extern crate hyper;
928/// extern crate hyper_rustls;
929/// extern crate google_mirror1 as mirror1;
930///
931/// # async fn dox() {
932/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
933///
934/// let secret: yup_oauth2::ApplicationSecret = Default::default();
935/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
936///     .with_native_roots()
937///     .unwrap()
938///     .https_only()
939///     .enable_http2()
940///     .build();
941///
942/// let executor = hyper_util::rt::TokioExecutor::new();
943/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
944///     secret,
945///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
946///     yup_oauth2::client::CustomHyperClientBuilder::from(
947///         hyper_util::client::legacy::Client::builder(executor).build(connector),
948///     ),
949/// ).build().await.unwrap();
950///
951/// let client = hyper_util::client::legacy::Client::builder(
952///     hyper_util::rt::TokioExecutor::new()
953/// )
954/// .build(
955///     hyper_rustls::HttpsConnectorBuilder::new()
956///         .with_native_roots()
957///         .unwrap()
958///         .https_or_http()
959///         .enable_http2()
960///         .build()
961/// );
962/// let mut hub = Mirror::new(client, auth);
963/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
964/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
965/// // to build up your call.
966/// let rb = hub.contacts();
967/// # }
968/// ```
969pub struct ContactMethods<'a, C>
970where
971    C: 'a,
972{
973    hub: &'a Mirror<C>,
974}
975
976impl<'a, C> common::MethodsBuilder for ContactMethods<'a, C> {}
977
978impl<'a, C> ContactMethods<'a, C> {
979    /// Create a builder to help you perform the following task:
980    ///
981    /// Deletes a contact.
982    ///
983    /// # Arguments
984    ///
985    /// * `id` - The ID of the contact.
986    pub fn delete(&self, id: &str) -> ContactDeleteCall<'a, C> {
987        ContactDeleteCall {
988            hub: self.hub,
989            _id: id.to_string(),
990            _delegate: Default::default(),
991            _additional_params: Default::default(),
992            _scopes: Default::default(),
993        }
994    }
995
996    /// Create a builder to help you perform the following task:
997    ///
998    /// Gets a single contact by ID.
999    ///
1000    /// # Arguments
1001    ///
1002    /// * `id` - The ID of the contact.
1003    pub fn get(&self, id: &str) -> ContactGetCall<'a, C> {
1004        ContactGetCall {
1005            hub: self.hub,
1006            _id: id.to_string(),
1007            _delegate: Default::default(),
1008            _additional_params: Default::default(),
1009            _scopes: Default::default(),
1010        }
1011    }
1012
1013    /// Create a builder to help you perform the following task:
1014    ///
1015    /// Inserts a new contact.
1016    ///
1017    /// # Arguments
1018    ///
1019    /// * `request` - No description provided.
1020    pub fn insert(&self, request: Contact) -> ContactInsertCall<'a, C> {
1021        ContactInsertCall {
1022            hub: self.hub,
1023            _request: request,
1024            _delegate: Default::default(),
1025            _additional_params: Default::default(),
1026            _scopes: Default::default(),
1027        }
1028    }
1029
1030    /// Create a builder to help you perform the following task:
1031    ///
1032    /// Retrieves a list of contacts for the authenticated user.
1033    pub fn list(&self) -> ContactListCall<'a, C> {
1034        ContactListCall {
1035            hub: self.hub,
1036            _delegate: Default::default(),
1037            _additional_params: Default::default(),
1038            _scopes: Default::default(),
1039        }
1040    }
1041
1042    /// Create a builder to help you perform the following task:
1043    ///
1044    /// Updates a contact in place. This method supports patch semantics.
1045    ///
1046    /// # Arguments
1047    ///
1048    /// * `request` - No description provided.
1049    /// * `id` - The ID of the contact.
1050    pub fn patch(&self, request: Contact, id: &str) -> ContactPatchCall<'a, C> {
1051        ContactPatchCall {
1052            hub: self.hub,
1053            _request: request,
1054            _id: id.to_string(),
1055            _delegate: Default::default(),
1056            _additional_params: Default::default(),
1057            _scopes: Default::default(),
1058        }
1059    }
1060
1061    /// Create a builder to help you perform the following task:
1062    ///
1063    /// Updates a contact in place.
1064    ///
1065    /// # Arguments
1066    ///
1067    /// * `request` - No description provided.
1068    /// * `id` - The ID of the contact.
1069    pub fn update(&self, request: Contact, id: &str) -> ContactUpdateCall<'a, C> {
1070        ContactUpdateCall {
1071            hub: self.hub,
1072            _request: request,
1073            _id: id.to_string(),
1074            _delegate: Default::default(),
1075            _additional_params: Default::default(),
1076            _scopes: Default::default(),
1077        }
1078    }
1079}
1080
1081/// A builder providing access to all methods supported on *location* resources.
1082/// It is not used directly, but through the [`Mirror`] hub.
1083///
1084/// # Example
1085///
1086/// Instantiate a resource builder
1087///
1088/// ```test_harness,no_run
1089/// extern crate hyper;
1090/// extern crate hyper_rustls;
1091/// extern crate google_mirror1 as mirror1;
1092///
1093/// # async fn dox() {
1094/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1095///
1096/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1097/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1098///     .with_native_roots()
1099///     .unwrap()
1100///     .https_only()
1101///     .enable_http2()
1102///     .build();
1103///
1104/// let executor = hyper_util::rt::TokioExecutor::new();
1105/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1106///     secret,
1107///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1108///     yup_oauth2::client::CustomHyperClientBuilder::from(
1109///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1110///     ),
1111/// ).build().await.unwrap();
1112///
1113/// let client = hyper_util::client::legacy::Client::builder(
1114///     hyper_util::rt::TokioExecutor::new()
1115/// )
1116/// .build(
1117///     hyper_rustls::HttpsConnectorBuilder::new()
1118///         .with_native_roots()
1119///         .unwrap()
1120///         .https_or_http()
1121///         .enable_http2()
1122///         .build()
1123/// );
1124/// let mut hub = Mirror::new(client, auth);
1125/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1126/// // like `get(...)` and `list(...)`
1127/// // to build up your call.
1128/// let rb = hub.locations();
1129/// # }
1130/// ```
1131pub struct LocationMethods<'a, C>
1132where
1133    C: 'a,
1134{
1135    hub: &'a Mirror<C>,
1136}
1137
1138impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
1139
1140impl<'a, C> LocationMethods<'a, C> {
1141    /// Create a builder to help you perform the following task:
1142    ///
1143    /// Gets a single location by ID.
1144    ///
1145    /// # Arguments
1146    ///
1147    /// * `id` - The ID of the location or latest for the last known location.
1148    pub fn get(&self, id: &str) -> LocationGetCall<'a, C> {
1149        LocationGetCall {
1150            hub: self.hub,
1151            _id: id.to_string(),
1152            _delegate: Default::default(),
1153            _additional_params: Default::default(),
1154            _scopes: Default::default(),
1155        }
1156    }
1157
1158    /// Create a builder to help you perform the following task:
1159    ///
1160    /// Retrieves a list of locations for the user.
1161    pub fn list(&self) -> LocationListCall<'a, C> {
1162        LocationListCall {
1163            hub: self.hub,
1164            _delegate: Default::default(),
1165            _additional_params: Default::default(),
1166            _scopes: Default::default(),
1167        }
1168    }
1169}
1170
1171/// A builder providing access to all methods supported on *setting* resources.
1172/// It is not used directly, but through the [`Mirror`] hub.
1173///
1174/// # Example
1175///
1176/// Instantiate a resource builder
1177///
1178/// ```test_harness,no_run
1179/// extern crate hyper;
1180/// extern crate hyper_rustls;
1181/// extern crate google_mirror1 as mirror1;
1182///
1183/// # async fn dox() {
1184/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1185///
1186/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1187/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1188///     .with_native_roots()
1189///     .unwrap()
1190///     .https_only()
1191///     .enable_http2()
1192///     .build();
1193///
1194/// let executor = hyper_util::rt::TokioExecutor::new();
1195/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1196///     secret,
1197///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1198///     yup_oauth2::client::CustomHyperClientBuilder::from(
1199///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1200///     ),
1201/// ).build().await.unwrap();
1202///
1203/// let client = hyper_util::client::legacy::Client::builder(
1204///     hyper_util::rt::TokioExecutor::new()
1205/// )
1206/// .build(
1207///     hyper_rustls::HttpsConnectorBuilder::new()
1208///         .with_native_roots()
1209///         .unwrap()
1210///         .https_or_http()
1211///         .enable_http2()
1212///         .build()
1213/// );
1214/// let mut hub = Mirror::new(client, auth);
1215/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1216/// // like `get(...)`
1217/// // to build up your call.
1218/// let rb = hub.settings();
1219/// # }
1220/// ```
1221pub struct SettingMethods<'a, C>
1222where
1223    C: 'a,
1224{
1225    hub: &'a Mirror<C>,
1226}
1227
1228impl<'a, C> common::MethodsBuilder for SettingMethods<'a, C> {}
1229
1230impl<'a, C> SettingMethods<'a, C> {
1231    /// Create a builder to help you perform the following task:
1232    ///
1233    /// Gets a single setting by ID.
1234    ///
1235    /// # Arguments
1236    ///
1237    /// * `id` - The ID of the setting. The following IDs are valid:
1238    ///          - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.
1239    ///          - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
1240    pub fn get(&self, id: &str) -> SettingGetCall<'a, C> {
1241        SettingGetCall {
1242            hub: self.hub,
1243            _id: id.to_string(),
1244            _delegate: Default::default(),
1245            _additional_params: Default::default(),
1246            _scopes: Default::default(),
1247        }
1248    }
1249}
1250
1251/// A builder providing access to all methods supported on *subscription* resources.
1252/// It is not used directly, but through the [`Mirror`] hub.
1253///
1254/// # Example
1255///
1256/// Instantiate a resource builder
1257///
1258/// ```test_harness,no_run
1259/// extern crate hyper;
1260/// extern crate hyper_rustls;
1261/// extern crate google_mirror1 as mirror1;
1262///
1263/// # async fn dox() {
1264/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1265///
1266/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1267/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1268///     .with_native_roots()
1269///     .unwrap()
1270///     .https_only()
1271///     .enable_http2()
1272///     .build();
1273///
1274/// let executor = hyper_util::rt::TokioExecutor::new();
1275/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1276///     secret,
1277///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1278///     yup_oauth2::client::CustomHyperClientBuilder::from(
1279///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1280///     ),
1281/// ).build().await.unwrap();
1282///
1283/// let client = hyper_util::client::legacy::Client::builder(
1284///     hyper_util::rt::TokioExecutor::new()
1285/// )
1286/// .build(
1287///     hyper_rustls::HttpsConnectorBuilder::new()
1288///         .with_native_roots()
1289///         .unwrap()
1290///         .https_or_http()
1291///         .enable_http2()
1292///         .build()
1293/// );
1294/// let mut hub = Mirror::new(client, auth);
1295/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1296/// // like `delete(...)`, `insert(...)`, `list(...)` and `update(...)`
1297/// // to build up your call.
1298/// let rb = hub.subscriptions();
1299/// # }
1300/// ```
1301pub struct SubscriptionMethods<'a, C>
1302where
1303    C: 'a,
1304{
1305    hub: &'a Mirror<C>,
1306}
1307
1308impl<'a, C> common::MethodsBuilder for SubscriptionMethods<'a, C> {}
1309
1310impl<'a, C> SubscriptionMethods<'a, C> {
1311    /// Create a builder to help you perform the following task:
1312    ///
1313    /// Deletes a subscription.
1314    ///
1315    /// # Arguments
1316    ///
1317    /// * `id` - The ID of the subscription.
1318    pub fn delete(&self, id: &str) -> SubscriptionDeleteCall<'a, C> {
1319        SubscriptionDeleteCall {
1320            hub: self.hub,
1321            _id: id.to_string(),
1322            _delegate: Default::default(),
1323            _additional_params: Default::default(),
1324            _scopes: Default::default(),
1325        }
1326    }
1327
1328    /// Create a builder to help you perform the following task:
1329    ///
1330    /// Creates a new subscription.
1331    ///
1332    /// # Arguments
1333    ///
1334    /// * `request` - No description provided.
1335    pub fn insert(&self, request: Subscription) -> SubscriptionInsertCall<'a, C> {
1336        SubscriptionInsertCall {
1337            hub: self.hub,
1338            _request: request,
1339            _delegate: Default::default(),
1340            _additional_params: Default::default(),
1341            _scopes: Default::default(),
1342        }
1343    }
1344
1345    /// Create a builder to help you perform the following task:
1346    ///
1347    /// Retrieves a list of subscriptions for the authenticated user and service.
1348    pub fn list(&self) -> SubscriptionListCall<'a, C> {
1349        SubscriptionListCall {
1350            hub: self.hub,
1351            _delegate: Default::default(),
1352            _additional_params: Default::default(),
1353            _scopes: Default::default(),
1354        }
1355    }
1356
1357    /// Create a builder to help you perform the following task:
1358    ///
1359    /// Updates an existing subscription in place.
1360    ///
1361    /// # Arguments
1362    ///
1363    /// * `request` - No description provided.
1364    /// * `id` - The ID of the subscription.
1365    pub fn update(&self, request: Subscription, id: &str) -> SubscriptionUpdateCall<'a, C> {
1366        SubscriptionUpdateCall {
1367            hub: self.hub,
1368            _request: request,
1369            _id: id.to_string(),
1370            _delegate: Default::default(),
1371            _additional_params: Default::default(),
1372            _scopes: Default::default(),
1373        }
1374    }
1375}
1376
1377/// A builder providing access to all methods supported on *timeline* resources.
1378/// It is not used directly, but through the [`Mirror`] hub.
1379///
1380/// # Example
1381///
1382/// Instantiate a resource builder
1383///
1384/// ```test_harness,no_run
1385/// extern crate hyper;
1386/// extern crate hyper_rustls;
1387/// extern crate google_mirror1 as mirror1;
1388///
1389/// # async fn dox() {
1390/// use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1391///
1392/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1393/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1394///     .with_native_roots()
1395///     .unwrap()
1396///     .https_only()
1397///     .enable_http2()
1398///     .build();
1399///
1400/// let executor = hyper_util::rt::TokioExecutor::new();
1401/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1402///     secret,
1403///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1404///     yup_oauth2::client::CustomHyperClientBuilder::from(
1405///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1406///     ),
1407/// ).build().await.unwrap();
1408///
1409/// let client = hyper_util::client::legacy::Client::builder(
1410///     hyper_util::rt::TokioExecutor::new()
1411/// )
1412/// .build(
1413///     hyper_rustls::HttpsConnectorBuilder::new()
1414///         .with_native_roots()
1415///         .unwrap()
1416///         .https_or_http()
1417///         .enable_http2()
1418///         .build()
1419/// );
1420/// let mut hub = Mirror::new(client, auth);
1421/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1422/// // like `attachments_delete(...)`, `attachments_get(...)`, `attachments_insert(...)`, `attachments_list(...)`, `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)` and `update(...)`
1423/// // to build up your call.
1424/// let rb = hub.timeline();
1425/// # }
1426/// ```
1427pub struct TimelineMethods<'a, C>
1428where
1429    C: 'a,
1430{
1431    hub: &'a Mirror<C>,
1432}
1433
1434impl<'a, C> common::MethodsBuilder for TimelineMethods<'a, C> {}
1435
1436impl<'a, C> TimelineMethods<'a, C> {
1437    /// Create a builder to help you perform the following task:
1438    ///
1439    /// Deletes an attachment from a timeline item.
1440    ///
1441    /// # Arguments
1442    ///
1443    /// * `itemId` - The ID of the timeline item the attachment belongs to.
1444    /// * `attachmentId` - The ID of the attachment.
1445    pub fn attachments_delete(
1446        &self,
1447        item_id: &str,
1448        attachment_id: &str,
1449    ) -> TimelineAttachmentDeleteCall<'a, C> {
1450        TimelineAttachmentDeleteCall {
1451            hub: self.hub,
1452            _item_id: item_id.to_string(),
1453            _attachment_id: attachment_id.to_string(),
1454            _delegate: Default::default(),
1455            _additional_params: Default::default(),
1456            _scopes: Default::default(),
1457        }
1458    }
1459
1460    /// Create a builder to help you perform the following task:
1461    ///
1462    /// Retrieves an attachment on a timeline item by item ID and attachment ID.
1463    ///
1464    /// # Arguments
1465    ///
1466    /// * `itemId` - The ID of the timeline item the attachment belongs to.
1467    /// * `attachmentId` - The ID of the attachment.
1468    pub fn attachments_get(
1469        &self,
1470        item_id: &str,
1471        attachment_id: &str,
1472    ) -> TimelineAttachmentGetCall<'a, C> {
1473        TimelineAttachmentGetCall {
1474            hub: self.hub,
1475            _item_id: item_id.to_string(),
1476            _attachment_id: attachment_id.to_string(),
1477            _delegate: Default::default(),
1478            _additional_params: Default::default(),
1479            _scopes: Default::default(),
1480        }
1481    }
1482
1483    /// Create a builder to help you perform the following task:
1484    ///
1485    /// Adds a new attachment to a timeline item.
1486    ///
1487    /// # Arguments
1488    ///
1489    /// * `itemId` - The ID of the timeline item the attachment belongs to.
1490    pub fn attachments_insert(&self, item_id: &str) -> TimelineAttachmentInsertCall<'a, C> {
1491        TimelineAttachmentInsertCall {
1492            hub: self.hub,
1493            _item_id: item_id.to_string(),
1494            _delegate: Default::default(),
1495            _additional_params: Default::default(),
1496            _scopes: Default::default(),
1497        }
1498    }
1499
1500    /// Create a builder to help you perform the following task:
1501    ///
1502    /// Returns a list of attachments for a timeline item.
1503    ///
1504    /// # Arguments
1505    ///
1506    /// * `itemId` - The ID of the timeline item whose attachments should be listed.
1507    pub fn attachments_list(&self, item_id: &str) -> TimelineAttachmentListCall<'a, C> {
1508        TimelineAttachmentListCall {
1509            hub: self.hub,
1510            _item_id: item_id.to_string(),
1511            _delegate: Default::default(),
1512            _additional_params: Default::default(),
1513            _scopes: Default::default(),
1514        }
1515    }
1516
1517    /// Create a builder to help you perform the following task:
1518    ///
1519    /// Deletes a timeline item.
1520    ///
1521    /// # Arguments
1522    ///
1523    /// * `id` - The ID of the timeline item.
1524    pub fn delete(&self, id: &str) -> TimelineDeleteCall<'a, C> {
1525        TimelineDeleteCall {
1526            hub: self.hub,
1527            _id: id.to_string(),
1528            _delegate: Default::default(),
1529            _additional_params: Default::default(),
1530            _scopes: Default::default(),
1531        }
1532    }
1533
1534    /// Create a builder to help you perform the following task:
1535    ///
1536    /// Gets a single timeline item by ID.
1537    ///
1538    /// # Arguments
1539    ///
1540    /// * `id` - The ID of the timeline item.
1541    pub fn get(&self, id: &str) -> TimelineGetCall<'a, C> {
1542        TimelineGetCall {
1543            hub: self.hub,
1544            _id: id.to_string(),
1545            _delegate: Default::default(),
1546            _additional_params: Default::default(),
1547            _scopes: Default::default(),
1548        }
1549    }
1550
1551    /// Create a builder to help you perform the following task:
1552    ///
1553    /// Inserts a new item into the timeline.
1554    ///
1555    /// # Arguments
1556    ///
1557    /// * `request` - No description provided.
1558    pub fn insert(&self, request: TimelineItem) -> TimelineInsertCall<'a, C> {
1559        TimelineInsertCall {
1560            hub: self.hub,
1561            _request: request,
1562            _delegate: Default::default(),
1563            _additional_params: Default::default(),
1564            _scopes: Default::default(),
1565        }
1566    }
1567
1568    /// Create a builder to help you perform the following task:
1569    ///
1570    /// Retrieves a list of timeline items for the authenticated user.
1571    pub fn list(&self) -> TimelineListCall<'a, C> {
1572        TimelineListCall {
1573            hub: self.hub,
1574            _source_item_id: Default::default(),
1575            _pinned_only: Default::default(),
1576            _page_token: Default::default(),
1577            _order_by: Default::default(),
1578            _max_results: Default::default(),
1579            _include_deleted: Default::default(),
1580            _bundle_id: Default::default(),
1581            _delegate: Default::default(),
1582            _additional_params: Default::default(),
1583            _scopes: Default::default(),
1584        }
1585    }
1586
1587    /// Create a builder to help you perform the following task:
1588    ///
1589    /// Updates a timeline item in place. This method supports patch semantics.
1590    ///
1591    /// # Arguments
1592    ///
1593    /// * `request` - No description provided.
1594    /// * `id` - The ID of the timeline item.
1595    pub fn patch(&self, request: TimelineItem, id: &str) -> TimelinePatchCall<'a, C> {
1596        TimelinePatchCall {
1597            hub: self.hub,
1598            _request: request,
1599            _id: id.to_string(),
1600            _delegate: Default::default(),
1601            _additional_params: Default::default(),
1602            _scopes: Default::default(),
1603        }
1604    }
1605
1606    /// Create a builder to help you perform the following task:
1607    ///
1608    /// Updates a timeline item in place.
1609    ///
1610    /// # Arguments
1611    ///
1612    /// * `request` - No description provided.
1613    /// * `id` - The ID of the timeline item.
1614    pub fn update(&self, request: TimelineItem, id: &str) -> TimelineUpdateCall<'a, C> {
1615        TimelineUpdateCall {
1616            hub: self.hub,
1617            _request: request,
1618            _id: id.to_string(),
1619            _delegate: Default::default(),
1620            _additional_params: Default::default(),
1621            _scopes: Default::default(),
1622        }
1623    }
1624}
1625
1626// ###################
1627// CallBuilders   ###
1628// #################
1629
1630/// Inserts a new account for a user
1631///
1632/// A builder for the *insert* method supported by a *account* resource.
1633/// It is not used directly, but through a [`AccountMethods`] instance.
1634///
1635/// # Example
1636///
1637/// Instantiate a resource method builder
1638///
1639/// ```test_harness,no_run
1640/// # extern crate hyper;
1641/// # extern crate hyper_rustls;
1642/// # extern crate google_mirror1 as mirror1;
1643/// use mirror1::api::Account;
1644/// # async fn dox() {
1645/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1646///
1647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1648/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1649/// #     .with_native_roots()
1650/// #     .unwrap()
1651/// #     .https_only()
1652/// #     .enable_http2()
1653/// #     .build();
1654///
1655/// # let executor = hyper_util::rt::TokioExecutor::new();
1656/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1657/// #     secret,
1658/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1659/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1660/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1661/// #     ),
1662/// # ).build().await.unwrap();
1663///
1664/// # let client = hyper_util::client::legacy::Client::builder(
1665/// #     hyper_util::rt::TokioExecutor::new()
1666/// # )
1667/// # .build(
1668/// #     hyper_rustls::HttpsConnectorBuilder::new()
1669/// #         .with_native_roots()
1670/// #         .unwrap()
1671/// #         .https_or_http()
1672/// #         .enable_http2()
1673/// #         .build()
1674/// # );
1675/// # let mut hub = Mirror::new(client, auth);
1676/// // As the method needs a request, you would usually fill it with the desired information
1677/// // into the respective structure. Some of the parts shown here might not be applicable !
1678/// // Values shown here are possibly random and not representative !
1679/// let mut req = Account::default();
1680///
1681/// // You can configure optional parameters by calling the respective setters at will, and
1682/// // execute the final call using `doit()`.
1683/// // Values shown here are possibly random and not representative !
1684/// let result = hub.accounts().insert(req, "userToken", "accountType", "accountName")
1685///              .doit().await;
1686/// # }
1687/// ```
1688pub struct AccountInsertCall<'a, C>
1689where
1690    C: 'a,
1691{
1692    hub: &'a Mirror<C>,
1693    _request: Account,
1694    _user_token: String,
1695    _account_type: String,
1696    _account_name: String,
1697    _delegate: Option<&'a mut dyn common::Delegate>,
1698    _additional_params: HashMap<String, String>,
1699}
1700
1701impl<'a, C> common::CallBuilder for AccountInsertCall<'a, C> {}
1702
1703impl<'a, C> AccountInsertCall<'a, C>
1704where
1705    C: common::Connector,
1706{
1707    /// Perform the operation you have build so far.
1708    pub async fn doit(mut self) -> common::Result<(common::Response, Account)> {
1709        use std::borrow::Cow;
1710        use std::io::{Read, Seek};
1711
1712        use common::{url::Params, ToParts};
1713        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1714
1715        let mut dd = common::DefaultDelegate;
1716        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1717        dlg.begin(common::MethodInfo {
1718            id: "mirror.accounts.insert",
1719            http_method: hyper::Method::POST,
1720        });
1721
1722        for &field in ["alt", "userToken", "accountType", "accountName"].iter() {
1723            if self._additional_params.contains_key(field) {
1724                dlg.finished(false);
1725                return Err(common::Error::FieldClash(field));
1726            }
1727        }
1728
1729        let mut params = Params::with_capacity(6 + self._additional_params.len());
1730        params.push("userToken", self._user_token);
1731        params.push("accountType", self._account_type);
1732        params.push("accountName", self._account_name);
1733
1734        params.extend(self._additional_params.iter());
1735
1736        params.push("alt", "json");
1737        let mut url =
1738            self.hub._base_url.clone() + "accounts/{userToken}/{accountType}/{accountName}";
1739
1740        match dlg.api_key() {
1741            Some(value) => params.push("key", value),
1742            None => {
1743                dlg.finished(false);
1744                return Err(common::Error::MissingAPIKey);
1745            }
1746        }
1747
1748        #[allow(clippy::single_element_loop)]
1749        for &(find_this, param_name) in [
1750            ("{userToken}", "userToken"),
1751            ("{accountType}", "accountType"),
1752            ("{accountName}", "accountName"),
1753        ]
1754        .iter()
1755        {
1756            url = params.uri_replacement(url, param_name, find_this, false);
1757        }
1758        {
1759            let to_remove = ["accountName", "accountType", "userToken"];
1760            params.remove_params(&to_remove);
1761        }
1762
1763        let url = params.parse_with_url(&url);
1764
1765        let mut json_mime_type = mime::APPLICATION_JSON;
1766        let mut request_value_reader = {
1767            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1768            common::remove_json_null_values(&mut value);
1769            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1770            serde_json::to_writer(&mut dst, &value).unwrap();
1771            dst
1772        };
1773        let request_size = request_value_reader
1774            .seek(std::io::SeekFrom::End(0))
1775            .unwrap();
1776        request_value_reader
1777            .seek(std::io::SeekFrom::Start(0))
1778            .unwrap();
1779
1780        loop {
1781            request_value_reader
1782                .seek(std::io::SeekFrom::Start(0))
1783                .unwrap();
1784            let mut req_result = {
1785                let client = &self.hub.client;
1786                dlg.pre_request();
1787                let mut req_builder = hyper::Request::builder()
1788                    .method(hyper::Method::POST)
1789                    .uri(url.as_str())
1790                    .header(USER_AGENT, self.hub._user_agent.clone());
1791
1792                let request = req_builder
1793                    .header(CONTENT_TYPE, json_mime_type.to_string())
1794                    .header(CONTENT_LENGTH, request_size as u64)
1795                    .body(common::to_body(
1796                        request_value_reader.get_ref().clone().into(),
1797                    ));
1798
1799                client.request(request.unwrap()).await
1800            };
1801
1802            match req_result {
1803                Err(err) => {
1804                    if let common::Retry::After(d) = dlg.http_error(&err) {
1805                        sleep(d).await;
1806                        continue;
1807                    }
1808                    dlg.finished(false);
1809                    return Err(common::Error::HttpError(err));
1810                }
1811                Ok(res) => {
1812                    let (mut parts, body) = res.into_parts();
1813                    let mut body = common::Body::new(body);
1814                    if !parts.status.is_success() {
1815                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1816                        let error = serde_json::from_str(&common::to_string(&bytes));
1817                        let response = common::to_response(parts, bytes.into());
1818
1819                        if let common::Retry::After(d) =
1820                            dlg.http_failure(&response, error.as_ref().ok())
1821                        {
1822                            sleep(d).await;
1823                            continue;
1824                        }
1825
1826                        dlg.finished(false);
1827
1828                        return Err(match error {
1829                            Ok(value) => common::Error::BadRequest(value),
1830                            _ => common::Error::Failure(response),
1831                        });
1832                    }
1833                    let response = {
1834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1835                        let encoded = common::to_string(&bytes);
1836                        match serde_json::from_str(&encoded) {
1837                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1838                            Err(error) => {
1839                                dlg.response_json_decode_error(&encoded, &error);
1840                                return Err(common::Error::JsonDecodeError(
1841                                    encoded.to_string(),
1842                                    error,
1843                                ));
1844                            }
1845                        }
1846                    };
1847
1848                    dlg.finished(true);
1849                    return Ok(response);
1850                }
1851            }
1852        }
1853    }
1854
1855    ///
1856    /// Sets the *request* property to the given value.
1857    ///
1858    /// Even though the property as already been set when instantiating this call,
1859    /// we provide this method for API completeness.
1860    pub fn request(mut self, new_value: Account) -> AccountInsertCall<'a, C> {
1861        self._request = new_value;
1862        self
1863    }
1864    /// The ID for the user.
1865    ///
1866    /// Sets the *user token* path property to the given value.
1867    ///
1868    /// Even though the property as already been set when instantiating this call,
1869    /// we provide this method for API completeness.
1870    pub fn user_token(mut self, new_value: &str) -> AccountInsertCall<'a, C> {
1871        self._user_token = new_value.to_string();
1872        self
1873    }
1874    /// Account type to be passed to Android Account Manager.
1875    ///
1876    /// Sets the *account type* path property to the given value.
1877    ///
1878    /// Even though the property as already been set when instantiating this call,
1879    /// we provide this method for API completeness.
1880    pub fn account_type(mut self, new_value: &str) -> AccountInsertCall<'a, C> {
1881        self._account_type = new_value.to_string();
1882        self
1883    }
1884    /// The name of the account to be passed to the Android Account Manager.
1885    ///
1886    /// Sets the *account name* path property to the given value.
1887    ///
1888    /// Even though the property as already been set when instantiating this call,
1889    /// we provide this method for API completeness.
1890    pub fn account_name(mut self, new_value: &str) -> AccountInsertCall<'a, C> {
1891        self._account_name = new_value.to_string();
1892        self
1893    }
1894    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1895    /// while executing the actual API request.
1896    ///
1897    /// ````text
1898    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1899    /// ````
1900    ///
1901    /// Sets the *delegate* property to the given value.
1902    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AccountInsertCall<'a, C> {
1903        self._delegate = Some(new_value);
1904        self
1905    }
1906
1907    /// Set any additional parameter of the query string used in the request.
1908    /// It should be used to set parameters which are not yet available through their own
1909    /// setters.
1910    ///
1911    /// Please note that this method must not be used to set any of the known parameters
1912    /// which have their own setter method. If done anyway, the request will fail.
1913    ///
1914    /// # Additional Parameters
1915    ///
1916    /// * *alt* (query-string) - Data format for the response.
1917    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1918    /// * *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.
1919    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1920    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1921    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
1922    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
1923    pub fn param<T>(mut self, name: T, value: T) -> AccountInsertCall<'a, C>
1924    where
1925        T: AsRef<str>,
1926    {
1927        self._additional_params
1928            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1929        self
1930    }
1931}
1932
1933/// Deletes a contact.
1934///
1935/// A builder for the *delete* method supported by a *contact* resource.
1936/// It is not used directly, but through a [`ContactMethods`] instance.
1937///
1938/// # Example
1939///
1940/// Instantiate a resource method builder
1941///
1942/// ```test_harness,no_run
1943/// # extern crate hyper;
1944/// # extern crate hyper_rustls;
1945/// # extern crate google_mirror1 as mirror1;
1946/// # async fn dox() {
1947/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1948///
1949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1950/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1951/// #     .with_native_roots()
1952/// #     .unwrap()
1953/// #     .https_only()
1954/// #     .enable_http2()
1955/// #     .build();
1956///
1957/// # let executor = hyper_util::rt::TokioExecutor::new();
1958/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1959/// #     secret,
1960/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1961/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1962/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1963/// #     ),
1964/// # ).build().await.unwrap();
1965///
1966/// # let client = hyper_util::client::legacy::Client::builder(
1967/// #     hyper_util::rt::TokioExecutor::new()
1968/// # )
1969/// # .build(
1970/// #     hyper_rustls::HttpsConnectorBuilder::new()
1971/// #         .with_native_roots()
1972/// #         .unwrap()
1973/// #         .https_or_http()
1974/// #         .enable_http2()
1975/// #         .build()
1976/// # );
1977/// # let mut hub = Mirror::new(client, auth);
1978/// // You can configure optional parameters by calling the respective setters at will, and
1979/// // execute the final call using `doit()`.
1980/// // Values shown here are possibly random and not representative !
1981/// let result = hub.contacts().delete("id")
1982///              .doit().await;
1983/// # }
1984/// ```
1985pub struct ContactDeleteCall<'a, C>
1986where
1987    C: 'a,
1988{
1989    hub: &'a Mirror<C>,
1990    _id: String,
1991    _delegate: Option<&'a mut dyn common::Delegate>,
1992    _additional_params: HashMap<String, String>,
1993    _scopes: BTreeSet<String>,
1994}
1995
1996impl<'a, C> common::CallBuilder for ContactDeleteCall<'a, C> {}
1997
1998impl<'a, C> ContactDeleteCall<'a, C>
1999where
2000    C: common::Connector,
2001{
2002    /// Perform the operation you have build so far.
2003    pub async fn doit(mut self) -> common::Result<common::Response> {
2004        use std::borrow::Cow;
2005        use std::io::{Read, Seek};
2006
2007        use common::{url::Params, ToParts};
2008        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2009
2010        let mut dd = common::DefaultDelegate;
2011        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2012        dlg.begin(common::MethodInfo {
2013            id: "mirror.contacts.delete",
2014            http_method: hyper::Method::DELETE,
2015        });
2016
2017        for &field in ["id"].iter() {
2018            if self._additional_params.contains_key(field) {
2019                dlg.finished(false);
2020                return Err(common::Error::FieldClash(field));
2021            }
2022        }
2023
2024        let mut params = Params::with_capacity(2 + self._additional_params.len());
2025        params.push("id", self._id);
2026
2027        params.extend(self._additional_params.iter());
2028
2029        let mut url = self.hub._base_url.clone() + "contacts/{id}";
2030        if self._scopes.is_empty() {
2031            self._scopes
2032                .insert(Scope::GlasTimeline.as_ref().to_string());
2033        }
2034
2035        #[allow(clippy::single_element_loop)]
2036        for &(find_this, param_name) in [("{id}", "id")].iter() {
2037            url = params.uri_replacement(url, param_name, find_this, false);
2038        }
2039        {
2040            let to_remove = ["id"];
2041            params.remove_params(&to_remove);
2042        }
2043
2044        let url = params.parse_with_url(&url);
2045
2046        loop {
2047            let token = match self
2048                .hub
2049                .auth
2050                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2051                .await
2052            {
2053                Ok(token) => token,
2054                Err(e) => match dlg.token(e) {
2055                    Ok(token) => token,
2056                    Err(e) => {
2057                        dlg.finished(false);
2058                        return Err(common::Error::MissingToken(e));
2059                    }
2060                },
2061            };
2062            let mut req_result = {
2063                let client = &self.hub.client;
2064                dlg.pre_request();
2065                let mut req_builder = hyper::Request::builder()
2066                    .method(hyper::Method::DELETE)
2067                    .uri(url.as_str())
2068                    .header(USER_AGENT, self.hub._user_agent.clone());
2069
2070                if let Some(token) = token.as_ref() {
2071                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2072                }
2073
2074                let request = req_builder
2075                    .header(CONTENT_LENGTH, 0_u64)
2076                    .body(common::to_body::<String>(None));
2077
2078                client.request(request.unwrap()).await
2079            };
2080
2081            match req_result {
2082                Err(err) => {
2083                    if let common::Retry::After(d) = dlg.http_error(&err) {
2084                        sleep(d).await;
2085                        continue;
2086                    }
2087                    dlg.finished(false);
2088                    return Err(common::Error::HttpError(err));
2089                }
2090                Ok(res) => {
2091                    let (mut parts, body) = res.into_parts();
2092                    let mut body = common::Body::new(body);
2093                    if !parts.status.is_success() {
2094                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2095                        let error = serde_json::from_str(&common::to_string(&bytes));
2096                        let response = common::to_response(parts, bytes.into());
2097
2098                        if let common::Retry::After(d) =
2099                            dlg.http_failure(&response, error.as_ref().ok())
2100                        {
2101                            sleep(d).await;
2102                            continue;
2103                        }
2104
2105                        dlg.finished(false);
2106
2107                        return Err(match error {
2108                            Ok(value) => common::Error::BadRequest(value),
2109                            _ => common::Error::Failure(response),
2110                        });
2111                    }
2112                    let response = common::Response::from_parts(parts, body);
2113
2114                    dlg.finished(true);
2115                    return Ok(response);
2116                }
2117            }
2118        }
2119    }
2120
2121    /// The ID of the contact.
2122    ///
2123    /// Sets the *id* path property to the given value.
2124    ///
2125    /// Even though the property as already been set when instantiating this call,
2126    /// we provide this method for API completeness.
2127    pub fn id(mut self, new_value: &str) -> ContactDeleteCall<'a, C> {
2128        self._id = new_value.to_string();
2129        self
2130    }
2131    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2132    /// while executing the actual API request.
2133    ///
2134    /// ````text
2135    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2136    /// ````
2137    ///
2138    /// Sets the *delegate* property to the given value.
2139    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactDeleteCall<'a, C> {
2140        self._delegate = Some(new_value);
2141        self
2142    }
2143
2144    /// Set any additional parameter of the query string used in the request.
2145    /// It should be used to set parameters which are not yet available through their own
2146    /// setters.
2147    ///
2148    /// Please note that this method must not be used to set any of the known parameters
2149    /// which have their own setter method. If done anyway, the request will fail.
2150    ///
2151    /// # Additional Parameters
2152    ///
2153    /// * *alt* (query-string) - Data format for the response.
2154    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2155    /// * *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.
2156    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2157    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2158    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2159    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2160    pub fn param<T>(mut self, name: T, value: T) -> ContactDeleteCall<'a, C>
2161    where
2162        T: AsRef<str>,
2163    {
2164        self._additional_params
2165            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2166        self
2167    }
2168
2169    /// Identifies the authorization scope for the method you are building.
2170    ///
2171    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2172    /// [`Scope::GlasTimeline`].
2173    ///
2174    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2175    /// tokens for more than one scope.
2176    ///
2177    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2178    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2179    /// sufficient, a read-write scope will do as well.
2180    pub fn add_scope<St>(mut self, scope: St) -> ContactDeleteCall<'a, C>
2181    where
2182        St: AsRef<str>,
2183    {
2184        self._scopes.insert(String::from(scope.as_ref()));
2185        self
2186    }
2187    /// Identifies the authorization scope(s) for the method you are building.
2188    ///
2189    /// See [`Self::add_scope()`] for details.
2190    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactDeleteCall<'a, C>
2191    where
2192        I: IntoIterator<Item = St>,
2193        St: AsRef<str>,
2194    {
2195        self._scopes
2196            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2197        self
2198    }
2199
2200    /// Removes all scopes, and no default scope will be used either.
2201    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2202    /// for details).
2203    pub fn clear_scopes(mut self) -> ContactDeleteCall<'a, C> {
2204        self._scopes.clear();
2205        self
2206    }
2207}
2208
2209/// Gets a single contact by ID.
2210///
2211/// A builder for the *get* method supported by a *contact* resource.
2212/// It is not used directly, but through a [`ContactMethods`] instance.
2213///
2214/// # Example
2215///
2216/// Instantiate a resource method builder
2217///
2218/// ```test_harness,no_run
2219/// # extern crate hyper;
2220/// # extern crate hyper_rustls;
2221/// # extern crate google_mirror1 as mirror1;
2222/// # async fn dox() {
2223/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2224///
2225/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2226/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2227/// #     .with_native_roots()
2228/// #     .unwrap()
2229/// #     .https_only()
2230/// #     .enable_http2()
2231/// #     .build();
2232///
2233/// # let executor = hyper_util::rt::TokioExecutor::new();
2234/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2235/// #     secret,
2236/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2237/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2238/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2239/// #     ),
2240/// # ).build().await.unwrap();
2241///
2242/// # let client = hyper_util::client::legacy::Client::builder(
2243/// #     hyper_util::rt::TokioExecutor::new()
2244/// # )
2245/// # .build(
2246/// #     hyper_rustls::HttpsConnectorBuilder::new()
2247/// #         .with_native_roots()
2248/// #         .unwrap()
2249/// #         .https_or_http()
2250/// #         .enable_http2()
2251/// #         .build()
2252/// # );
2253/// # let mut hub = Mirror::new(client, auth);
2254/// // You can configure optional parameters by calling the respective setters at will, and
2255/// // execute the final call using `doit()`.
2256/// // Values shown here are possibly random and not representative !
2257/// let result = hub.contacts().get("id")
2258///              .doit().await;
2259/// # }
2260/// ```
2261pub struct ContactGetCall<'a, C>
2262where
2263    C: 'a,
2264{
2265    hub: &'a Mirror<C>,
2266    _id: String,
2267    _delegate: Option<&'a mut dyn common::Delegate>,
2268    _additional_params: HashMap<String, String>,
2269    _scopes: BTreeSet<String>,
2270}
2271
2272impl<'a, C> common::CallBuilder for ContactGetCall<'a, C> {}
2273
2274impl<'a, C> ContactGetCall<'a, C>
2275where
2276    C: common::Connector,
2277{
2278    /// Perform the operation you have build so far.
2279    pub async fn doit(mut self) -> common::Result<(common::Response, Contact)> {
2280        use std::borrow::Cow;
2281        use std::io::{Read, Seek};
2282
2283        use common::{url::Params, ToParts};
2284        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2285
2286        let mut dd = common::DefaultDelegate;
2287        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2288        dlg.begin(common::MethodInfo {
2289            id: "mirror.contacts.get",
2290            http_method: hyper::Method::GET,
2291        });
2292
2293        for &field in ["alt", "id"].iter() {
2294            if self._additional_params.contains_key(field) {
2295                dlg.finished(false);
2296                return Err(common::Error::FieldClash(field));
2297            }
2298        }
2299
2300        let mut params = Params::with_capacity(3 + self._additional_params.len());
2301        params.push("id", self._id);
2302
2303        params.extend(self._additional_params.iter());
2304
2305        params.push("alt", "json");
2306        let mut url = self.hub._base_url.clone() + "contacts/{id}";
2307        if self._scopes.is_empty() {
2308            self._scopes
2309                .insert(Scope::GlasTimeline.as_ref().to_string());
2310        }
2311
2312        #[allow(clippy::single_element_loop)]
2313        for &(find_this, param_name) in [("{id}", "id")].iter() {
2314            url = params.uri_replacement(url, param_name, find_this, false);
2315        }
2316        {
2317            let to_remove = ["id"];
2318            params.remove_params(&to_remove);
2319        }
2320
2321        let url = params.parse_with_url(&url);
2322
2323        loop {
2324            let token = match self
2325                .hub
2326                .auth
2327                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2328                .await
2329            {
2330                Ok(token) => token,
2331                Err(e) => match dlg.token(e) {
2332                    Ok(token) => token,
2333                    Err(e) => {
2334                        dlg.finished(false);
2335                        return Err(common::Error::MissingToken(e));
2336                    }
2337                },
2338            };
2339            let mut req_result = {
2340                let client = &self.hub.client;
2341                dlg.pre_request();
2342                let mut req_builder = hyper::Request::builder()
2343                    .method(hyper::Method::GET)
2344                    .uri(url.as_str())
2345                    .header(USER_AGENT, self.hub._user_agent.clone());
2346
2347                if let Some(token) = token.as_ref() {
2348                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2349                }
2350
2351                let request = req_builder
2352                    .header(CONTENT_LENGTH, 0_u64)
2353                    .body(common::to_body::<String>(None));
2354
2355                client.request(request.unwrap()).await
2356            };
2357
2358            match req_result {
2359                Err(err) => {
2360                    if let common::Retry::After(d) = dlg.http_error(&err) {
2361                        sleep(d).await;
2362                        continue;
2363                    }
2364                    dlg.finished(false);
2365                    return Err(common::Error::HttpError(err));
2366                }
2367                Ok(res) => {
2368                    let (mut parts, body) = res.into_parts();
2369                    let mut body = common::Body::new(body);
2370                    if !parts.status.is_success() {
2371                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2372                        let error = serde_json::from_str(&common::to_string(&bytes));
2373                        let response = common::to_response(parts, bytes.into());
2374
2375                        if let common::Retry::After(d) =
2376                            dlg.http_failure(&response, error.as_ref().ok())
2377                        {
2378                            sleep(d).await;
2379                            continue;
2380                        }
2381
2382                        dlg.finished(false);
2383
2384                        return Err(match error {
2385                            Ok(value) => common::Error::BadRequest(value),
2386                            _ => common::Error::Failure(response),
2387                        });
2388                    }
2389                    let response = {
2390                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2391                        let encoded = common::to_string(&bytes);
2392                        match serde_json::from_str(&encoded) {
2393                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2394                            Err(error) => {
2395                                dlg.response_json_decode_error(&encoded, &error);
2396                                return Err(common::Error::JsonDecodeError(
2397                                    encoded.to_string(),
2398                                    error,
2399                                ));
2400                            }
2401                        }
2402                    };
2403
2404                    dlg.finished(true);
2405                    return Ok(response);
2406                }
2407            }
2408        }
2409    }
2410
2411    /// The ID of the contact.
2412    ///
2413    /// Sets the *id* path property to the given value.
2414    ///
2415    /// Even though the property as already been set when instantiating this call,
2416    /// we provide this method for API completeness.
2417    pub fn id(mut self, new_value: &str) -> ContactGetCall<'a, C> {
2418        self._id = new_value.to_string();
2419        self
2420    }
2421    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2422    /// while executing the actual API request.
2423    ///
2424    /// ````text
2425    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2426    /// ````
2427    ///
2428    /// Sets the *delegate* property to the given value.
2429    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactGetCall<'a, C> {
2430        self._delegate = Some(new_value);
2431        self
2432    }
2433
2434    /// Set any additional parameter of the query string used in the request.
2435    /// It should be used to set parameters which are not yet available through their own
2436    /// setters.
2437    ///
2438    /// Please note that this method must not be used to set any of the known parameters
2439    /// which have their own setter method. If done anyway, the request will fail.
2440    ///
2441    /// # Additional Parameters
2442    ///
2443    /// * *alt* (query-string) - Data format for the response.
2444    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2445    /// * *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.
2446    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2447    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2448    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2449    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2450    pub fn param<T>(mut self, name: T, value: T) -> ContactGetCall<'a, C>
2451    where
2452        T: AsRef<str>,
2453    {
2454        self._additional_params
2455            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2456        self
2457    }
2458
2459    /// Identifies the authorization scope for the method you are building.
2460    ///
2461    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2462    /// [`Scope::GlasTimeline`].
2463    ///
2464    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2465    /// tokens for more than one scope.
2466    ///
2467    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2468    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2469    /// sufficient, a read-write scope will do as well.
2470    pub fn add_scope<St>(mut self, scope: St) -> ContactGetCall<'a, C>
2471    where
2472        St: AsRef<str>,
2473    {
2474        self._scopes.insert(String::from(scope.as_ref()));
2475        self
2476    }
2477    /// Identifies the authorization scope(s) for the method you are building.
2478    ///
2479    /// See [`Self::add_scope()`] for details.
2480    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactGetCall<'a, C>
2481    where
2482        I: IntoIterator<Item = St>,
2483        St: AsRef<str>,
2484    {
2485        self._scopes
2486            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2487        self
2488    }
2489
2490    /// Removes all scopes, and no default scope will be used either.
2491    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2492    /// for details).
2493    pub fn clear_scopes(mut self) -> ContactGetCall<'a, C> {
2494        self._scopes.clear();
2495        self
2496    }
2497}
2498
2499/// Inserts a new contact.
2500///
2501/// A builder for the *insert* method supported by a *contact* resource.
2502/// It is not used directly, but through a [`ContactMethods`] instance.
2503///
2504/// # Example
2505///
2506/// Instantiate a resource method builder
2507///
2508/// ```test_harness,no_run
2509/// # extern crate hyper;
2510/// # extern crate hyper_rustls;
2511/// # extern crate google_mirror1 as mirror1;
2512/// use mirror1::api::Contact;
2513/// # async fn dox() {
2514/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2515///
2516/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2517/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2518/// #     .with_native_roots()
2519/// #     .unwrap()
2520/// #     .https_only()
2521/// #     .enable_http2()
2522/// #     .build();
2523///
2524/// # let executor = hyper_util::rt::TokioExecutor::new();
2525/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2526/// #     secret,
2527/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2528/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2529/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2530/// #     ),
2531/// # ).build().await.unwrap();
2532///
2533/// # let client = hyper_util::client::legacy::Client::builder(
2534/// #     hyper_util::rt::TokioExecutor::new()
2535/// # )
2536/// # .build(
2537/// #     hyper_rustls::HttpsConnectorBuilder::new()
2538/// #         .with_native_roots()
2539/// #         .unwrap()
2540/// #         .https_or_http()
2541/// #         .enable_http2()
2542/// #         .build()
2543/// # );
2544/// # let mut hub = Mirror::new(client, auth);
2545/// // As the method needs a request, you would usually fill it with the desired information
2546/// // into the respective structure. Some of the parts shown here might not be applicable !
2547/// // Values shown here are possibly random and not representative !
2548/// let mut req = Contact::default();
2549///
2550/// // You can configure optional parameters by calling the respective setters at will, and
2551/// // execute the final call using `doit()`.
2552/// // Values shown here are possibly random and not representative !
2553/// let result = hub.contacts().insert(req)
2554///              .doit().await;
2555/// # }
2556/// ```
2557pub struct ContactInsertCall<'a, C>
2558where
2559    C: 'a,
2560{
2561    hub: &'a Mirror<C>,
2562    _request: Contact,
2563    _delegate: Option<&'a mut dyn common::Delegate>,
2564    _additional_params: HashMap<String, String>,
2565    _scopes: BTreeSet<String>,
2566}
2567
2568impl<'a, C> common::CallBuilder for ContactInsertCall<'a, C> {}
2569
2570impl<'a, C> ContactInsertCall<'a, C>
2571where
2572    C: common::Connector,
2573{
2574    /// Perform the operation you have build so far.
2575    pub async fn doit(mut self) -> common::Result<(common::Response, Contact)> {
2576        use std::borrow::Cow;
2577        use std::io::{Read, Seek};
2578
2579        use common::{url::Params, ToParts};
2580        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2581
2582        let mut dd = common::DefaultDelegate;
2583        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2584        dlg.begin(common::MethodInfo {
2585            id: "mirror.contacts.insert",
2586            http_method: hyper::Method::POST,
2587        });
2588
2589        for &field in ["alt"].iter() {
2590            if self._additional_params.contains_key(field) {
2591                dlg.finished(false);
2592                return Err(common::Error::FieldClash(field));
2593            }
2594        }
2595
2596        let mut params = Params::with_capacity(3 + self._additional_params.len());
2597
2598        params.extend(self._additional_params.iter());
2599
2600        params.push("alt", "json");
2601        let mut url = self.hub._base_url.clone() + "contacts";
2602        if self._scopes.is_empty() {
2603            self._scopes
2604                .insert(Scope::GlasTimeline.as_ref().to_string());
2605        }
2606
2607        let url = params.parse_with_url(&url);
2608
2609        let mut json_mime_type = mime::APPLICATION_JSON;
2610        let mut request_value_reader = {
2611            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2612            common::remove_json_null_values(&mut value);
2613            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2614            serde_json::to_writer(&mut dst, &value).unwrap();
2615            dst
2616        };
2617        let request_size = request_value_reader
2618            .seek(std::io::SeekFrom::End(0))
2619            .unwrap();
2620        request_value_reader
2621            .seek(std::io::SeekFrom::Start(0))
2622            .unwrap();
2623
2624        loop {
2625            let token = match self
2626                .hub
2627                .auth
2628                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2629                .await
2630            {
2631                Ok(token) => token,
2632                Err(e) => match dlg.token(e) {
2633                    Ok(token) => token,
2634                    Err(e) => {
2635                        dlg.finished(false);
2636                        return Err(common::Error::MissingToken(e));
2637                    }
2638                },
2639            };
2640            request_value_reader
2641                .seek(std::io::SeekFrom::Start(0))
2642                .unwrap();
2643            let mut req_result = {
2644                let client = &self.hub.client;
2645                dlg.pre_request();
2646                let mut req_builder = hyper::Request::builder()
2647                    .method(hyper::Method::POST)
2648                    .uri(url.as_str())
2649                    .header(USER_AGENT, self.hub._user_agent.clone());
2650
2651                if let Some(token) = token.as_ref() {
2652                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2653                }
2654
2655                let request = req_builder
2656                    .header(CONTENT_TYPE, json_mime_type.to_string())
2657                    .header(CONTENT_LENGTH, request_size as u64)
2658                    .body(common::to_body(
2659                        request_value_reader.get_ref().clone().into(),
2660                    ));
2661
2662                client.request(request.unwrap()).await
2663            };
2664
2665            match req_result {
2666                Err(err) => {
2667                    if let common::Retry::After(d) = dlg.http_error(&err) {
2668                        sleep(d).await;
2669                        continue;
2670                    }
2671                    dlg.finished(false);
2672                    return Err(common::Error::HttpError(err));
2673                }
2674                Ok(res) => {
2675                    let (mut parts, body) = res.into_parts();
2676                    let mut body = common::Body::new(body);
2677                    if !parts.status.is_success() {
2678                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2679                        let error = serde_json::from_str(&common::to_string(&bytes));
2680                        let response = common::to_response(parts, bytes.into());
2681
2682                        if let common::Retry::After(d) =
2683                            dlg.http_failure(&response, error.as_ref().ok())
2684                        {
2685                            sleep(d).await;
2686                            continue;
2687                        }
2688
2689                        dlg.finished(false);
2690
2691                        return Err(match error {
2692                            Ok(value) => common::Error::BadRequest(value),
2693                            _ => common::Error::Failure(response),
2694                        });
2695                    }
2696                    let response = {
2697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2698                        let encoded = common::to_string(&bytes);
2699                        match serde_json::from_str(&encoded) {
2700                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2701                            Err(error) => {
2702                                dlg.response_json_decode_error(&encoded, &error);
2703                                return Err(common::Error::JsonDecodeError(
2704                                    encoded.to_string(),
2705                                    error,
2706                                ));
2707                            }
2708                        }
2709                    };
2710
2711                    dlg.finished(true);
2712                    return Ok(response);
2713                }
2714            }
2715        }
2716    }
2717
2718    ///
2719    /// Sets the *request* property to the given value.
2720    ///
2721    /// Even though the property as already been set when instantiating this call,
2722    /// we provide this method for API completeness.
2723    pub fn request(mut self, new_value: Contact) -> ContactInsertCall<'a, C> {
2724        self._request = new_value;
2725        self
2726    }
2727    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2728    /// while executing the actual API request.
2729    ///
2730    /// ````text
2731    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2732    /// ````
2733    ///
2734    /// Sets the *delegate* property to the given value.
2735    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactInsertCall<'a, C> {
2736        self._delegate = Some(new_value);
2737        self
2738    }
2739
2740    /// Set any additional parameter of the query string used in the request.
2741    /// It should be used to set parameters which are not yet available through their own
2742    /// setters.
2743    ///
2744    /// Please note that this method must not be used to set any of the known parameters
2745    /// which have their own setter method. If done anyway, the request will fail.
2746    ///
2747    /// # Additional Parameters
2748    ///
2749    /// * *alt* (query-string) - Data format for the response.
2750    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2751    /// * *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.
2752    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2753    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2754    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2755    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2756    pub fn param<T>(mut self, name: T, value: T) -> ContactInsertCall<'a, C>
2757    where
2758        T: AsRef<str>,
2759    {
2760        self._additional_params
2761            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2762        self
2763    }
2764
2765    /// Identifies the authorization scope for the method you are building.
2766    ///
2767    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2768    /// [`Scope::GlasTimeline`].
2769    ///
2770    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2771    /// tokens for more than one scope.
2772    ///
2773    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2774    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2775    /// sufficient, a read-write scope will do as well.
2776    pub fn add_scope<St>(mut self, scope: St) -> ContactInsertCall<'a, C>
2777    where
2778        St: AsRef<str>,
2779    {
2780        self._scopes.insert(String::from(scope.as_ref()));
2781        self
2782    }
2783    /// Identifies the authorization scope(s) for the method you are building.
2784    ///
2785    /// See [`Self::add_scope()`] for details.
2786    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactInsertCall<'a, C>
2787    where
2788        I: IntoIterator<Item = St>,
2789        St: AsRef<str>,
2790    {
2791        self._scopes
2792            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2793        self
2794    }
2795
2796    /// Removes all scopes, and no default scope will be used either.
2797    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2798    /// for details).
2799    pub fn clear_scopes(mut self) -> ContactInsertCall<'a, C> {
2800        self._scopes.clear();
2801        self
2802    }
2803}
2804
2805/// Retrieves a list of contacts for the authenticated user.
2806///
2807/// A builder for the *list* method supported by a *contact* resource.
2808/// It is not used directly, but through a [`ContactMethods`] instance.
2809///
2810/// # Example
2811///
2812/// Instantiate a resource method builder
2813///
2814/// ```test_harness,no_run
2815/// # extern crate hyper;
2816/// # extern crate hyper_rustls;
2817/// # extern crate google_mirror1 as mirror1;
2818/// # async fn dox() {
2819/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2820///
2821/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2822/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2823/// #     .with_native_roots()
2824/// #     .unwrap()
2825/// #     .https_only()
2826/// #     .enable_http2()
2827/// #     .build();
2828///
2829/// # let executor = hyper_util::rt::TokioExecutor::new();
2830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2831/// #     secret,
2832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2833/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2834/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2835/// #     ),
2836/// # ).build().await.unwrap();
2837///
2838/// # let client = hyper_util::client::legacy::Client::builder(
2839/// #     hyper_util::rt::TokioExecutor::new()
2840/// # )
2841/// # .build(
2842/// #     hyper_rustls::HttpsConnectorBuilder::new()
2843/// #         .with_native_roots()
2844/// #         .unwrap()
2845/// #         .https_or_http()
2846/// #         .enable_http2()
2847/// #         .build()
2848/// # );
2849/// # let mut hub = Mirror::new(client, auth);
2850/// // You can configure optional parameters by calling the respective setters at will, and
2851/// // execute the final call using `doit()`.
2852/// // Values shown here are possibly random and not representative !
2853/// let result = hub.contacts().list()
2854///              .doit().await;
2855/// # }
2856/// ```
2857pub struct ContactListCall<'a, C>
2858where
2859    C: 'a,
2860{
2861    hub: &'a Mirror<C>,
2862    _delegate: Option<&'a mut dyn common::Delegate>,
2863    _additional_params: HashMap<String, String>,
2864    _scopes: BTreeSet<String>,
2865}
2866
2867impl<'a, C> common::CallBuilder for ContactListCall<'a, C> {}
2868
2869impl<'a, C> ContactListCall<'a, C>
2870where
2871    C: common::Connector,
2872{
2873    /// Perform the operation you have build so far.
2874    pub async fn doit(mut self) -> common::Result<(common::Response, ContactsListResponse)> {
2875        use std::borrow::Cow;
2876        use std::io::{Read, Seek};
2877
2878        use common::{url::Params, ToParts};
2879        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2880
2881        let mut dd = common::DefaultDelegate;
2882        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2883        dlg.begin(common::MethodInfo {
2884            id: "mirror.contacts.list",
2885            http_method: hyper::Method::GET,
2886        });
2887
2888        for &field in ["alt"].iter() {
2889            if self._additional_params.contains_key(field) {
2890                dlg.finished(false);
2891                return Err(common::Error::FieldClash(field));
2892            }
2893        }
2894
2895        let mut params = Params::with_capacity(2 + self._additional_params.len());
2896
2897        params.extend(self._additional_params.iter());
2898
2899        params.push("alt", "json");
2900        let mut url = self.hub._base_url.clone() + "contacts";
2901        if self._scopes.is_empty() {
2902            self._scopes
2903                .insert(Scope::GlasTimeline.as_ref().to_string());
2904        }
2905
2906        let url = params.parse_with_url(&url);
2907
2908        loop {
2909            let token = match self
2910                .hub
2911                .auth
2912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2913                .await
2914            {
2915                Ok(token) => token,
2916                Err(e) => match dlg.token(e) {
2917                    Ok(token) => token,
2918                    Err(e) => {
2919                        dlg.finished(false);
2920                        return Err(common::Error::MissingToken(e));
2921                    }
2922                },
2923            };
2924            let mut req_result = {
2925                let client = &self.hub.client;
2926                dlg.pre_request();
2927                let mut req_builder = hyper::Request::builder()
2928                    .method(hyper::Method::GET)
2929                    .uri(url.as_str())
2930                    .header(USER_AGENT, self.hub._user_agent.clone());
2931
2932                if let Some(token) = token.as_ref() {
2933                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2934                }
2935
2936                let request = req_builder
2937                    .header(CONTENT_LENGTH, 0_u64)
2938                    .body(common::to_body::<String>(None));
2939
2940                client.request(request.unwrap()).await
2941            };
2942
2943            match req_result {
2944                Err(err) => {
2945                    if let common::Retry::After(d) = dlg.http_error(&err) {
2946                        sleep(d).await;
2947                        continue;
2948                    }
2949                    dlg.finished(false);
2950                    return Err(common::Error::HttpError(err));
2951                }
2952                Ok(res) => {
2953                    let (mut parts, body) = res.into_parts();
2954                    let mut body = common::Body::new(body);
2955                    if !parts.status.is_success() {
2956                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2957                        let error = serde_json::from_str(&common::to_string(&bytes));
2958                        let response = common::to_response(parts, bytes.into());
2959
2960                        if let common::Retry::After(d) =
2961                            dlg.http_failure(&response, error.as_ref().ok())
2962                        {
2963                            sleep(d).await;
2964                            continue;
2965                        }
2966
2967                        dlg.finished(false);
2968
2969                        return Err(match error {
2970                            Ok(value) => common::Error::BadRequest(value),
2971                            _ => common::Error::Failure(response),
2972                        });
2973                    }
2974                    let response = {
2975                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2976                        let encoded = common::to_string(&bytes);
2977                        match serde_json::from_str(&encoded) {
2978                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2979                            Err(error) => {
2980                                dlg.response_json_decode_error(&encoded, &error);
2981                                return Err(common::Error::JsonDecodeError(
2982                                    encoded.to_string(),
2983                                    error,
2984                                ));
2985                            }
2986                        }
2987                    };
2988
2989                    dlg.finished(true);
2990                    return Ok(response);
2991                }
2992            }
2993        }
2994    }
2995
2996    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2997    /// while executing the actual API request.
2998    ///
2999    /// ````text
3000    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3001    /// ````
3002    ///
3003    /// Sets the *delegate* property to the given value.
3004    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactListCall<'a, C> {
3005        self._delegate = Some(new_value);
3006        self
3007    }
3008
3009    /// Set any additional parameter of the query string used in the request.
3010    /// It should be used to set parameters which are not yet available through their own
3011    /// setters.
3012    ///
3013    /// Please note that this method must not be used to set any of the known parameters
3014    /// which have their own setter method. If done anyway, the request will fail.
3015    ///
3016    /// # Additional Parameters
3017    ///
3018    /// * *alt* (query-string) - Data format for the response.
3019    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3020    /// * *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.
3021    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3022    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3023    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3024    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3025    pub fn param<T>(mut self, name: T, value: T) -> ContactListCall<'a, C>
3026    where
3027        T: AsRef<str>,
3028    {
3029        self._additional_params
3030            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3031        self
3032    }
3033
3034    /// Identifies the authorization scope for the method you are building.
3035    ///
3036    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3037    /// [`Scope::GlasTimeline`].
3038    ///
3039    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3040    /// tokens for more than one scope.
3041    ///
3042    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3043    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3044    /// sufficient, a read-write scope will do as well.
3045    pub fn add_scope<St>(mut self, scope: St) -> ContactListCall<'a, C>
3046    where
3047        St: AsRef<str>,
3048    {
3049        self._scopes.insert(String::from(scope.as_ref()));
3050        self
3051    }
3052    /// Identifies the authorization scope(s) for the method you are building.
3053    ///
3054    /// See [`Self::add_scope()`] for details.
3055    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactListCall<'a, C>
3056    where
3057        I: IntoIterator<Item = St>,
3058        St: AsRef<str>,
3059    {
3060        self._scopes
3061            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3062        self
3063    }
3064
3065    /// Removes all scopes, and no default scope will be used either.
3066    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3067    /// for details).
3068    pub fn clear_scopes(mut self) -> ContactListCall<'a, C> {
3069        self._scopes.clear();
3070        self
3071    }
3072}
3073
3074/// Updates a contact in place. This method supports patch semantics.
3075///
3076/// A builder for the *patch* method supported by a *contact* resource.
3077/// It is not used directly, but through a [`ContactMethods`] instance.
3078///
3079/// # Example
3080///
3081/// Instantiate a resource method builder
3082///
3083/// ```test_harness,no_run
3084/// # extern crate hyper;
3085/// # extern crate hyper_rustls;
3086/// # extern crate google_mirror1 as mirror1;
3087/// use mirror1::api::Contact;
3088/// # async fn dox() {
3089/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3090///
3091/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3092/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3093/// #     .with_native_roots()
3094/// #     .unwrap()
3095/// #     .https_only()
3096/// #     .enable_http2()
3097/// #     .build();
3098///
3099/// # let executor = hyper_util::rt::TokioExecutor::new();
3100/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3101/// #     secret,
3102/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3103/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3104/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3105/// #     ),
3106/// # ).build().await.unwrap();
3107///
3108/// # let client = hyper_util::client::legacy::Client::builder(
3109/// #     hyper_util::rt::TokioExecutor::new()
3110/// # )
3111/// # .build(
3112/// #     hyper_rustls::HttpsConnectorBuilder::new()
3113/// #         .with_native_roots()
3114/// #         .unwrap()
3115/// #         .https_or_http()
3116/// #         .enable_http2()
3117/// #         .build()
3118/// # );
3119/// # let mut hub = Mirror::new(client, auth);
3120/// // As the method needs a request, you would usually fill it with the desired information
3121/// // into the respective structure. Some of the parts shown here might not be applicable !
3122/// // Values shown here are possibly random and not representative !
3123/// let mut req = Contact::default();
3124///
3125/// // You can configure optional parameters by calling the respective setters at will, and
3126/// // execute the final call using `doit()`.
3127/// // Values shown here are possibly random and not representative !
3128/// let result = hub.contacts().patch(req, "id")
3129///              .doit().await;
3130/// # }
3131/// ```
3132pub struct ContactPatchCall<'a, C>
3133where
3134    C: 'a,
3135{
3136    hub: &'a Mirror<C>,
3137    _request: Contact,
3138    _id: String,
3139    _delegate: Option<&'a mut dyn common::Delegate>,
3140    _additional_params: HashMap<String, String>,
3141    _scopes: BTreeSet<String>,
3142}
3143
3144impl<'a, C> common::CallBuilder for ContactPatchCall<'a, C> {}
3145
3146impl<'a, C> ContactPatchCall<'a, C>
3147where
3148    C: common::Connector,
3149{
3150    /// Perform the operation you have build so far.
3151    pub async fn doit(mut self) -> common::Result<(common::Response, Contact)> {
3152        use std::borrow::Cow;
3153        use std::io::{Read, Seek};
3154
3155        use common::{url::Params, ToParts};
3156        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3157
3158        let mut dd = common::DefaultDelegate;
3159        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3160        dlg.begin(common::MethodInfo {
3161            id: "mirror.contacts.patch",
3162            http_method: hyper::Method::PATCH,
3163        });
3164
3165        for &field in ["alt", "id"].iter() {
3166            if self._additional_params.contains_key(field) {
3167                dlg.finished(false);
3168                return Err(common::Error::FieldClash(field));
3169            }
3170        }
3171
3172        let mut params = Params::with_capacity(4 + self._additional_params.len());
3173        params.push("id", self._id);
3174
3175        params.extend(self._additional_params.iter());
3176
3177        params.push("alt", "json");
3178        let mut url = self.hub._base_url.clone() + "contacts/{id}";
3179        if self._scopes.is_empty() {
3180            self._scopes
3181                .insert(Scope::GlasTimeline.as_ref().to_string());
3182        }
3183
3184        #[allow(clippy::single_element_loop)]
3185        for &(find_this, param_name) in [("{id}", "id")].iter() {
3186            url = params.uri_replacement(url, param_name, find_this, false);
3187        }
3188        {
3189            let to_remove = ["id"];
3190            params.remove_params(&to_remove);
3191        }
3192
3193        let url = params.parse_with_url(&url);
3194
3195        let mut json_mime_type = mime::APPLICATION_JSON;
3196        let mut request_value_reader = {
3197            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3198            common::remove_json_null_values(&mut value);
3199            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3200            serde_json::to_writer(&mut dst, &value).unwrap();
3201            dst
3202        };
3203        let request_size = request_value_reader
3204            .seek(std::io::SeekFrom::End(0))
3205            .unwrap();
3206        request_value_reader
3207            .seek(std::io::SeekFrom::Start(0))
3208            .unwrap();
3209
3210        loop {
3211            let token = match self
3212                .hub
3213                .auth
3214                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3215                .await
3216            {
3217                Ok(token) => token,
3218                Err(e) => match dlg.token(e) {
3219                    Ok(token) => token,
3220                    Err(e) => {
3221                        dlg.finished(false);
3222                        return Err(common::Error::MissingToken(e));
3223                    }
3224                },
3225            };
3226            request_value_reader
3227                .seek(std::io::SeekFrom::Start(0))
3228                .unwrap();
3229            let mut req_result = {
3230                let client = &self.hub.client;
3231                dlg.pre_request();
3232                let mut req_builder = hyper::Request::builder()
3233                    .method(hyper::Method::PATCH)
3234                    .uri(url.as_str())
3235                    .header(USER_AGENT, self.hub._user_agent.clone());
3236
3237                if let Some(token) = token.as_ref() {
3238                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3239                }
3240
3241                let request = req_builder
3242                    .header(CONTENT_TYPE, json_mime_type.to_string())
3243                    .header(CONTENT_LENGTH, request_size as u64)
3244                    .body(common::to_body(
3245                        request_value_reader.get_ref().clone().into(),
3246                    ));
3247
3248                client.request(request.unwrap()).await
3249            };
3250
3251            match req_result {
3252                Err(err) => {
3253                    if let common::Retry::After(d) = dlg.http_error(&err) {
3254                        sleep(d).await;
3255                        continue;
3256                    }
3257                    dlg.finished(false);
3258                    return Err(common::Error::HttpError(err));
3259                }
3260                Ok(res) => {
3261                    let (mut parts, body) = res.into_parts();
3262                    let mut body = common::Body::new(body);
3263                    if !parts.status.is_success() {
3264                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3265                        let error = serde_json::from_str(&common::to_string(&bytes));
3266                        let response = common::to_response(parts, bytes.into());
3267
3268                        if let common::Retry::After(d) =
3269                            dlg.http_failure(&response, error.as_ref().ok())
3270                        {
3271                            sleep(d).await;
3272                            continue;
3273                        }
3274
3275                        dlg.finished(false);
3276
3277                        return Err(match error {
3278                            Ok(value) => common::Error::BadRequest(value),
3279                            _ => common::Error::Failure(response),
3280                        });
3281                    }
3282                    let response = {
3283                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3284                        let encoded = common::to_string(&bytes);
3285                        match serde_json::from_str(&encoded) {
3286                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3287                            Err(error) => {
3288                                dlg.response_json_decode_error(&encoded, &error);
3289                                return Err(common::Error::JsonDecodeError(
3290                                    encoded.to_string(),
3291                                    error,
3292                                ));
3293                            }
3294                        }
3295                    };
3296
3297                    dlg.finished(true);
3298                    return Ok(response);
3299                }
3300            }
3301        }
3302    }
3303
3304    ///
3305    /// Sets the *request* property to the given value.
3306    ///
3307    /// Even though the property as already been set when instantiating this call,
3308    /// we provide this method for API completeness.
3309    pub fn request(mut self, new_value: Contact) -> ContactPatchCall<'a, C> {
3310        self._request = new_value;
3311        self
3312    }
3313    /// The ID of the contact.
3314    ///
3315    /// Sets the *id* path property to the given value.
3316    ///
3317    /// Even though the property as already been set when instantiating this call,
3318    /// we provide this method for API completeness.
3319    pub fn id(mut self, new_value: &str) -> ContactPatchCall<'a, C> {
3320        self._id = new_value.to_string();
3321        self
3322    }
3323    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3324    /// while executing the actual API request.
3325    ///
3326    /// ````text
3327    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3328    /// ````
3329    ///
3330    /// Sets the *delegate* property to the given value.
3331    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactPatchCall<'a, C> {
3332        self._delegate = Some(new_value);
3333        self
3334    }
3335
3336    /// Set any additional parameter of the query string used in the request.
3337    /// It should be used to set parameters which are not yet available through their own
3338    /// setters.
3339    ///
3340    /// Please note that this method must not be used to set any of the known parameters
3341    /// which have their own setter method. If done anyway, the request will fail.
3342    ///
3343    /// # Additional Parameters
3344    ///
3345    /// * *alt* (query-string) - Data format for the response.
3346    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3347    /// * *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.
3348    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3349    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3350    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3351    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3352    pub fn param<T>(mut self, name: T, value: T) -> ContactPatchCall<'a, C>
3353    where
3354        T: AsRef<str>,
3355    {
3356        self._additional_params
3357            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3358        self
3359    }
3360
3361    /// Identifies the authorization scope for the method you are building.
3362    ///
3363    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3364    /// [`Scope::GlasTimeline`].
3365    ///
3366    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3367    /// tokens for more than one scope.
3368    ///
3369    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3370    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3371    /// sufficient, a read-write scope will do as well.
3372    pub fn add_scope<St>(mut self, scope: St) -> ContactPatchCall<'a, C>
3373    where
3374        St: AsRef<str>,
3375    {
3376        self._scopes.insert(String::from(scope.as_ref()));
3377        self
3378    }
3379    /// Identifies the authorization scope(s) for the method you are building.
3380    ///
3381    /// See [`Self::add_scope()`] for details.
3382    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactPatchCall<'a, C>
3383    where
3384        I: IntoIterator<Item = St>,
3385        St: AsRef<str>,
3386    {
3387        self._scopes
3388            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3389        self
3390    }
3391
3392    /// Removes all scopes, and no default scope will be used either.
3393    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3394    /// for details).
3395    pub fn clear_scopes(mut self) -> ContactPatchCall<'a, C> {
3396        self._scopes.clear();
3397        self
3398    }
3399}
3400
3401/// Updates a contact in place.
3402///
3403/// A builder for the *update* method supported by a *contact* resource.
3404/// It is not used directly, but through a [`ContactMethods`] instance.
3405///
3406/// # Example
3407///
3408/// Instantiate a resource method builder
3409///
3410/// ```test_harness,no_run
3411/// # extern crate hyper;
3412/// # extern crate hyper_rustls;
3413/// # extern crate google_mirror1 as mirror1;
3414/// use mirror1::api::Contact;
3415/// # async fn dox() {
3416/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3417///
3418/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3419/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3420/// #     .with_native_roots()
3421/// #     .unwrap()
3422/// #     .https_only()
3423/// #     .enable_http2()
3424/// #     .build();
3425///
3426/// # let executor = hyper_util::rt::TokioExecutor::new();
3427/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3428/// #     secret,
3429/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3430/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3431/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3432/// #     ),
3433/// # ).build().await.unwrap();
3434///
3435/// # let client = hyper_util::client::legacy::Client::builder(
3436/// #     hyper_util::rt::TokioExecutor::new()
3437/// # )
3438/// # .build(
3439/// #     hyper_rustls::HttpsConnectorBuilder::new()
3440/// #         .with_native_roots()
3441/// #         .unwrap()
3442/// #         .https_or_http()
3443/// #         .enable_http2()
3444/// #         .build()
3445/// # );
3446/// # let mut hub = Mirror::new(client, auth);
3447/// // As the method needs a request, you would usually fill it with the desired information
3448/// // into the respective structure. Some of the parts shown here might not be applicable !
3449/// // Values shown here are possibly random and not representative !
3450/// let mut req = Contact::default();
3451///
3452/// // You can configure optional parameters by calling the respective setters at will, and
3453/// // execute the final call using `doit()`.
3454/// // Values shown here are possibly random and not representative !
3455/// let result = hub.contacts().update(req, "id")
3456///              .doit().await;
3457/// # }
3458/// ```
3459pub struct ContactUpdateCall<'a, C>
3460where
3461    C: 'a,
3462{
3463    hub: &'a Mirror<C>,
3464    _request: Contact,
3465    _id: String,
3466    _delegate: Option<&'a mut dyn common::Delegate>,
3467    _additional_params: HashMap<String, String>,
3468    _scopes: BTreeSet<String>,
3469}
3470
3471impl<'a, C> common::CallBuilder for ContactUpdateCall<'a, C> {}
3472
3473impl<'a, C> ContactUpdateCall<'a, C>
3474where
3475    C: common::Connector,
3476{
3477    /// Perform the operation you have build so far.
3478    pub async fn doit(mut self) -> common::Result<(common::Response, Contact)> {
3479        use std::borrow::Cow;
3480        use std::io::{Read, Seek};
3481
3482        use common::{url::Params, ToParts};
3483        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3484
3485        let mut dd = common::DefaultDelegate;
3486        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3487        dlg.begin(common::MethodInfo {
3488            id: "mirror.contacts.update",
3489            http_method: hyper::Method::PUT,
3490        });
3491
3492        for &field in ["alt", "id"].iter() {
3493            if self._additional_params.contains_key(field) {
3494                dlg.finished(false);
3495                return Err(common::Error::FieldClash(field));
3496            }
3497        }
3498
3499        let mut params = Params::with_capacity(4 + self._additional_params.len());
3500        params.push("id", self._id);
3501
3502        params.extend(self._additional_params.iter());
3503
3504        params.push("alt", "json");
3505        let mut url = self.hub._base_url.clone() + "contacts/{id}";
3506        if self._scopes.is_empty() {
3507            self._scopes
3508                .insert(Scope::GlasTimeline.as_ref().to_string());
3509        }
3510
3511        #[allow(clippy::single_element_loop)]
3512        for &(find_this, param_name) in [("{id}", "id")].iter() {
3513            url = params.uri_replacement(url, param_name, find_this, false);
3514        }
3515        {
3516            let to_remove = ["id"];
3517            params.remove_params(&to_remove);
3518        }
3519
3520        let url = params.parse_with_url(&url);
3521
3522        let mut json_mime_type = mime::APPLICATION_JSON;
3523        let mut request_value_reader = {
3524            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3525            common::remove_json_null_values(&mut value);
3526            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3527            serde_json::to_writer(&mut dst, &value).unwrap();
3528            dst
3529        };
3530        let request_size = request_value_reader
3531            .seek(std::io::SeekFrom::End(0))
3532            .unwrap();
3533        request_value_reader
3534            .seek(std::io::SeekFrom::Start(0))
3535            .unwrap();
3536
3537        loop {
3538            let token = match self
3539                .hub
3540                .auth
3541                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3542                .await
3543            {
3544                Ok(token) => token,
3545                Err(e) => match dlg.token(e) {
3546                    Ok(token) => token,
3547                    Err(e) => {
3548                        dlg.finished(false);
3549                        return Err(common::Error::MissingToken(e));
3550                    }
3551                },
3552            };
3553            request_value_reader
3554                .seek(std::io::SeekFrom::Start(0))
3555                .unwrap();
3556            let mut req_result = {
3557                let client = &self.hub.client;
3558                dlg.pre_request();
3559                let mut req_builder = hyper::Request::builder()
3560                    .method(hyper::Method::PUT)
3561                    .uri(url.as_str())
3562                    .header(USER_AGENT, self.hub._user_agent.clone());
3563
3564                if let Some(token) = token.as_ref() {
3565                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3566                }
3567
3568                let request = req_builder
3569                    .header(CONTENT_TYPE, json_mime_type.to_string())
3570                    .header(CONTENT_LENGTH, request_size as u64)
3571                    .body(common::to_body(
3572                        request_value_reader.get_ref().clone().into(),
3573                    ));
3574
3575                client.request(request.unwrap()).await
3576            };
3577
3578            match req_result {
3579                Err(err) => {
3580                    if let common::Retry::After(d) = dlg.http_error(&err) {
3581                        sleep(d).await;
3582                        continue;
3583                    }
3584                    dlg.finished(false);
3585                    return Err(common::Error::HttpError(err));
3586                }
3587                Ok(res) => {
3588                    let (mut parts, body) = res.into_parts();
3589                    let mut body = common::Body::new(body);
3590                    if !parts.status.is_success() {
3591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3592                        let error = serde_json::from_str(&common::to_string(&bytes));
3593                        let response = common::to_response(parts, bytes.into());
3594
3595                        if let common::Retry::After(d) =
3596                            dlg.http_failure(&response, error.as_ref().ok())
3597                        {
3598                            sleep(d).await;
3599                            continue;
3600                        }
3601
3602                        dlg.finished(false);
3603
3604                        return Err(match error {
3605                            Ok(value) => common::Error::BadRequest(value),
3606                            _ => common::Error::Failure(response),
3607                        });
3608                    }
3609                    let response = {
3610                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3611                        let encoded = common::to_string(&bytes);
3612                        match serde_json::from_str(&encoded) {
3613                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3614                            Err(error) => {
3615                                dlg.response_json_decode_error(&encoded, &error);
3616                                return Err(common::Error::JsonDecodeError(
3617                                    encoded.to_string(),
3618                                    error,
3619                                ));
3620                            }
3621                        }
3622                    };
3623
3624                    dlg.finished(true);
3625                    return Ok(response);
3626                }
3627            }
3628        }
3629    }
3630
3631    ///
3632    /// Sets the *request* property to the given value.
3633    ///
3634    /// Even though the property as already been set when instantiating this call,
3635    /// we provide this method for API completeness.
3636    pub fn request(mut self, new_value: Contact) -> ContactUpdateCall<'a, C> {
3637        self._request = new_value;
3638        self
3639    }
3640    /// The ID of the contact.
3641    ///
3642    /// Sets the *id* path property to the given value.
3643    ///
3644    /// Even though the property as already been set when instantiating this call,
3645    /// we provide this method for API completeness.
3646    pub fn id(mut self, new_value: &str) -> ContactUpdateCall<'a, C> {
3647        self._id = new_value.to_string();
3648        self
3649    }
3650    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3651    /// while executing the actual API request.
3652    ///
3653    /// ````text
3654    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3655    /// ````
3656    ///
3657    /// Sets the *delegate* property to the given value.
3658    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ContactUpdateCall<'a, C> {
3659        self._delegate = Some(new_value);
3660        self
3661    }
3662
3663    /// Set any additional parameter of the query string used in the request.
3664    /// It should be used to set parameters which are not yet available through their own
3665    /// setters.
3666    ///
3667    /// Please note that this method must not be used to set any of the known parameters
3668    /// which have their own setter method. If done anyway, the request will fail.
3669    ///
3670    /// # Additional Parameters
3671    ///
3672    /// * *alt* (query-string) - Data format for the response.
3673    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3674    /// * *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.
3675    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3676    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3677    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3678    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3679    pub fn param<T>(mut self, name: T, value: T) -> ContactUpdateCall<'a, C>
3680    where
3681        T: AsRef<str>,
3682    {
3683        self._additional_params
3684            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3685        self
3686    }
3687
3688    /// Identifies the authorization scope for the method you are building.
3689    ///
3690    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3691    /// [`Scope::GlasTimeline`].
3692    ///
3693    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3694    /// tokens for more than one scope.
3695    ///
3696    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3697    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3698    /// sufficient, a read-write scope will do as well.
3699    pub fn add_scope<St>(mut self, scope: St) -> ContactUpdateCall<'a, C>
3700    where
3701        St: AsRef<str>,
3702    {
3703        self._scopes.insert(String::from(scope.as_ref()));
3704        self
3705    }
3706    /// Identifies the authorization scope(s) for the method you are building.
3707    ///
3708    /// See [`Self::add_scope()`] for details.
3709    pub fn add_scopes<I, St>(mut self, scopes: I) -> ContactUpdateCall<'a, C>
3710    where
3711        I: IntoIterator<Item = St>,
3712        St: AsRef<str>,
3713    {
3714        self._scopes
3715            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3716        self
3717    }
3718
3719    /// Removes all scopes, and no default scope will be used either.
3720    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3721    /// for details).
3722    pub fn clear_scopes(mut self) -> ContactUpdateCall<'a, C> {
3723        self._scopes.clear();
3724        self
3725    }
3726}
3727
3728/// Gets a single location by ID.
3729///
3730/// A builder for the *get* method supported by a *location* resource.
3731/// It is not used directly, but through a [`LocationMethods`] instance.
3732///
3733/// # Example
3734///
3735/// Instantiate a resource method builder
3736///
3737/// ```test_harness,no_run
3738/// # extern crate hyper;
3739/// # extern crate hyper_rustls;
3740/// # extern crate google_mirror1 as mirror1;
3741/// # async fn dox() {
3742/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3743///
3744/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3745/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3746/// #     .with_native_roots()
3747/// #     .unwrap()
3748/// #     .https_only()
3749/// #     .enable_http2()
3750/// #     .build();
3751///
3752/// # let executor = hyper_util::rt::TokioExecutor::new();
3753/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3754/// #     secret,
3755/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3756/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3757/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3758/// #     ),
3759/// # ).build().await.unwrap();
3760///
3761/// # let client = hyper_util::client::legacy::Client::builder(
3762/// #     hyper_util::rt::TokioExecutor::new()
3763/// # )
3764/// # .build(
3765/// #     hyper_rustls::HttpsConnectorBuilder::new()
3766/// #         .with_native_roots()
3767/// #         .unwrap()
3768/// #         .https_or_http()
3769/// #         .enable_http2()
3770/// #         .build()
3771/// # );
3772/// # let mut hub = Mirror::new(client, auth);
3773/// // You can configure optional parameters by calling the respective setters at will, and
3774/// // execute the final call using `doit()`.
3775/// // Values shown here are possibly random and not representative !
3776/// let result = hub.locations().get("id")
3777///              .doit().await;
3778/// # }
3779/// ```
3780pub struct LocationGetCall<'a, C>
3781where
3782    C: 'a,
3783{
3784    hub: &'a Mirror<C>,
3785    _id: String,
3786    _delegate: Option<&'a mut dyn common::Delegate>,
3787    _additional_params: HashMap<String, String>,
3788    _scopes: BTreeSet<String>,
3789}
3790
3791impl<'a, C> common::CallBuilder for LocationGetCall<'a, C> {}
3792
3793impl<'a, C> LocationGetCall<'a, C>
3794where
3795    C: common::Connector,
3796{
3797    /// Perform the operation you have build so far.
3798    pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
3799        use std::borrow::Cow;
3800        use std::io::{Read, Seek};
3801
3802        use common::{url::Params, ToParts};
3803        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3804
3805        let mut dd = common::DefaultDelegate;
3806        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3807        dlg.begin(common::MethodInfo {
3808            id: "mirror.locations.get",
3809            http_method: hyper::Method::GET,
3810        });
3811
3812        for &field in ["alt", "id"].iter() {
3813            if self._additional_params.contains_key(field) {
3814                dlg.finished(false);
3815                return Err(common::Error::FieldClash(field));
3816            }
3817        }
3818
3819        let mut params = Params::with_capacity(3 + self._additional_params.len());
3820        params.push("id", self._id);
3821
3822        params.extend(self._additional_params.iter());
3823
3824        params.push("alt", "json");
3825        let mut url = self.hub._base_url.clone() + "locations/{id}";
3826        if self._scopes.is_empty() {
3827            self._scopes
3828                .insert(Scope::GlasLocation.as_ref().to_string());
3829        }
3830
3831        #[allow(clippy::single_element_loop)]
3832        for &(find_this, param_name) in [("{id}", "id")].iter() {
3833            url = params.uri_replacement(url, param_name, find_this, false);
3834        }
3835        {
3836            let to_remove = ["id"];
3837            params.remove_params(&to_remove);
3838        }
3839
3840        let url = params.parse_with_url(&url);
3841
3842        loop {
3843            let token = match self
3844                .hub
3845                .auth
3846                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3847                .await
3848            {
3849                Ok(token) => token,
3850                Err(e) => match dlg.token(e) {
3851                    Ok(token) => token,
3852                    Err(e) => {
3853                        dlg.finished(false);
3854                        return Err(common::Error::MissingToken(e));
3855                    }
3856                },
3857            };
3858            let mut req_result = {
3859                let client = &self.hub.client;
3860                dlg.pre_request();
3861                let mut req_builder = hyper::Request::builder()
3862                    .method(hyper::Method::GET)
3863                    .uri(url.as_str())
3864                    .header(USER_AGENT, self.hub._user_agent.clone());
3865
3866                if let Some(token) = token.as_ref() {
3867                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3868                }
3869
3870                let request = req_builder
3871                    .header(CONTENT_LENGTH, 0_u64)
3872                    .body(common::to_body::<String>(None));
3873
3874                client.request(request.unwrap()).await
3875            };
3876
3877            match req_result {
3878                Err(err) => {
3879                    if let common::Retry::After(d) = dlg.http_error(&err) {
3880                        sleep(d).await;
3881                        continue;
3882                    }
3883                    dlg.finished(false);
3884                    return Err(common::Error::HttpError(err));
3885                }
3886                Ok(res) => {
3887                    let (mut parts, body) = res.into_parts();
3888                    let mut body = common::Body::new(body);
3889                    if !parts.status.is_success() {
3890                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3891                        let error = serde_json::from_str(&common::to_string(&bytes));
3892                        let response = common::to_response(parts, bytes.into());
3893
3894                        if let common::Retry::After(d) =
3895                            dlg.http_failure(&response, error.as_ref().ok())
3896                        {
3897                            sleep(d).await;
3898                            continue;
3899                        }
3900
3901                        dlg.finished(false);
3902
3903                        return Err(match error {
3904                            Ok(value) => common::Error::BadRequest(value),
3905                            _ => common::Error::Failure(response),
3906                        });
3907                    }
3908                    let response = {
3909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3910                        let encoded = common::to_string(&bytes);
3911                        match serde_json::from_str(&encoded) {
3912                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3913                            Err(error) => {
3914                                dlg.response_json_decode_error(&encoded, &error);
3915                                return Err(common::Error::JsonDecodeError(
3916                                    encoded.to_string(),
3917                                    error,
3918                                ));
3919                            }
3920                        }
3921                    };
3922
3923                    dlg.finished(true);
3924                    return Ok(response);
3925                }
3926            }
3927        }
3928    }
3929
3930    /// The ID of the location or latest for the last known location.
3931    ///
3932    /// Sets the *id* path property to the given value.
3933    ///
3934    /// Even though the property as already been set when instantiating this call,
3935    /// we provide this method for API completeness.
3936    pub fn id(mut self, new_value: &str) -> LocationGetCall<'a, C> {
3937        self._id = new_value.to_string();
3938        self
3939    }
3940    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3941    /// while executing the actual API request.
3942    ///
3943    /// ````text
3944    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3945    /// ````
3946    ///
3947    /// Sets the *delegate* property to the given value.
3948    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LocationGetCall<'a, C> {
3949        self._delegate = Some(new_value);
3950        self
3951    }
3952
3953    /// Set any additional parameter of the query string used in the request.
3954    /// It should be used to set parameters which are not yet available through their own
3955    /// setters.
3956    ///
3957    /// Please note that this method must not be used to set any of the known parameters
3958    /// which have their own setter method. If done anyway, the request will fail.
3959    ///
3960    /// # Additional Parameters
3961    ///
3962    /// * *alt* (query-string) - Data format for the response.
3963    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3964    /// * *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.
3965    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3966    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3967    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3968    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3969    pub fn param<T>(mut self, name: T, value: T) -> LocationGetCall<'a, C>
3970    where
3971        T: AsRef<str>,
3972    {
3973        self._additional_params
3974            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3975        self
3976    }
3977
3978    /// Identifies the authorization scope for the method you are building.
3979    ///
3980    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3981    /// [`Scope::GlasLocation`].
3982    ///
3983    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3984    /// tokens for more than one scope.
3985    ///
3986    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3987    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3988    /// sufficient, a read-write scope will do as well.
3989    pub fn add_scope<St>(mut self, scope: St) -> LocationGetCall<'a, C>
3990    where
3991        St: AsRef<str>,
3992    {
3993        self._scopes.insert(String::from(scope.as_ref()));
3994        self
3995    }
3996    /// Identifies the authorization scope(s) for the method you are building.
3997    ///
3998    /// See [`Self::add_scope()`] for details.
3999    pub fn add_scopes<I, St>(mut self, scopes: I) -> LocationGetCall<'a, C>
4000    where
4001        I: IntoIterator<Item = St>,
4002        St: AsRef<str>,
4003    {
4004        self._scopes
4005            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4006        self
4007    }
4008
4009    /// Removes all scopes, and no default scope will be used either.
4010    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4011    /// for details).
4012    pub fn clear_scopes(mut self) -> LocationGetCall<'a, C> {
4013        self._scopes.clear();
4014        self
4015    }
4016}
4017
4018/// Retrieves a list of locations for the user.
4019///
4020/// A builder for the *list* method supported by a *location* resource.
4021/// It is not used directly, but through a [`LocationMethods`] instance.
4022///
4023/// # Example
4024///
4025/// Instantiate a resource method builder
4026///
4027/// ```test_harness,no_run
4028/// # extern crate hyper;
4029/// # extern crate hyper_rustls;
4030/// # extern crate google_mirror1 as mirror1;
4031/// # async fn dox() {
4032/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4033///
4034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4035/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4036/// #     .with_native_roots()
4037/// #     .unwrap()
4038/// #     .https_only()
4039/// #     .enable_http2()
4040/// #     .build();
4041///
4042/// # let executor = hyper_util::rt::TokioExecutor::new();
4043/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4044/// #     secret,
4045/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4046/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4047/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4048/// #     ),
4049/// # ).build().await.unwrap();
4050///
4051/// # let client = hyper_util::client::legacy::Client::builder(
4052/// #     hyper_util::rt::TokioExecutor::new()
4053/// # )
4054/// # .build(
4055/// #     hyper_rustls::HttpsConnectorBuilder::new()
4056/// #         .with_native_roots()
4057/// #         .unwrap()
4058/// #         .https_or_http()
4059/// #         .enable_http2()
4060/// #         .build()
4061/// # );
4062/// # let mut hub = Mirror::new(client, auth);
4063/// // You can configure optional parameters by calling the respective setters at will, and
4064/// // execute the final call using `doit()`.
4065/// // Values shown here are possibly random and not representative !
4066/// let result = hub.locations().list()
4067///              .doit().await;
4068/// # }
4069/// ```
4070pub struct LocationListCall<'a, C>
4071where
4072    C: 'a,
4073{
4074    hub: &'a Mirror<C>,
4075    _delegate: Option<&'a mut dyn common::Delegate>,
4076    _additional_params: HashMap<String, String>,
4077    _scopes: BTreeSet<String>,
4078}
4079
4080impl<'a, C> common::CallBuilder for LocationListCall<'a, C> {}
4081
4082impl<'a, C> LocationListCall<'a, C>
4083where
4084    C: common::Connector,
4085{
4086    /// Perform the operation you have build so far.
4087    pub async fn doit(mut self) -> common::Result<(common::Response, LocationsListResponse)> {
4088        use std::borrow::Cow;
4089        use std::io::{Read, Seek};
4090
4091        use common::{url::Params, ToParts};
4092        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4093
4094        let mut dd = common::DefaultDelegate;
4095        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4096        dlg.begin(common::MethodInfo {
4097            id: "mirror.locations.list",
4098            http_method: hyper::Method::GET,
4099        });
4100
4101        for &field in ["alt"].iter() {
4102            if self._additional_params.contains_key(field) {
4103                dlg.finished(false);
4104                return Err(common::Error::FieldClash(field));
4105            }
4106        }
4107
4108        let mut params = Params::with_capacity(2 + self._additional_params.len());
4109
4110        params.extend(self._additional_params.iter());
4111
4112        params.push("alt", "json");
4113        let mut url = self.hub._base_url.clone() + "locations";
4114        if self._scopes.is_empty() {
4115            self._scopes
4116                .insert(Scope::GlasLocation.as_ref().to_string());
4117        }
4118
4119        let url = params.parse_with_url(&url);
4120
4121        loop {
4122            let token = match self
4123                .hub
4124                .auth
4125                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4126                .await
4127            {
4128                Ok(token) => token,
4129                Err(e) => match dlg.token(e) {
4130                    Ok(token) => token,
4131                    Err(e) => {
4132                        dlg.finished(false);
4133                        return Err(common::Error::MissingToken(e));
4134                    }
4135                },
4136            };
4137            let mut req_result = {
4138                let client = &self.hub.client;
4139                dlg.pre_request();
4140                let mut req_builder = hyper::Request::builder()
4141                    .method(hyper::Method::GET)
4142                    .uri(url.as_str())
4143                    .header(USER_AGENT, self.hub._user_agent.clone());
4144
4145                if let Some(token) = token.as_ref() {
4146                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4147                }
4148
4149                let request = req_builder
4150                    .header(CONTENT_LENGTH, 0_u64)
4151                    .body(common::to_body::<String>(None));
4152
4153                client.request(request.unwrap()).await
4154            };
4155
4156            match req_result {
4157                Err(err) => {
4158                    if let common::Retry::After(d) = dlg.http_error(&err) {
4159                        sleep(d).await;
4160                        continue;
4161                    }
4162                    dlg.finished(false);
4163                    return Err(common::Error::HttpError(err));
4164                }
4165                Ok(res) => {
4166                    let (mut parts, body) = res.into_parts();
4167                    let mut body = common::Body::new(body);
4168                    if !parts.status.is_success() {
4169                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4170                        let error = serde_json::from_str(&common::to_string(&bytes));
4171                        let response = common::to_response(parts, bytes.into());
4172
4173                        if let common::Retry::After(d) =
4174                            dlg.http_failure(&response, error.as_ref().ok())
4175                        {
4176                            sleep(d).await;
4177                            continue;
4178                        }
4179
4180                        dlg.finished(false);
4181
4182                        return Err(match error {
4183                            Ok(value) => common::Error::BadRequest(value),
4184                            _ => common::Error::Failure(response),
4185                        });
4186                    }
4187                    let response = {
4188                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4189                        let encoded = common::to_string(&bytes);
4190                        match serde_json::from_str(&encoded) {
4191                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4192                            Err(error) => {
4193                                dlg.response_json_decode_error(&encoded, &error);
4194                                return Err(common::Error::JsonDecodeError(
4195                                    encoded.to_string(),
4196                                    error,
4197                                ));
4198                            }
4199                        }
4200                    };
4201
4202                    dlg.finished(true);
4203                    return Ok(response);
4204                }
4205            }
4206        }
4207    }
4208
4209    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4210    /// while executing the actual API request.
4211    ///
4212    /// ````text
4213    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4214    /// ````
4215    ///
4216    /// Sets the *delegate* property to the given value.
4217    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LocationListCall<'a, C> {
4218        self._delegate = Some(new_value);
4219        self
4220    }
4221
4222    /// Set any additional parameter of the query string used in the request.
4223    /// It should be used to set parameters which are not yet available through their own
4224    /// setters.
4225    ///
4226    /// Please note that this method must not be used to set any of the known parameters
4227    /// which have their own setter method. If done anyway, the request will fail.
4228    ///
4229    /// # Additional Parameters
4230    ///
4231    /// * *alt* (query-string) - Data format for the response.
4232    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4233    /// * *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.
4234    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4235    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4236    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4237    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4238    pub fn param<T>(mut self, name: T, value: T) -> LocationListCall<'a, C>
4239    where
4240        T: AsRef<str>,
4241    {
4242        self._additional_params
4243            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4244        self
4245    }
4246
4247    /// Identifies the authorization scope for the method you are building.
4248    ///
4249    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4250    /// [`Scope::GlasLocation`].
4251    ///
4252    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4253    /// tokens for more than one scope.
4254    ///
4255    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4256    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4257    /// sufficient, a read-write scope will do as well.
4258    pub fn add_scope<St>(mut self, scope: St) -> LocationListCall<'a, C>
4259    where
4260        St: AsRef<str>,
4261    {
4262        self._scopes.insert(String::from(scope.as_ref()));
4263        self
4264    }
4265    /// Identifies the authorization scope(s) for the method you are building.
4266    ///
4267    /// See [`Self::add_scope()`] for details.
4268    pub fn add_scopes<I, St>(mut self, scopes: I) -> LocationListCall<'a, C>
4269    where
4270        I: IntoIterator<Item = St>,
4271        St: AsRef<str>,
4272    {
4273        self._scopes
4274            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4275        self
4276    }
4277
4278    /// Removes all scopes, and no default scope will be used either.
4279    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4280    /// for details).
4281    pub fn clear_scopes(mut self) -> LocationListCall<'a, C> {
4282        self._scopes.clear();
4283        self
4284    }
4285}
4286
4287/// Gets a single setting by ID.
4288///
4289/// A builder for the *get* method supported by a *setting* resource.
4290/// It is not used directly, but through a [`SettingMethods`] instance.
4291///
4292/// # Example
4293///
4294/// Instantiate a resource method builder
4295///
4296/// ```test_harness,no_run
4297/// # extern crate hyper;
4298/// # extern crate hyper_rustls;
4299/// # extern crate google_mirror1 as mirror1;
4300/// # async fn dox() {
4301/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4302///
4303/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4304/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4305/// #     .with_native_roots()
4306/// #     .unwrap()
4307/// #     .https_only()
4308/// #     .enable_http2()
4309/// #     .build();
4310///
4311/// # let executor = hyper_util::rt::TokioExecutor::new();
4312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4313/// #     secret,
4314/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4315/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4316/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4317/// #     ),
4318/// # ).build().await.unwrap();
4319///
4320/// # let client = hyper_util::client::legacy::Client::builder(
4321/// #     hyper_util::rt::TokioExecutor::new()
4322/// # )
4323/// # .build(
4324/// #     hyper_rustls::HttpsConnectorBuilder::new()
4325/// #         .with_native_roots()
4326/// #         .unwrap()
4327/// #         .https_or_http()
4328/// #         .enable_http2()
4329/// #         .build()
4330/// # );
4331/// # let mut hub = Mirror::new(client, auth);
4332/// // You can configure optional parameters by calling the respective setters at will, and
4333/// // execute the final call using `doit()`.
4334/// // Values shown here are possibly random and not representative !
4335/// let result = hub.settings().get("id")
4336///              .doit().await;
4337/// # }
4338/// ```
4339pub struct SettingGetCall<'a, C>
4340where
4341    C: 'a,
4342{
4343    hub: &'a Mirror<C>,
4344    _id: String,
4345    _delegate: Option<&'a mut dyn common::Delegate>,
4346    _additional_params: HashMap<String, String>,
4347    _scopes: BTreeSet<String>,
4348}
4349
4350impl<'a, C> common::CallBuilder for SettingGetCall<'a, C> {}
4351
4352impl<'a, C> SettingGetCall<'a, C>
4353where
4354    C: common::Connector,
4355{
4356    /// Perform the operation you have build so far.
4357    pub async fn doit(mut self) -> common::Result<(common::Response, Setting)> {
4358        use std::borrow::Cow;
4359        use std::io::{Read, Seek};
4360
4361        use common::{url::Params, ToParts};
4362        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4363
4364        let mut dd = common::DefaultDelegate;
4365        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4366        dlg.begin(common::MethodInfo {
4367            id: "mirror.settings.get",
4368            http_method: hyper::Method::GET,
4369        });
4370
4371        for &field in ["alt", "id"].iter() {
4372            if self._additional_params.contains_key(field) {
4373                dlg.finished(false);
4374                return Err(common::Error::FieldClash(field));
4375            }
4376        }
4377
4378        let mut params = Params::with_capacity(3 + self._additional_params.len());
4379        params.push("id", self._id);
4380
4381        params.extend(self._additional_params.iter());
4382
4383        params.push("alt", "json");
4384        let mut url = self.hub._base_url.clone() + "settings/{id}";
4385        if self._scopes.is_empty() {
4386            self._scopes
4387                .insert(Scope::GlasTimeline.as_ref().to_string());
4388        }
4389
4390        #[allow(clippy::single_element_loop)]
4391        for &(find_this, param_name) in [("{id}", "id")].iter() {
4392            url = params.uri_replacement(url, param_name, find_this, false);
4393        }
4394        {
4395            let to_remove = ["id"];
4396            params.remove_params(&to_remove);
4397        }
4398
4399        let url = params.parse_with_url(&url);
4400
4401        loop {
4402            let token = match self
4403                .hub
4404                .auth
4405                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4406                .await
4407            {
4408                Ok(token) => token,
4409                Err(e) => match dlg.token(e) {
4410                    Ok(token) => token,
4411                    Err(e) => {
4412                        dlg.finished(false);
4413                        return Err(common::Error::MissingToken(e));
4414                    }
4415                },
4416            };
4417            let mut req_result = {
4418                let client = &self.hub.client;
4419                dlg.pre_request();
4420                let mut req_builder = hyper::Request::builder()
4421                    .method(hyper::Method::GET)
4422                    .uri(url.as_str())
4423                    .header(USER_AGENT, self.hub._user_agent.clone());
4424
4425                if let Some(token) = token.as_ref() {
4426                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4427                }
4428
4429                let request = req_builder
4430                    .header(CONTENT_LENGTH, 0_u64)
4431                    .body(common::to_body::<String>(None));
4432
4433                client.request(request.unwrap()).await
4434            };
4435
4436            match req_result {
4437                Err(err) => {
4438                    if let common::Retry::After(d) = dlg.http_error(&err) {
4439                        sleep(d).await;
4440                        continue;
4441                    }
4442                    dlg.finished(false);
4443                    return Err(common::Error::HttpError(err));
4444                }
4445                Ok(res) => {
4446                    let (mut parts, body) = res.into_parts();
4447                    let mut body = common::Body::new(body);
4448                    if !parts.status.is_success() {
4449                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4450                        let error = serde_json::from_str(&common::to_string(&bytes));
4451                        let response = common::to_response(parts, bytes.into());
4452
4453                        if let common::Retry::After(d) =
4454                            dlg.http_failure(&response, error.as_ref().ok())
4455                        {
4456                            sleep(d).await;
4457                            continue;
4458                        }
4459
4460                        dlg.finished(false);
4461
4462                        return Err(match error {
4463                            Ok(value) => common::Error::BadRequest(value),
4464                            _ => common::Error::Failure(response),
4465                        });
4466                    }
4467                    let response = {
4468                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4469                        let encoded = common::to_string(&bytes);
4470                        match serde_json::from_str(&encoded) {
4471                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4472                            Err(error) => {
4473                                dlg.response_json_decode_error(&encoded, &error);
4474                                return Err(common::Error::JsonDecodeError(
4475                                    encoded.to_string(),
4476                                    error,
4477                                ));
4478                            }
4479                        }
4480                    };
4481
4482                    dlg.finished(true);
4483                    return Ok(response);
4484                }
4485            }
4486        }
4487    }
4488
4489    /// The ID of the setting. The following IDs are valid:
4490    /// - locale - The key to the user’s language/locale (BCP 47 identifier) that Glassware should use to render localized content.
4491    /// - timezone - The key to the user’s current time zone region as defined in the tz database. Example: America/Los_Angeles.
4492    ///
4493    /// Sets the *id* path property to the given value.
4494    ///
4495    /// Even though the property as already been set when instantiating this call,
4496    /// we provide this method for API completeness.
4497    pub fn id(mut self, new_value: &str) -> SettingGetCall<'a, C> {
4498        self._id = new_value.to_string();
4499        self
4500    }
4501    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4502    /// while executing the actual API request.
4503    ///
4504    /// ````text
4505    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4506    /// ````
4507    ///
4508    /// Sets the *delegate* property to the given value.
4509    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingGetCall<'a, C> {
4510        self._delegate = Some(new_value);
4511        self
4512    }
4513
4514    /// Set any additional parameter of the query string used in the request.
4515    /// It should be used to set parameters which are not yet available through their own
4516    /// setters.
4517    ///
4518    /// Please note that this method must not be used to set any of the known parameters
4519    /// which have their own setter method. If done anyway, the request will fail.
4520    ///
4521    /// # Additional Parameters
4522    ///
4523    /// * *alt* (query-string) - Data format for the response.
4524    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4525    /// * *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.
4526    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4527    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4528    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4529    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4530    pub fn param<T>(mut self, name: T, value: T) -> SettingGetCall<'a, C>
4531    where
4532        T: AsRef<str>,
4533    {
4534        self._additional_params
4535            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4536        self
4537    }
4538
4539    /// Identifies the authorization scope for the method you are building.
4540    ///
4541    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4542    /// [`Scope::GlasTimeline`].
4543    ///
4544    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4545    /// tokens for more than one scope.
4546    ///
4547    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4548    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4549    /// sufficient, a read-write scope will do as well.
4550    pub fn add_scope<St>(mut self, scope: St) -> SettingGetCall<'a, C>
4551    where
4552        St: AsRef<str>,
4553    {
4554        self._scopes.insert(String::from(scope.as_ref()));
4555        self
4556    }
4557    /// Identifies the authorization scope(s) for the method you are building.
4558    ///
4559    /// See [`Self::add_scope()`] for details.
4560    pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingGetCall<'a, C>
4561    where
4562        I: IntoIterator<Item = St>,
4563        St: AsRef<str>,
4564    {
4565        self._scopes
4566            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4567        self
4568    }
4569
4570    /// Removes all scopes, and no default scope will be used either.
4571    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4572    /// for details).
4573    pub fn clear_scopes(mut self) -> SettingGetCall<'a, C> {
4574        self._scopes.clear();
4575        self
4576    }
4577}
4578
4579/// Deletes a subscription.
4580///
4581/// A builder for the *delete* method supported by a *subscription* resource.
4582/// It is not used directly, but through a [`SubscriptionMethods`] instance.
4583///
4584/// # Example
4585///
4586/// Instantiate a resource method builder
4587///
4588/// ```test_harness,no_run
4589/// # extern crate hyper;
4590/// # extern crate hyper_rustls;
4591/// # extern crate google_mirror1 as mirror1;
4592/// # async fn dox() {
4593/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4594///
4595/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4596/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4597/// #     .with_native_roots()
4598/// #     .unwrap()
4599/// #     .https_only()
4600/// #     .enable_http2()
4601/// #     .build();
4602///
4603/// # let executor = hyper_util::rt::TokioExecutor::new();
4604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4605/// #     secret,
4606/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4607/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4608/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4609/// #     ),
4610/// # ).build().await.unwrap();
4611///
4612/// # let client = hyper_util::client::legacy::Client::builder(
4613/// #     hyper_util::rt::TokioExecutor::new()
4614/// # )
4615/// # .build(
4616/// #     hyper_rustls::HttpsConnectorBuilder::new()
4617/// #         .with_native_roots()
4618/// #         .unwrap()
4619/// #         .https_or_http()
4620/// #         .enable_http2()
4621/// #         .build()
4622/// # );
4623/// # let mut hub = Mirror::new(client, auth);
4624/// // You can configure optional parameters by calling the respective setters at will, and
4625/// // execute the final call using `doit()`.
4626/// // Values shown here are possibly random and not representative !
4627/// let result = hub.subscriptions().delete("id")
4628///              .doit().await;
4629/// # }
4630/// ```
4631pub struct SubscriptionDeleteCall<'a, C>
4632where
4633    C: 'a,
4634{
4635    hub: &'a Mirror<C>,
4636    _id: String,
4637    _delegate: Option<&'a mut dyn common::Delegate>,
4638    _additional_params: HashMap<String, String>,
4639    _scopes: BTreeSet<String>,
4640}
4641
4642impl<'a, C> common::CallBuilder for SubscriptionDeleteCall<'a, C> {}
4643
4644impl<'a, C> SubscriptionDeleteCall<'a, C>
4645where
4646    C: common::Connector,
4647{
4648    /// Perform the operation you have build so far.
4649    pub async fn doit(mut self) -> common::Result<common::Response> {
4650        use std::borrow::Cow;
4651        use std::io::{Read, Seek};
4652
4653        use common::{url::Params, ToParts};
4654        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4655
4656        let mut dd = common::DefaultDelegate;
4657        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4658        dlg.begin(common::MethodInfo {
4659            id: "mirror.subscriptions.delete",
4660            http_method: hyper::Method::DELETE,
4661        });
4662
4663        for &field in ["id"].iter() {
4664            if self._additional_params.contains_key(field) {
4665                dlg.finished(false);
4666                return Err(common::Error::FieldClash(field));
4667            }
4668        }
4669
4670        let mut params = Params::with_capacity(2 + self._additional_params.len());
4671        params.push("id", self._id);
4672
4673        params.extend(self._additional_params.iter());
4674
4675        let mut url = self.hub._base_url.clone() + "subscriptions/{id}";
4676        if self._scopes.is_empty() {
4677            self._scopes
4678                .insert(Scope::GlasTimeline.as_ref().to_string());
4679        }
4680
4681        #[allow(clippy::single_element_loop)]
4682        for &(find_this, param_name) in [("{id}", "id")].iter() {
4683            url = params.uri_replacement(url, param_name, find_this, false);
4684        }
4685        {
4686            let to_remove = ["id"];
4687            params.remove_params(&to_remove);
4688        }
4689
4690        let url = params.parse_with_url(&url);
4691
4692        loop {
4693            let token = match self
4694                .hub
4695                .auth
4696                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4697                .await
4698            {
4699                Ok(token) => token,
4700                Err(e) => match dlg.token(e) {
4701                    Ok(token) => token,
4702                    Err(e) => {
4703                        dlg.finished(false);
4704                        return Err(common::Error::MissingToken(e));
4705                    }
4706                },
4707            };
4708            let mut req_result = {
4709                let client = &self.hub.client;
4710                dlg.pre_request();
4711                let mut req_builder = hyper::Request::builder()
4712                    .method(hyper::Method::DELETE)
4713                    .uri(url.as_str())
4714                    .header(USER_AGENT, self.hub._user_agent.clone());
4715
4716                if let Some(token) = token.as_ref() {
4717                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4718                }
4719
4720                let request = req_builder
4721                    .header(CONTENT_LENGTH, 0_u64)
4722                    .body(common::to_body::<String>(None));
4723
4724                client.request(request.unwrap()).await
4725            };
4726
4727            match req_result {
4728                Err(err) => {
4729                    if let common::Retry::After(d) = dlg.http_error(&err) {
4730                        sleep(d).await;
4731                        continue;
4732                    }
4733                    dlg.finished(false);
4734                    return Err(common::Error::HttpError(err));
4735                }
4736                Ok(res) => {
4737                    let (mut parts, body) = res.into_parts();
4738                    let mut body = common::Body::new(body);
4739                    if !parts.status.is_success() {
4740                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4741                        let error = serde_json::from_str(&common::to_string(&bytes));
4742                        let response = common::to_response(parts, bytes.into());
4743
4744                        if let common::Retry::After(d) =
4745                            dlg.http_failure(&response, error.as_ref().ok())
4746                        {
4747                            sleep(d).await;
4748                            continue;
4749                        }
4750
4751                        dlg.finished(false);
4752
4753                        return Err(match error {
4754                            Ok(value) => common::Error::BadRequest(value),
4755                            _ => common::Error::Failure(response),
4756                        });
4757                    }
4758                    let response = common::Response::from_parts(parts, body);
4759
4760                    dlg.finished(true);
4761                    return Ok(response);
4762                }
4763            }
4764        }
4765    }
4766
4767    /// The ID of the subscription.
4768    ///
4769    /// Sets the *id* path property to the given value.
4770    ///
4771    /// Even though the property as already been set when instantiating this call,
4772    /// we provide this method for API completeness.
4773    pub fn id(mut self, new_value: &str) -> SubscriptionDeleteCall<'a, C> {
4774        self._id = new_value.to_string();
4775        self
4776    }
4777    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4778    /// while executing the actual API request.
4779    ///
4780    /// ````text
4781    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4782    /// ````
4783    ///
4784    /// Sets the *delegate* property to the given value.
4785    pub fn delegate(
4786        mut self,
4787        new_value: &'a mut dyn common::Delegate,
4788    ) -> SubscriptionDeleteCall<'a, C> {
4789        self._delegate = Some(new_value);
4790        self
4791    }
4792
4793    /// Set any additional parameter of the query string used in the request.
4794    /// It should be used to set parameters which are not yet available through their own
4795    /// setters.
4796    ///
4797    /// Please note that this method must not be used to set any of the known parameters
4798    /// which have their own setter method. If done anyway, the request will fail.
4799    ///
4800    /// # Additional Parameters
4801    ///
4802    /// * *alt* (query-string) - Data format for the response.
4803    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4804    /// * *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.
4805    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4806    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4807    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4808    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4809    pub fn param<T>(mut self, name: T, value: T) -> SubscriptionDeleteCall<'a, C>
4810    where
4811        T: AsRef<str>,
4812    {
4813        self._additional_params
4814            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4815        self
4816    }
4817
4818    /// Identifies the authorization scope for the method you are building.
4819    ///
4820    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4821    /// [`Scope::GlasTimeline`].
4822    ///
4823    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4824    /// tokens for more than one scope.
4825    ///
4826    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4827    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4828    /// sufficient, a read-write scope will do as well.
4829    pub fn add_scope<St>(mut self, scope: St) -> SubscriptionDeleteCall<'a, C>
4830    where
4831        St: AsRef<str>,
4832    {
4833        self._scopes.insert(String::from(scope.as_ref()));
4834        self
4835    }
4836    /// Identifies the authorization scope(s) for the method you are building.
4837    ///
4838    /// See [`Self::add_scope()`] for details.
4839    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubscriptionDeleteCall<'a, C>
4840    where
4841        I: IntoIterator<Item = St>,
4842        St: AsRef<str>,
4843    {
4844        self._scopes
4845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4846        self
4847    }
4848
4849    /// Removes all scopes, and no default scope will be used either.
4850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4851    /// for details).
4852    pub fn clear_scopes(mut self) -> SubscriptionDeleteCall<'a, C> {
4853        self._scopes.clear();
4854        self
4855    }
4856}
4857
4858/// Creates a new subscription.
4859///
4860/// A builder for the *insert* method supported by a *subscription* resource.
4861/// It is not used directly, but through a [`SubscriptionMethods`] instance.
4862///
4863/// # Example
4864///
4865/// Instantiate a resource method builder
4866///
4867/// ```test_harness,no_run
4868/// # extern crate hyper;
4869/// # extern crate hyper_rustls;
4870/// # extern crate google_mirror1 as mirror1;
4871/// use mirror1::api::Subscription;
4872/// # async fn dox() {
4873/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4874///
4875/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4876/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4877/// #     .with_native_roots()
4878/// #     .unwrap()
4879/// #     .https_only()
4880/// #     .enable_http2()
4881/// #     .build();
4882///
4883/// # let executor = hyper_util::rt::TokioExecutor::new();
4884/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4885/// #     secret,
4886/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4887/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4888/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4889/// #     ),
4890/// # ).build().await.unwrap();
4891///
4892/// # let client = hyper_util::client::legacy::Client::builder(
4893/// #     hyper_util::rt::TokioExecutor::new()
4894/// # )
4895/// # .build(
4896/// #     hyper_rustls::HttpsConnectorBuilder::new()
4897/// #         .with_native_roots()
4898/// #         .unwrap()
4899/// #         .https_or_http()
4900/// #         .enable_http2()
4901/// #         .build()
4902/// # );
4903/// # let mut hub = Mirror::new(client, auth);
4904/// // As the method needs a request, you would usually fill it with the desired information
4905/// // into the respective structure. Some of the parts shown here might not be applicable !
4906/// // Values shown here are possibly random and not representative !
4907/// let mut req = Subscription::default();
4908///
4909/// // You can configure optional parameters by calling the respective setters at will, and
4910/// // execute the final call using `doit()`.
4911/// // Values shown here are possibly random and not representative !
4912/// let result = hub.subscriptions().insert(req)
4913///              .doit().await;
4914/// # }
4915/// ```
4916pub struct SubscriptionInsertCall<'a, C>
4917where
4918    C: 'a,
4919{
4920    hub: &'a Mirror<C>,
4921    _request: Subscription,
4922    _delegate: Option<&'a mut dyn common::Delegate>,
4923    _additional_params: HashMap<String, String>,
4924    _scopes: BTreeSet<String>,
4925}
4926
4927impl<'a, C> common::CallBuilder for SubscriptionInsertCall<'a, C> {}
4928
4929impl<'a, C> SubscriptionInsertCall<'a, C>
4930where
4931    C: common::Connector,
4932{
4933    /// Perform the operation you have build so far.
4934    pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
4935        use std::borrow::Cow;
4936        use std::io::{Read, Seek};
4937
4938        use common::{url::Params, ToParts};
4939        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4940
4941        let mut dd = common::DefaultDelegate;
4942        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4943        dlg.begin(common::MethodInfo {
4944            id: "mirror.subscriptions.insert",
4945            http_method: hyper::Method::POST,
4946        });
4947
4948        for &field in ["alt"].iter() {
4949            if self._additional_params.contains_key(field) {
4950                dlg.finished(false);
4951                return Err(common::Error::FieldClash(field));
4952            }
4953        }
4954
4955        let mut params = Params::with_capacity(3 + self._additional_params.len());
4956
4957        params.extend(self._additional_params.iter());
4958
4959        params.push("alt", "json");
4960        let mut url = self.hub._base_url.clone() + "subscriptions";
4961        if self._scopes.is_empty() {
4962            self._scopes
4963                .insert(Scope::GlasTimeline.as_ref().to_string());
4964        }
4965
4966        let url = params.parse_with_url(&url);
4967
4968        let mut json_mime_type = mime::APPLICATION_JSON;
4969        let mut request_value_reader = {
4970            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4971            common::remove_json_null_values(&mut value);
4972            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4973            serde_json::to_writer(&mut dst, &value).unwrap();
4974            dst
4975        };
4976        let request_size = request_value_reader
4977            .seek(std::io::SeekFrom::End(0))
4978            .unwrap();
4979        request_value_reader
4980            .seek(std::io::SeekFrom::Start(0))
4981            .unwrap();
4982
4983        loop {
4984            let token = match self
4985                .hub
4986                .auth
4987                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4988                .await
4989            {
4990                Ok(token) => token,
4991                Err(e) => match dlg.token(e) {
4992                    Ok(token) => token,
4993                    Err(e) => {
4994                        dlg.finished(false);
4995                        return Err(common::Error::MissingToken(e));
4996                    }
4997                },
4998            };
4999            request_value_reader
5000                .seek(std::io::SeekFrom::Start(0))
5001                .unwrap();
5002            let mut req_result = {
5003                let client = &self.hub.client;
5004                dlg.pre_request();
5005                let mut req_builder = hyper::Request::builder()
5006                    .method(hyper::Method::POST)
5007                    .uri(url.as_str())
5008                    .header(USER_AGENT, self.hub._user_agent.clone());
5009
5010                if let Some(token) = token.as_ref() {
5011                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5012                }
5013
5014                let request = req_builder
5015                    .header(CONTENT_TYPE, json_mime_type.to_string())
5016                    .header(CONTENT_LENGTH, request_size as u64)
5017                    .body(common::to_body(
5018                        request_value_reader.get_ref().clone().into(),
5019                    ));
5020
5021                client.request(request.unwrap()).await
5022            };
5023
5024            match req_result {
5025                Err(err) => {
5026                    if let common::Retry::After(d) = dlg.http_error(&err) {
5027                        sleep(d).await;
5028                        continue;
5029                    }
5030                    dlg.finished(false);
5031                    return Err(common::Error::HttpError(err));
5032                }
5033                Ok(res) => {
5034                    let (mut parts, body) = res.into_parts();
5035                    let mut body = common::Body::new(body);
5036                    if !parts.status.is_success() {
5037                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5038                        let error = serde_json::from_str(&common::to_string(&bytes));
5039                        let response = common::to_response(parts, bytes.into());
5040
5041                        if let common::Retry::After(d) =
5042                            dlg.http_failure(&response, error.as_ref().ok())
5043                        {
5044                            sleep(d).await;
5045                            continue;
5046                        }
5047
5048                        dlg.finished(false);
5049
5050                        return Err(match error {
5051                            Ok(value) => common::Error::BadRequest(value),
5052                            _ => common::Error::Failure(response),
5053                        });
5054                    }
5055                    let response = {
5056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5057                        let encoded = common::to_string(&bytes);
5058                        match serde_json::from_str(&encoded) {
5059                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5060                            Err(error) => {
5061                                dlg.response_json_decode_error(&encoded, &error);
5062                                return Err(common::Error::JsonDecodeError(
5063                                    encoded.to_string(),
5064                                    error,
5065                                ));
5066                            }
5067                        }
5068                    };
5069
5070                    dlg.finished(true);
5071                    return Ok(response);
5072                }
5073            }
5074        }
5075    }
5076
5077    ///
5078    /// Sets the *request* property to the given value.
5079    ///
5080    /// Even though the property as already been set when instantiating this call,
5081    /// we provide this method for API completeness.
5082    pub fn request(mut self, new_value: Subscription) -> SubscriptionInsertCall<'a, C> {
5083        self._request = new_value;
5084        self
5085    }
5086    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5087    /// while executing the actual API request.
5088    ///
5089    /// ````text
5090    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5091    /// ````
5092    ///
5093    /// Sets the *delegate* property to the given value.
5094    pub fn delegate(
5095        mut self,
5096        new_value: &'a mut dyn common::Delegate,
5097    ) -> SubscriptionInsertCall<'a, C> {
5098        self._delegate = Some(new_value);
5099        self
5100    }
5101
5102    /// Set any additional parameter of the query string used in the request.
5103    /// It should be used to set parameters which are not yet available through their own
5104    /// setters.
5105    ///
5106    /// Please note that this method must not be used to set any of the known parameters
5107    /// which have their own setter method. If done anyway, the request will fail.
5108    ///
5109    /// # Additional Parameters
5110    ///
5111    /// * *alt* (query-string) - Data format for the response.
5112    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5113    /// * *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.
5114    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5115    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5116    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5117    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5118    pub fn param<T>(mut self, name: T, value: T) -> SubscriptionInsertCall<'a, C>
5119    where
5120        T: AsRef<str>,
5121    {
5122        self._additional_params
5123            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5124        self
5125    }
5126
5127    /// Identifies the authorization scope for the method you are building.
5128    ///
5129    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5130    /// [`Scope::GlasTimeline`].
5131    ///
5132    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5133    /// tokens for more than one scope.
5134    ///
5135    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5136    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5137    /// sufficient, a read-write scope will do as well.
5138    pub fn add_scope<St>(mut self, scope: St) -> SubscriptionInsertCall<'a, C>
5139    where
5140        St: AsRef<str>,
5141    {
5142        self._scopes.insert(String::from(scope.as_ref()));
5143        self
5144    }
5145    /// Identifies the authorization scope(s) for the method you are building.
5146    ///
5147    /// See [`Self::add_scope()`] for details.
5148    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubscriptionInsertCall<'a, C>
5149    where
5150        I: IntoIterator<Item = St>,
5151        St: AsRef<str>,
5152    {
5153        self._scopes
5154            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5155        self
5156    }
5157
5158    /// Removes all scopes, and no default scope will be used either.
5159    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5160    /// for details).
5161    pub fn clear_scopes(mut self) -> SubscriptionInsertCall<'a, C> {
5162        self._scopes.clear();
5163        self
5164    }
5165}
5166
5167/// Retrieves a list of subscriptions for the authenticated user and service.
5168///
5169/// A builder for the *list* method supported by a *subscription* resource.
5170/// It is not used directly, but through a [`SubscriptionMethods`] instance.
5171///
5172/// # Example
5173///
5174/// Instantiate a resource method builder
5175///
5176/// ```test_harness,no_run
5177/// # extern crate hyper;
5178/// # extern crate hyper_rustls;
5179/// # extern crate google_mirror1 as mirror1;
5180/// # async fn dox() {
5181/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5182///
5183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5185/// #     .with_native_roots()
5186/// #     .unwrap()
5187/// #     .https_only()
5188/// #     .enable_http2()
5189/// #     .build();
5190///
5191/// # let executor = hyper_util::rt::TokioExecutor::new();
5192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5193/// #     secret,
5194/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5195/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5196/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5197/// #     ),
5198/// # ).build().await.unwrap();
5199///
5200/// # let client = hyper_util::client::legacy::Client::builder(
5201/// #     hyper_util::rt::TokioExecutor::new()
5202/// # )
5203/// # .build(
5204/// #     hyper_rustls::HttpsConnectorBuilder::new()
5205/// #         .with_native_roots()
5206/// #         .unwrap()
5207/// #         .https_or_http()
5208/// #         .enable_http2()
5209/// #         .build()
5210/// # );
5211/// # let mut hub = Mirror::new(client, auth);
5212/// // You can configure optional parameters by calling the respective setters at will, and
5213/// // execute the final call using `doit()`.
5214/// // Values shown here are possibly random and not representative !
5215/// let result = hub.subscriptions().list()
5216///              .doit().await;
5217/// # }
5218/// ```
5219pub struct SubscriptionListCall<'a, C>
5220where
5221    C: 'a,
5222{
5223    hub: &'a Mirror<C>,
5224    _delegate: Option<&'a mut dyn common::Delegate>,
5225    _additional_params: HashMap<String, String>,
5226    _scopes: BTreeSet<String>,
5227}
5228
5229impl<'a, C> common::CallBuilder for SubscriptionListCall<'a, C> {}
5230
5231impl<'a, C> SubscriptionListCall<'a, C>
5232where
5233    C: common::Connector,
5234{
5235    /// Perform the operation you have build so far.
5236    pub async fn doit(mut self) -> common::Result<(common::Response, SubscriptionsListResponse)> {
5237        use std::borrow::Cow;
5238        use std::io::{Read, Seek};
5239
5240        use common::{url::Params, ToParts};
5241        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5242
5243        let mut dd = common::DefaultDelegate;
5244        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5245        dlg.begin(common::MethodInfo {
5246            id: "mirror.subscriptions.list",
5247            http_method: hyper::Method::GET,
5248        });
5249
5250        for &field in ["alt"].iter() {
5251            if self._additional_params.contains_key(field) {
5252                dlg.finished(false);
5253                return Err(common::Error::FieldClash(field));
5254            }
5255        }
5256
5257        let mut params = Params::with_capacity(2 + self._additional_params.len());
5258
5259        params.extend(self._additional_params.iter());
5260
5261        params.push("alt", "json");
5262        let mut url = self.hub._base_url.clone() + "subscriptions";
5263        if self._scopes.is_empty() {
5264            self._scopes
5265                .insert(Scope::GlasTimeline.as_ref().to_string());
5266        }
5267
5268        let url = params.parse_with_url(&url);
5269
5270        loop {
5271            let token = match self
5272                .hub
5273                .auth
5274                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5275                .await
5276            {
5277                Ok(token) => token,
5278                Err(e) => match dlg.token(e) {
5279                    Ok(token) => token,
5280                    Err(e) => {
5281                        dlg.finished(false);
5282                        return Err(common::Error::MissingToken(e));
5283                    }
5284                },
5285            };
5286            let mut req_result = {
5287                let client = &self.hub.client;
5288                dlg.pre_request();
5289                let mut req_builder = hyper::Request::builder()
5290                    .method(hyper::Method::GET)
5291                    .uri(url.as_str())
5292                    .header(USER_AGENT, self.hub._user_agent.clone());
5293
5294                if let Some(token) = token.as_ref() {
5295                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5296                }
5297
5298                let request = req_builder
5299                    .header(CONTENT_LENGTH, 0_u64)
5300                    .body(common::to_body::<String>(None));
5301
5302                client.request(request.unwrap()).await
5303            };
5304
5305            match req_result {
5306                Err(err) => {
5307                    if let common::Retry::After(d) = dlg.http_error(&err) {
5308                        sleep(d).await;
5309                        continue;
5310                    }
5311                    dlg.finished(false);
5312                    return Err(common::Error::HttpError(err));
5313                }
5314                Ok(res) => {
5315                    let (mut parts, body) = res.into_parts();
5316                    let mut body = common::Body::new(body);
5317                    if !parts.status.is_success() {
5318                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5319                        let error = serde_json::from_str(&common::to_string(&bytes));
5320                        let response = common::to_response(parts, bytes.into());
5321
5322                        if let common::Retry::After(d) =
5323                            dlg.http_failure(&response, error.as_ref().ok())
5324                        {
5325                            sleep(d).await;
5326                            continue;
5327                        }
5328
5329                        dlg.finished(false);
5330
5331                        return Err(match error {
5332                            Ok(value) => common::Error::BadRequest(value),
5333                            _ => common::Error::Failure(response),
5334                        });
5335                    }
5336                    let response = {
5337                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5338                        let encoded = common::to_string(&bytes);
5339                        match serde_json::from_str(&encoded) {
5340                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5341                            Err(error) => {
5342                                dlg.response_json_decode_error(&encoded, &error);
5343                                return Err(common::Error::JsonDecodeError(
5344                                    encoded.to_string(),
5345                                    error,
5346                                ));
5347                            }
5348                        }
5349                    };
5350
5351                    dlg.finished(true);
5352                    return Ok(response);
5353                }
5354            }
5355        }
5356    }
5357
5358    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5359    /// while executing the actual API request.
5360    ///
5361    /// ````text
5362    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5363    /// ````
5364    ///
5365    /// Sets the *delegate* property to the given value.
5366    pub fn delegate(
5367        mut self,
5368        new_value: &'a mut dyn common::Delegate,
5369    ) -> SubscriptionListCall<'a, C> {
5370        self._delegate = Some(new_value);
5371        self
5372    }
5373
5374    /// Set any additional parameter of the query string used in the request.
5375    /// It should be used to set parameters which are not yet available through their own
5376    /// setters.
5377    ///
5378    /// Please note that this method must not be used to set any of the known parameters
5379    /// which have their own setter method. If done anyway, the request will fail.
5380    ///
5381    /// # Additional Parameters
5382    ///
5383    /// * *alt* (query-string) - Data format for the response.
5384    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5385    /// * *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.
5386    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5387    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5388    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5389    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5390    pub fn param<T>(mut self, name: T, value: T) -> SubscriptionListCall<'a, C>
5391    where
5392        T: AsRef<str>,
5393    {
5394        self._additional_params
5395            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5396        self
5397    }
5398
5399    /// Identifies the authorization scope for the method you are building.
5400    ///
5401    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5402    /// [`Scope::GlasTimeline`].
5403    ///
5404    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5405    /// tokens for more than one scope.
5406    ///
5407    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5408    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5409    /// sufficient, a read-write scope will do as well.
5410    pub fn add_scope<St>(mut self, scope: St) -> SubscriptionListCall<'a, C>
5411    where
5412        St: AsRef<str>,
5413    {
5414        self._scopes.insert(String::from(scope.as_ref()));
5415        self
5416    }
5417    /// Identifies the authorization scope(s) for the method you are building.
5418    ///
5419    /// See [`Self::add_scope()`] for details.
5420    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubscriptionListCall<'a, C>
5421    where
5422        I: IntoIterator<Item = St>,
5423        St: AsRef<str>,
5424    {
5425        self._scopes
5426            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5427        self
5428    }
5429
5430    /// Removes all scopes, and no default scope will be used either.
5431    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5432    /// for details).
5433    pub fn clear_scopes(mut self) -> SubscriptionListCall<'a, C> {
5434        self._scopes.clear();
5435        self
5436    }
5437}
5438
5439/// Updates an existing subscription in place.
5440///
5441/// A builder for the *update* method supported by a *subscription* resource.
5442/// It is not used directly, but through a [`SubscriptionMethods`] instance.
5443///
5444/// # Example
5445///
5446/// Instantiate a resource method builder
5447///
5448/// ```test_harness,no_run
5449/// # extern crate hyper;
5450/// # extern crate hyper_rustls;
5451/// # extern crate google_mirror1 as mirror1;
5452/// use mirror1::api::Subscription;
5453/// # async fn dox() {
5454/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5455///
5456/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5457/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5458/// #     .with_native_roots()
5459/// #     .unwrap()
5460/// #     .https_only()
5461/// #     .enable_http2()
5462/// #     .build();
5463///
5464/// # let executor = hyper_util::rt::TokioExecutor::new();
5465/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5466/// #     secret,
5467/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5468/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5469/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5470/// #     ),
5471/// # ).build().await.unwrap();
5472///
5473/// # let client = hyper_util::client::legacy::Client::builder(
5474/// #     hyper_util::rt::TokioExecutor::new()
5475/// # )
5476/// # .build(
5477/// #     hyper_rustls::HttpsConnectorBuilder::new()
5478/// #         .with_native_roots()
5479/// #         .unwrap()
5480/// #         .https_or_http()
5481/// #         .enable_http2()
5482/// #         .build()
5483/// # );
5484/// # let mut hub = Mirror::new(client, auth);
5485/// // As the method needs a request, you would usually fill it with the desired information
5486/// // into the respective structure. Some of the parts shown here might not be applicable !
5487/// // Values shown here are possibly random and not representative !
5488/// let mut req = Subscription::default();
5489///
5490/// // You can configure optional parameters by calling the respective setters at will, and
5491/// // execute the final call using `doit()`.
5492/// // Values shown here are possibly random and not representative !
5493/// let result = hub.subscriptions().update(req, "id")
5494///              .doit().await;
5495/// # }
5496/// ```
5497pub struct SubscriptionUpdateCall<'a, C>
5498where
5499    C: 'a,
5500{
5501    hub: &'a Mirror<C>,
5502    _request: Subscription,
5503    _id: String,
5504    _delegate: Option<&'a mut dyn common::Delegate>,
5505    _additional_params: HashMap<String, String>,
5506    _scopes: BTreeSet<String>,
5507}
5508
5509impl<'a, C> common::CallBuilder for SubscriptionUpdateCall<'a, C> {}
5510
5511impl<'a, C> SubscriptionUpdateCall<'a, C>
5512where
5513    C: common::Connector,
5514{
5515    /// Perform the operation you have build so far.
5516    pub async fn doit(mut self) -> common::Result<(common::Response, Subscription)> {
5517        use std::borrow::Cow;
5518        use std::io::{Read, Seek};
5519
5520        use common::{url::Params, ToParts};
5521        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5522
5523        let mut dd = common::DefaultDelegate;
5524        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5525        dlg.begin(common::MethodInfo {
5526            id: "mirror.subscriptions.update",
5527            http_method: hyper::Method::PUT,
5528        });
5529
5530        for &field in ["alt", "id"].iter() {
5531            if self._additional_params.contains_key(field) {
5532                dlg.finished(false);
5533                return Err(common::Error::FieldClash(field));
5534            }
5535        }
5536
5537        let mut params = Params::with_capacity(4 + self._additional_params.len());
5538        params.push("id", self._id);
5539
5540        params.extend(self._additional_params.iter());
5541
5542        params.push("alt", "json");
5543        let mut url = self.hub._base_url.clone() + "subscriptions/{id}";
5544        if self._scopes.is_empty() {
5545            self._scopes
5546                .insert(Scope::GlasTimeline.as_ref().to_string());
5547        }
5548
5549        #[allow(clippy::single_element_loop)]
5550        for &(find_this, param_name) in [("{id}", "id")].iter() {
5551            url = params.uri_replacement(url, param_name, find_this, false);
5552        }
5553        {
5554            let to_remove = ["id"];
5555            params.remove_params(&to_remove);
5556        }
5557
5558        let url = params.parse_with_url(&url);
5559
5560        let mut json_mime_type = mime::APPLICATION_JSON;
5561        let mut request_value_reader = {
5562            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5563            common::remove_json_null_values(&mut value);
5564            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5565            serde_json::to_writer(&mut dst, &value).unwrap();
5566            dst
5567        };
5568        let request_size = request_value_reader
5569            .seek(std::io::SeekFrom::End(0))
5570            .unwrap();
5571        request_value_reader
5572            .seek(std::io::SeekFrom::Start(0))
5573            .unwrap();
5574
5575        loop {
5576            let token = match self
5577                .hub
5578                .auth
5579                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5580                .await
5581            {
5582                Ok(token) => token,
5583                Err(e) => match dlg.token(e) {
5584                    Ok(token) => token,
5585                    Err(e) => {
5586                        dlg.finished(false);
5587                        return Err(common::Error::MissingToken(e));
5588                    }
5589                },
5590            };
5591            request_value_reader
5592                .seek(std::io::SeekFrom::Start(0))
5593                .unwrap();
5594            let mut req_result = {
5595                let client = &self.hub.client;
5596                dlg.pre_request();
5597                let mut req_builder = hyper::Request::builder()
5598                    .method(hyper::Method::PUT)
5599                    .uri(url.as_str())
5600                    .header(USER_AGENT, self.hub._user_agent.clone());
5601
5602                if let Some(token) = token.as_ref() {
5603                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5604                }
5605
5606                let request = req_builder
5607                    .header(CONTENT_TYPE, json_mime_type.to_string())
5608                    .header(CONTENT_LENGTH, request_size as u64)
5609                    .body(common::to_body(
5610                        request_value_reader.get_ref().clone().into(),
5611                    ));
5612
5613                client.request(request.unwrap()).await
5614            };
5615
5616            match req_result {
5617                Err(err) => {
5618                    if let common::Retry::After(d) = dlg.http_error(&err) {
5619                        sleep(d).await;
5620                        continue;
5621                    }
5622                    dlg.finished(false);
5623                    return Err(common::Error::HttpError(err));
5624                }
5625                Ok(res) => {
5626                    let (mut parts, body) = res.into_parts();
5627                    let mut body = common::Body::new(body);
5628                    if !parts.status.is_success() {
5629                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5630                        let error = serde_json::from_str(&common::to_string(&bytes));
5631                        let response = common::to_response(parts, bytes.into());
5632
5633                        if let common::Retry::After(d) =
5634                            dlg.http_failure(&response, error.as_ref().ok())
5635                        {
5636                            sleep(d).await;
5637                            continue;
5638                        }
5639
5640                        dlg.finished(false);
5641
5642                        return Err(match error {
5643                            Ok(value) => common::Error::BadRequest(value),
5644                            _ => common::Error::Failure(response),
5645                        });
5646                    }
5647                    let response = {
5648                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5649                        let encoded = common::to_string(&bytes);
5650                        match serde_json::from_str(&encoded) {
5651                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5652                            Err(error) => {
5653                                dlg.response_json_decode_error(&encoded, &error);
5654                                return Err(common::Error::JsonDecodeError(
5655                                    encoded.to_string(),
5656                                    error,
5657                                ));
5658                            }
5659                        }
5660                    };
5661
5662                    dlg.finished(true);
5663                    return Ok(response);
5664                }
5665            }
5666        }
5667    }
5668
5669    ///
5670    /// Sets the *request* property to the given value.
5671    ///
5672    /// Even though the property as already been set when instantiating this call,
5673    /// we provide this method for API completeness.
5674    pub fn request(mut self, new_value: Subscription) -> SubscriptionUpdateCall<'a, C> {
5675        self._request = new_value;
5676        self
5677    }
5678    /// The ID of the subscription.
5679    ///
5680    /// Sets the *id* path property to the given value.
5681    ///
5682    /// Even though the property as already been set when instantiating this call,
5683    /// we provide this method for API completeness.
5684    pub fn id(mut self, new_value: &str) -> SubscriptionUpdateCall<'a, C> {
5685        self._id = new_value.to_string();
5686        self
5687    }
5688    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5689    /// while executing the actual API request.
5690    ///
5691    /// ````text
5692    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5693    /// ````
5694    ///
5695    /// Sets the *delegate* property to the given value.
5696    pub fn delegate(
5697        mut self,
5698        new_value: &'a mut dyn common::Delegate,
5699    ) -> SubscriptionUpdateCall<'a, C> {
5700        self._delegate = Some(new_value);
5701        self
5702    }
5703
5704    /// Set any additional parameter of the query string used in the request.
5705    /// It should be used to set parameters which are not yet available through their own
5706    /// setters.
5707    ///
5708    /// Please note that this method must not be used to set any of the known parameters
5709    /// which have their own setter method. If done anyway, the request will fail.
5710    ///
5711    /// # Additional Parameters
5712    ///
5713    /// * *alt* (query-string) - Data format for the response.
5714    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5715    /// * *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.
5716    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5717    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5718    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5719    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5720    pub fn param<T>(mut self, name: T, value: T) -> SubscriptionUpdateCall<'a, C>
5721    where
5722        T: AsRef<str>,
5723    {
5724        self._additional_params
5725            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5726        self
5727    }
5728
5729    /// Identifies the authorization scope for the method you are building.
5730    ///
5731    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5732    /// [`Scope::GlasTimeline`].
5733    ///
5734    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5735    /// tokens for more than one scope.
5736    ///
5737    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5738    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5739    /// sufficient, a read-write scope will do as well.
5740    pub fn add_scope<St>(mut self, scope: St) -> SubscriptionUpdateCall<'a, C>
5741    where
5742        St: AsRef<str>,
5743    {
5744        self._scopes.insert(String::from(scope.as_ref()));
5745        self
5746    }
5747    /// Identifies the authorization scope(s) for the method you are building.
5748    ///
5749    /// See [`Self::add_scope()`] for details.
5750    pub fn add_scopes<I, St>(mut self, scopes: I) -> SubscriptionUpdateCall<'a, C>
5751    where
5752        I: IntoIterator<Item = St>,
5753        St: AsRef<str>,
5754    {
5755        self._scopes
5756            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5757        self
5758    }
5759
5760    /// Removes all scopes, and no default scope will be used either.
5761    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5762    /// for details).
5763    pub fn clear_scopes(mut self) -> SubscriptionUpdateCall<'a, C> {
5764        self._scopes.clear();
5765        self
5766    }
5767}
5768
5769/// Deletes an attachment from a timeline item.
5770///
5771/// A builder for the *attachments.delete* method supported by a *timeline* resource.
5772/// It is not used directly, but through a [`TimelineMethods`] instance.
5773///
5774/// # Example
5775///
5776/// Instantiate a resource method builder
5777///
5778/// ```test_harness,no_run
5779/// # extern crate hyper;
5780/// # extern crate hyper_rustls;
5781/// # extern crate google_mirror1 as mirror1;
5782/// # async fn dox() {
5783/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5784///
5785/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5786/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5787/// #     .with_native_roots()
5788/// #     .unwrap()
5789/// #     .https_only()
5790/// #     .enable_http2()
5791/// #     .build();
5792///
5793/// # let executor = hyper_util::rt::TokioExecutor::new();
5794/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5795/// #     secret,
5796/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5797/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5798/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5799/// #     ),
5800/// # ).build().await.unwrap();
5801///
5802/// # let client = hyper_util::client::legacy::Client::builder(
5803/// #     hyper_util::rt::TokioExecutor::new()
5804/// # )
5805/// # .build(
5806/// #     hyper_rustls::HttpsConnectorBuilder::new()
5807/// #         .with_native_roots()
5808/// #         .unwrap()
5809/// #         .https_or_http()
5810/// #         .enable_http2()
5811/// #         .build()
5812/// # );
5813/// # let mut hub = Mirror::new(client, auth);
5814/// // You can configure optional parameters by calling the respective setters at will, and
5815/// // execute the final call using `doit()`.
5816/// // Values shown here are possibly random and not representative !
5817/// let result = hub.timeline().attachments_delete("itemId", "attachmentId")
5818///              .doit().await;
5819/// # }
5820/// ```
5821pub struct TimelineAttachmentDeleteCall<'a, C>
5822where
5823    C: 'a,
5824{
5825    hub: &'a Mirror<C>,
5826    _item_id: String,
5827    _attachment_id: String,
5828    _delegate: Option<&'a mut dyn common::Delegate>,
5829    _additional_params: HashMap<String, String>,
5830    _scopes: BTreeSet<String>,
5831}
5832
5833impl<'a, C> common::CallBuilder for TimelineAttachmentDeleteCall<'a, C> {}
5834
5835impl<'a, C> TimelineAttachmentDeleteCall<'a, C>
5836where
5837    C: common::Connector,
5838{
5839    /// Perform the operation you have build so far.
5840    pub async fn doit(mut self) -> common::Result<common::Response> {
5841        use std::borrow::Cow;
5842        use std::io::{Read, Seek};
5843
5844        use common::{url::Params, ToParts};
5845        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5846
5847        let mut dd = common::DefaultDelegate;
5848        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5849        dlg.begin(common::MethodInfo {
5850            id: "mirror.timeline.attachments.delete",
5851            http_method: hyper::Method::DELETE,
5852        });
5853
5854        for &field in ["itemId", "attachmentId"].iter() {
5855            if self._additional_params.contains_key(field) {
5856                dlg.finished(false);
5857                return Err(common::Error::FieldClash(field));
5858            }
5859        }
5860
5861        let mut params = Params::with_capacity(3 + self._additional_params.len());
5862        params.push("itemId", self._item_id);
5863        params.push("attachmentId", self._attachment_id);
5864
5865        params.extend(self._additional_params.iter());
5866
5867        let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments/{attachmentId}";
5868        if self._scopes.is_empty() {
5869            self._scopes
5870                .insert(Scope::GlasTimeline.as_ref().to_string());
5871        }
5872
5873        #[allow(clippy::single_element_loop)]
5874        for &(find_this, param_name) in
5875            [("{itemId}", "itemId"), ("{attachmentId}", "attachmentId")].iter()
5876        {
5877            url = params.uri_replacement(url, param_name, find_this, false);
5878        }
5879        {
5880            let to_remove = ["attachmentId", "itemId"];
5881            params.remove_params(&to_remove);
5882        }
5883
5884        let url = params.parse_with_url(&url);
5885
5886        loop {
5887            let token = match self
5888                .hub
5889                .auth
5890                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5891                .await
5892            {
5893                Ok(token) => token,
5894                Err(e) => match dlg.token(e) {
5895                    Ok(token) => token,
5896                    Err(e) => {
5897                        dlg.finished(false);
5898                        return Err(common::Error::MissingToken(e));
5899                    }
5900                },
5901            };
5902            let mut req_result = {
5903                let client = &self.hub.client;
5904                dlg.pre_request();
5905                let mut req_builder = hyper::Request::builder()
5906                    .method(hyper::Method::DELETE)
5907                    .uri(url.as_str())
5908                    .header(USER_AGENT, self.hub._user_agent.clone());
5909
5910                if let Some(token) = token.as_ref() {
5911                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5912                }
5913
5914                let request = req_builder
5915                    .header(CONTENT_LENGTH, 0_u64)
5916                    .body(common::to_body::<String>(None));
5917
5918                client.request(request.unwrap()).await
5919            };
5920
5921            match req_result {
5922                Err(err) => {
5923                    if let common::Retry::After(d) = dlg.http_error(&err) {
5924                        sleep(d).await;
5925                        continue;
5926                    }
5927                    dlg.finished(false);
5928                    return Err(common::Error::HttpError(err));
5929                }
5930                Ok(res) => {
5931                    let (mut parts, body) = res.into_parts();
5932                    let mut body = common::Body::new(body);
5933                    if !parts.status.is_success() {
5934                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5935                        let error = serde_json::from_str(&common::to_string(&bytes));
5936                        let response = common::to_response(parts, bytes.into());
5937
5938                        if let common::Retry::After(d) =
5939                            dlg.http_failure(&response, error.as_ref().ok())
5940                        {
5941                            sleep(d).await;
5942                            continue;
5943                        }
5944
5945                        dlg.finished(false);
5946
5947                        return Err(match error {
5948                            Ok(value) => common::Error::BadRequest(value),
5949                            _ => common::Error::Failure(response),
5950                        });
5951                    }
5952                    let response = common::Response::from_parts(parts, body);
5953
5954                    dlg.finished(true);
5955                    return Ok(response);
5956                }
5957            }
5958        }
5959    }
5960
5961    /// The ID of the timeline item the attachment belongs to.
5962    ///
5963    /// Sets the *item id* path property to the given value.
5964    ///
5965    /// Even though the property as already been set when instantiating this call,
5966    /// we provide this method for API completeness.
5967    pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentDeleteCall<'a, C> {
5968        self._item_id = new_value.to_string();
5969        self
5970    }
5971    /// The ID of the attachment.
5972    ///
5973    /// Sets the *attachment id* path property to the given value.
5974    ///
5975    /// Even though the property as already been set when instantiating this call,
5976    /// we provide this method for API completeness.
5977    pub fn attachment_id(mut self, new_value: &str) -> TimelineAttachmentDeleteCall<'a, C> {
5978        self._attachment_id = new_value.to_string();
5979        self
5980    }
5981    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5982    /// while executing the actual API request.
5983    ///
5984    /// ````text
5985    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5986    /// ````
5987    ///
5988    /// Sets the *delegate* property to the given value.
5989    pub fn delegate(
5990        mut self,
5991        new_value: &'a mut dyn common::Delegate,
5992    ) -> TimelineAttachmentDeleteCall<'a, C> {
5993        self._delegate = Some(new_value);
5994        self
5995    }
5996
5997    /// Set any additional parameter of the query string used in the request.
5998    /// It should be used to set parameters which are not yet available through their own
5999    /// setters.
6000    ///
6001    /// Please note that this method must not be used to set any of the known parameters
6002    /// which have their own setter method. If done anyway, the request will fail.
6003    ///
6004    /// # Additional Parameters
6005    ///
6006    /// * *alt* (query-string) - Data format for the response.
6007    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6008    /// * *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.
6009    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6010    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6011    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6012    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6013    pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentDeleteCall<'a, C>
6014    where
6015        T: AsRef<str>,
6016    {
6017        self._additional_params
6018            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6019        self
6020    }
6021
6022    /// Identifies the authorization scope for the method you are building.
6023    ///
6024    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6025    /// [`Scope::GlasTimeline`].
6026    ///
6027    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6028    /// tokens for more than one scope.
6029    ///
6030    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6031    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6032    /// sufficient, a read-write scope will do as well.
6033    pub fn add_scope<St>(mut self, scope: St) -> TimelineAttachmentDeleteCall<'a, C>
6034    where
6035        St: AsRef<str>,
6036    {
6037        self._scopes.insert(String::from(scope.as_ref()));
6038        self
6039    }
6040    /// Identifies the authorization scope(s) for the method you are building.
6041    ///
6042    /// See [`Self::add_scope()`] for details.
6043    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineAttachmentDeleteCall<'a, C>
6044    where
6045        I: IntoIterator<Item = St>,
6046        St: AsRef<str>,
6047    {
6048        self._scopes
6049            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6050        self
6051    }
6052
6053    /// Removes all scopes, and no default scope will be used either.
6054    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6055    /// for details).
6056    pub fn clear_scopes(mut self) -> TimelineAttachmentDeleteCall<'a, C> {
6057        self._scopes.clear();
6058        self
6059    }
6060}
6061
6062/// Retrieves an attachment on a timeline item by item ID and attachment ID.
6063///
6064/// This method supports **media download**. To enable it, adjust the builder like this:
6065/// `.param("alt", "media")`.
6066/// Please note that due to missing multi-part support on the server side, you will only receive the media,
6067/// but not the `Attachment` structure that you would usually get. The latter will be a default value.
6068///
6069/// A builder for the *attachments.get* method supported by a *timeline* resource.
6070/// It is not used directly, but through a [`TimelineMethods`] instance.
6071///
6072/// # Example
6073///
6074/// Instantiate a resource method builder
6075///
6076/// ```test_harness,no_run
6077/// # extern crate hyper;
6078/// # extern crate hyper_rustls;
6079/// # extern crate google_mirror1 as mirror1;
6080/// # async fn dox() {
6081/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6082///
6083/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6084/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6085/// #     .with_native_roots()
6086/// #     .unwrap()
6087/// #     .https_only()
6088/// #     .enable_http2()
6089/// #     .build();
6090///
6091/// # let executor = hyper_util::rt::TokioExecutor::new();
6092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6093/// #     secret,
6094/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6095/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6096/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6097/// #     ),
6098/// # ).build().await.unwrap();
6099///
6100/// # let client = hyper_util::client::legacy::Client::builder(
6101/// #     hyper_util::rt::TokioExecutor::new()
6102/// # )
6103/// # .build(
6104/// #     hyper_rustls::HttpsConnectorBuilder::new()
6105/// #         .with_native_roots()
6106/// #         .unwrap()
6107/// #         .https_or_http()
6108/// #         .enable_http2()
6109/// #         .build()
6110/// # );
6111/// # let mut hub = Mirror::new(client, auth);
6112/// // You can configure optional parameters by calling the respective setters at will, and
6113/// // execute the final call using `doit()`.
6114/// // Values shown here are possibly random and not representative !
6115/// let result = hub.timeline().attachments_get("itemId", "attachmentId")
6116///              .doit().await;
6117/// # }
6118/// ```
6119pub struct TimelineAttachmentGetCall<'a, C>
6120where
6121    C: 'a,
6122{
6123    hub: &'a Mirror<C>,
6124    _item_id: String,
6125    _attachment_id: String,
6126    _delegate: Option<&'a mut dyn common::Delegate>,
6127    _additional_params: HashMap<String, String>,
6128    _scopes: BTreeSet<String>,
6129}
6130
6131impl<'a, C> common::CallBuilder for TimelineAttachmentGetCall<'a, C> {}
6132
6133impl<'a, C> TimelineAttachmentGetCall<'a, C>
6134where
6135    C: common::Connector,
6136{
6137    /// Perform the operation you have build so far.
6138    pub async fn doit(mut self) -> common::Result<(common::Response, Attachment)> {
6139        use std::borrow::Cow;
6140        use std::io::{Read, Seek};
6141
6142        use common::{url::Params, ToParts};
6143        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6144
6145        let mut dd = common::DefaultDelegate;
6146        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6147        dlg.begin(common::MethodInfo {
6148            id: "mirror.timeline.attachments.get",
6149            http_method: hyper::Method::GET,
6150        });
6151
6152        for &field in ["itemId", "attachmentId"].iter() {
6153            if self._additional_params.contains_key(field) {
6154                dlg.finished(false);
6155                return Err(common::Error::FieldClash(field));
6156            }
6157        }
6158
6159        let mut params = Params::with_capacity(3 + self._additional_params.len());
6160        params.push("itemId", self._item_id);
6161        params.push("attachmentId", self._attachment_id);
6162
6163        params.extend(self._additional_params.iter());
6164
6165        let (alt_field_missing, enable_resource_parsing) = {
6166            if let Some(value) = params.get("alt") {
6167                (false, value == "json")
6168            } else {
6169                (true, true)
6170            }
6171        };
6172        if alt_field_missing {
6173            params.push("alt", "json");
6174        }
6175        let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments/{attachmentId}";
6176        if self._scopes.is_empty() {
6177            self._scopes
6178                .insert(Scope::GlasTimeline.as_ref().to_string());
6179        }
6180
6181        #[allow(clippy::single_element_loop)]
6182        for &(find_this, param_name) in
6183            [("{itemId}", "itemId"), ("{attachmentId}", "attachmentId")].iter()
6184        {
6185            url = params.uri_replacement(url, param_name, find_this, false);
6186        }
6187        {
6188            let to_remove = ["attachmentId", "itemId"];
6189            params.remove_params(&to_remove);
6190        }
6191
6192        let url = params.parse_with_url(&url);
6193
6194        loop {
6195            let token = match self
6196                .hub
6197                .auth
6198                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6199                .await
6200            {
6201                Ok(token) => token,
6202                Err(e) => match dlg.token(e) {
6203                    Ok(token) => token,
6204                    Err(e) => {
6205                        dlg.finished(false);
6206                        return Err(common::Error::MissingToken(e));
6207                    }
6208                },
6209            };
6210            let mut req_result = {
6211                let client = &self.hub.client;
6212                dlg.pre_request();
6213                let mut req_builder = hyper::Request::builder()
6214                    .method(hyper::Method::GET)
6215                    .uri(url.as_str())
6216                    .header(USER_AGENT, self.hub._user_agent.clone());
6217
6218                if let Some(token) = token.as_ref() {
6219                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6220                }
6221
6222                let request = req_builder
6223                    .header(CONTENT_LENGTH, 0_u64)
6224                    .body(common::to_body::<String>(None));
6225
6226                client.request(request.unwrap()).await
6227            };
6228
6229            match req_result {
6230                Err(err) => {
6231                    if let common::Retry::After(d) = dlg.http_error(&err) {
6232                        sleep(d).await;
6233                        continue;
6234                    }
6235                    dlg.finished(false);
6236                    return Err(common::Error::HttpError(err));
6237                }
6238                Ok(res) => {
6239                    let (mut parts, body) = res.into_parts();
6240                    let mut body = common::Body::new(body);
6241                    if !parts.status.is_success() {
6242                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6243                        let error = serde_json::from_str(&common::to_string(&bytes));
6244                        let response = common::to_response(parts, bytes.into());
6245
6246                        if let common::Retry::After(d) =
6247                            dlg.http_failure(&response, error.as_ref().ok())
6248                        {
6249                            sleep(d).await;
6250                            continue;
6251                        }
6252
6253                        dlg.finished(false);
6254
6255                        return Err(match error {
6256                            Ok(value) => common::Error::BadRequest(value),
6257                            _ => common::Error::Failure(response),
6258                        });
6259                    }
6260                    let response = if enable_resource_parsing {
6261                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6262                        let encoded = common::to_string(&bytes);
6263                        match serde_json::from_str(&encoded) {
6264                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6265                            Err(error) => {
6266                                dlg.response_json_decode_error(&encoded, &error);
6267                                return Err(common::Error::JsonDecodeError(
6268                                    encoded.to_string(),
6269                                    error,
6270                                ));
6271                            }
6272                        }
6273                    } else {
6274                        (
6275                            common::Response::from_parts(parts, body),
6276                            Default::default(),
6277                        )
6278                    };
6279
6280                    dlg.finished(true);
6281                    return Ok(response);
6282                }
6283            }
6284        }
6285    }
6286
6287    /// The ID of the timeline item the attachment belongs to.
6288    ///
6289    /// Sets the *item id* path property to the given value.
6290    ///
6291    /// Even though the property as already been set when instantiating this call,
6292    /// we provide this method for API completeness.
6293    pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentGetCall<'a, C> {
6294        self._item_id = new_value.to_string();
6295        self
6296    }
6297    /// The ID of the attachment.
6298    ///
6299    /// Sets the *attachment id* path property to the given value.
6300    ///
6301    /// Even though the property as already been set when instantiating this call,
6302    /// we provide this method for API completeness.
6303    pub fn attachment_id(mut self, new_value: &str) -> TimelineAttachmentGetCall<'a, C> {
6304        self._attachment_id = new_value.to_string();
6305        self
6306    }
6307    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6308    /// while executing the actual API request.
6309    ///
6310    /// ````text
6311    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6312    /// ````
6313    ///
6314    /// Sets the *delegate* property to the given value.
6315    pub fn delegate(
6316        mut self,
6317        new_value: &'a mut dyn common::Delegate,
6318    ) -> TimelineAttachmentGetCall<'a, C> {
6319        self._delegate = Some(new_value);
6320        self
6321    }
6322
6323    /// Set any additional parameter of the query string used in the request.
6324    /// It should be used to set parameters which are not yet available through their own
6325    /// setters.
6326    ///
6327    /// Please note that this method must not be used to set any of the known parameters
6328    /// which have their own setter method. If done anyway, the request will fail.
6329    ///
6330    /// # Additional Parameters
6331    ///
6332    /// * *alt* (query-string) - Data format for the response.
6333    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6334    /// * *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.
6335    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6336    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6337    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6338    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6339    pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentGetCall<'a, C>
6340    where
6341        T: AsRef<str>,
6342    {
6343        self._additional_params
6344            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6345        self
6346    }
6347
6348    /// Identifies the authorization scope for the method you are building.
6349    ///
6350    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6351    /// [`Scope::GlasTimeline`].
6352    ///
6353    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6354    /// tokens for more than one scope.
6355    ///
6356    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6357    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6358    /// sufficient, a read-write scope will do as well.
6359    pub fn add_scope<St>(mut self, scope: St) -> TimelineAttachmentGetCall<'a, C>
6360    where
6361        St: AsRef<str>,
6362    {
6363        self._scopes.insert(String::from(scope.as_ref()));
6364        self
6365    }
6366    /// Identifies the authorization scope(s) for the method you are building.
6367    ///
6368    /// See [`Self::add_scope()`] for details.
6369    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineAttachmentGetCall<'a, C>
6370    where
6371        I: IntoIterator<Item = St>,
6372        St: AsRef<str>,
6373    {
6374        self._scopes
6375            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6376        self
6377    }
6378
6379    /// Removes all scopes, and no default scope will be used either.
6380    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6381    /// for details).
6382    pub fn clear_scopes(mut self) -> TimelineAttachmentGetCall<'a, C> {
6383        self._scopes.clear();
6384        self
6385    }
6386}
6387
6388/// Adds a new attachment to a timeline item.
6389///
6390/// A builder for the *attachments.insert* method supported by a *timeline* resource.
6391/// It is not used directly, but through a [`TimelineMethods`] instance.
6392///
6393/// # Example
6394///
6395/// Instantiate a resource method builder
6396///
6397/// ```test_harness,no_run
6398/// # extern crate hyper;
6399/// # extern crate hyper_rustls;
6400/// # extern crate google_mirror1 as mirror1;
6401/// use std::fs;
6402/// # async fn dox() {
6403/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6404///
6405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6406/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6407/// #     .with_native_roots()
6408/// #     .unwrap()
6409/// #     .https_only()
6410/// #     .enable_http2()
6411/// #     .build();
6412///
6413/// # let executor = hyper_util::rt::TokioExecutor::new();
6414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6415/// #     secret,
6416/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6417/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6418/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6419/// #     ),
6420/// # ).build().await.unwrap();
6421///
6422/// # let client = hyper_util::client::legacy::Client::builder(
6423/// #     hyper_util::rt::TokioExecutor::new()
6424/// # )
6425/// # .build(
6426/// #     hyper_rustls::HttpsConnectorBuilder::new()
6427/// #         .with_native_roots()
6428/// #         .unwrap()
6429/// #         .https_or_http()
6430/// #         .enable_http2()
6431/// #         .build()
6432/// # );
6433/// # let mut hub = Mirror::new(client, auth);
6434/// // You can configure optional parameters by calling the respective setters at will, and
6435/// // execute the final call using `upload_resumable(...)`.
6436/// // Values shown here are possibly random and not representative !
6437/// let result = hub.timeline().attachments_insert("itemId")
6438///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
6439/// # }
6440/// ```
6441pub struct TimelineAttachmentInsertCall<'a, C>
6442where
6443    C: 'a,
6444{
6445    hub: &'a Mirror<C>,
6446    _item_id: String,
6447    _delegate: Option<&'a mut dyn common::Delegate>,
6448    _additional_params: HashMap<String, String>,
6449    _scopes: BTreeSet<String>,
6450}
6451
6452impl<'a, C> common::CallBuilder for TimelineAttachmentInsertCall<'a, C> {}
6453
6454impl<'a, C> TimelineAttachmentInsertCall<'a, C>
6455where
6456    C: common::Connector,
6457{
6458    /// Perform the operation you have build so far.
6459    async fn doit<RS>(
6460        mut self,
6461        mut reader: RS,
6462        reader_mime_type: mime::Mime,
6463        protocol: common::UploadProtocol,
6464    ) -> common::Result<(common::Response, Attachment)>
6465    where
6466        RS: common::ReadSeek,
6467    {
6468        use std::borrow::Cow;
6469        use std::io::{Read, Seek};
6470
6471        use common::{url::Params, ToParts};
6472        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6473
6474        let mut dd = common::DefaultDelegate;
6475        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6476        dlg.begin(common::MethodInfo {
6477            id: "mirror.timeline.attachments.insert",
6478            http_method: hyper::Method::POST,
6479        });
6480
6481        for &field in ["alt", "itemId"].iter() {
6482            if self._additional_params.contains_key(field) {
6483                dlg.finished(false);
6484                return Err(common::Error::FieldClash(field));
6485            }
6486        }
6487
6488        let mut params = Params::with_capacity(3 + self._additional_params.len());
6489        params.push("itemId", self._item_id);
6490
6491        params.extend(self._additional_params.iter());
6492
6493        params.push("alt", "json");
6494        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
6495            (
6496                self.hub._root_url.clone()
6497                    + "resumable/upload/mirror/v1/timeline/{itemId}/attachments",
6498                "resumable",
6499            )
6500        } else if protocol == common::UploadProtocol::Simple {
6501            (
6502                self.hub._root_url.clone() + "upload/mirror/v1/timeline/{itemId}/attachments",
6503                "multipart",
6504            )
6505        } else {
6506            unreachable!()
6507        };
6508        params.push("uploadType", upload_type);
6509        if self._scopes.is_empty() {
6510            self._scopes
6511                .insert(Scope::GlasTimeline.as_ref().to_string());
6512        }
6513
6514        #[allow(clippy::single_element_loop)]
6515        for &(find_this, param_name) in [("{itemId}", "itemId")].iter() {
6516            url = params.uri_replacement(url, param_name, find_this, false);
6517        }
6518        {
6519            let to_remove = ["itemId"];
6520            params.remove_params(&to_remove);
6521        }
6522
6523        let url = params.parse_with_url(&url);
6524
6525        let mut upload_url_from_server;
6526
6527        loop {
6528            let token = match self
6529                .hub
6530                .auth
6531                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6532                .await
6533            {
6534                Ok(token) => token,
6535                Err(e) => match dlg.token(e) {
6536                    Ok(token) => token,
6537                    Err(e) => {
6538                        dlg.finished(false);
6539                        return Err(common::Error::MissingToken(e));
6540                    }
6541                },
6542            };
6543            let mut req_result = {
6544                let client = &self.hub.client;
6545                dlg.pre_request();
6546                let mut req_builder = hyper::Request::builder()
6547                    .method(hyper::Method::POST)
6548                    .uri(url.as_str())
6549                    .header(USER_AGENT, self.hub._user_agent.clone());
6550
6551                if let Some(token) = token.as_ref() {
6552                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6553                }
6554
6555                upload_url_from_server = true;
6556                if protocol == common::UploadProtocol::Resumable {
6557                    req_builder = req_builder
6558                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
6559                }
6560
6561                let request = if protocol == common::UploadProtocol::Simple {
6562                    let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6563                    reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6564                    if size > 10485760 {
6565                        return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
6566                    }
6567                    let mut bytes = Vec::with_capacity(size as usize);
6568                    reader.read_to_end(&mut bytes)?;
6569                    req_builder
6570                        .header(CONTENT_TYPE, reader_mime_type.to_string())
6571                        .header(CONTENT_LENGTH, size)
6572                        .body(common::to_body(bytes.into()))
6573                } else {
6574                    req_builder.body(common::to_body::<String>(None))
6575                };
6576
6577                client.request(request.unwrap()).await
6578            };
6579
6580            match req_result {
6581                Err(err) => {
6582                    if let common::Retry::After(d) = dlg.http_error(&err) {
6583                        sleep(d).await;
6584                        continue;
6585                    }
6586                    dlg.finished(false);
6587                    return Err(common::Error::HttpError(err));
6588                }
6589                Ok(res) => {
6590                    let (mut parts, body) = res.into_parts();
6591                    let mut body = common::Body::new(body);
6592                    if !parts.status.is_success() {
6593                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6594                        let error = serde_json::from_str(&common::to_string(&bytes));
6595                        let response = common::to_response(parts, bytes.into());
6596
6597                        if let common::Retry::After(d) =
6598                            dlg.http_failure(&response, error.as_ref().ok())
6599                        {
6600                            sleep(d).await;
6601                            continue;
6602                        }
6603
6604                        dlg.finished(false);
6605
6606                        return Err(match error {
6607                            Ok(value) => common::Error::BadRequest(value),
6608                            _ => common::Error::Failure(response),
6609                        });
6610                    }
6611                    if protocol == common::UploadProtocol::Resumable {
6612                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
6613                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
6614                        if size > 10485760 {
6615                            return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
6616                        }
6617                        let upload_result = {
6618                            let url_str = &parts
6619                                .headers
6620                                .get("Location")
6621                                .expect("LOCATION header is part of protocol")
6622                                .to_str()
6623                                .unwrap();
6624                            if upload_url_from_server {
6625                                dlg.store_upload_url(Some(url_str));
6626                            }
6627
6628                            common::ResumableUploadHelper {
6629                                client: &self.hub.client,
6630                                delegate: dlg,
6631                                start_at: if upload_url_from_server {
6632                                    Some(0)
6633                                } else {
6634                                    None
6635                                },
6636                                auth: &self.hub.auth,
6637                                user_agent: &self.hub._user_agent,
6638                                // TODO: Check this assumption
6639                                auth_header: format!(
6640                                    "Bearer {}",
6641                                    token
6642                                        .ok_or_else(|| common::Error::MissingToken(
6643                                            "resumable upload requires token".into()
6644                                        ))?
6645                                        .as_str()
6646                                ),
6647                                url: url_str,
6648                                reader: &mut reader,
6649                                media_type: reader_mime_type.clone(),
6650                                content_length: size,
6651                            }
6652                            .upload()
6653                            .await
6654                        };
6655                        match upload_result {
6656                            None => {
6657                                dlg.finished(false);
6658                                return Err(common::Error::Cancelled);
6659                            }
6660                            Some(Err(err)) => {
6661                                dlg.finished(false);
6662                                return Err(common::Error::HttpError(err));
6663                            }
6664                            Some(Ok(response)) => {
6665                                (parts, body) = response.into_parts();
6666                                if !parts.status.is_success() {
6667                                    dlg.store_upload_url(None);
6668                                    dlg.finished(false);
6669                                    return Err(common::Error::Failure(
6670                                        common::Response::from_parts(parts, body),
6671                                    ));
6672                                }
6673                            }
6674                        }
6675                    }
6676                    let response = {
6677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6678                        let encoded = common::to_string(&bytes);
6679                        match serde_json::from_str(&encoded) {
6680                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6681                            Err(error) => {
6682                                dlg.response_json_decode_error(&encoded, &error);
6683                                return Err(common::Error::JsonDecodeError(
6684                                    encoded.to_string(),
6685                                    error,
6686                                ));
6687                            }
6688                        }
6689                    };
6690
6691                    dlg.finished(true);
6692                    return Ok(response);
6693                }
6694            }
6695        }
6696    }
6697
6698    /// Upload media in a resumable fashion.
6699    /// Even if the upload fails or is interrupted, it can be resumed for a
6700    /// certain amount of time as the server maintains state temporarily.
6701    ///
6702    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
6703    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
6704    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
6705    /// `cancel_chunk_upload(...)`.
6706    ///
6707    /// * *multipart*: yes
6708    /// * *max size*: 10MB
6709    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
6710    pub async fn upload_resumable<RS>(
6711        self,
6712        resumeable_stream: RS,
6713        mime_type: mime::Mime,
6714    ) -> common::Result<(common::Response, Attachment)>
6715    where
6716        RS: common::ReadSeek,
6717    {
6718        self.doit(
6719            resumeable_stream,
6720            mime_type,
6721            common::UploadProtocol::Resumable,
6722        )
6723        .await
6724    }
6725    /// Upload media all at once.
6726    /// If the upload fails for whichever reason, all progress is lost.
6727    ///
6728    /// * *multipart*: yes
6729    /// * *max size*: 10MB
6730    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
6731    pub async fn upload<RS>(
6732        self,
6733        stream: RS,
6734        mime_type: mime::Mime,
6735    ) -> common::Result<(common::Response, Attachment)>
6736    where
6737        RS: common::ReadSeek,
6738    {
6739        self.doit(stream, mime_type, common::UploadProtocol::Simple)
6740            .await
6741    }
6742
6743    /// The ID of the timeline item the attachment belongs to.
6744    ///
6745    /// Sets the *item id* path property to the given value.
6746    ///
6747    /// Even though the property as already been set when instantiating this call,
6748    /// we provide this method for API completeness.
6749    pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentInsertCall<'a, C> {
6750        self._item_id = new_value.to_string();
6751        self
6752    }
6753    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6754    /// while executing the actual API request.
6755    ///
6756    /// ````text
6757    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6758    /// ````
6759    ///
6760    /// Sets the *delegate* property to the given value.
6761    pub fn delegate(
6762        mut self,
6763        new_value: &'a mut dyn common::Delegate,
6764    ) -> TimelineAttachmentInsertCall<'a, C> {
6765        self._delegate = Some(new_value);
6766        self
6767    }
6768
6769    /// Set any additional parameter of the query string used in the request.
6770    /// It should be used to set parameters which are not yet available through their own
6771    /// setters.
6772    ///
6773    /// Please note that this method must not be used to set any of the known parameters
6774    /// which have their own setter method. If done anyway, the request will fail.
6775    ///
6776    /// # Additional Parameters
6777    ///
6778    /// * *alt* (query-string) - Data format for the response.
6779    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6780    /// * *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.
6781    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6782    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6783    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6784    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6785    pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentInsertCall<'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::GlasTimeline`].
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) -> TimelineAttachmentInsertCall<'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) -> TimelineAttachmentInsertCall<'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) -> TimelineAttachmentInsertCall<'a, C> {
6829        self._scopes.clear();
6830        self
6831    }
6832}
6833
6834/// Returns a list of attachments for a timeline item.
6835///
6836/// A builder for the *attachments.list* method supported by a *timeline* resource.
6837/// It is not used directly, but through a [`TimelineMethods`] 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_mirror1 as mirror1;
6847/// # async fn dox() {
6848/// # use mirror1::{Mirror, 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 = Mirror::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.timeline().attachments_list("itemId")
6883///              .doit().await;
6884/// # }
6885/// ```
6886pub struct TimelineAttachmentListCall<'a, C>
6887where
6888    C: 'a,
6889{
6890    hub: &'a Mirror<C>,
6891    _item_id: String,
6892    _delegate: Option<&'a mut dyn common::Delegate>,
6893    _additional_params: HashMap<String, String>,
6894    _scopes: BTreeSet<String>,
6895}
6896
6897impl<'a, C> common::CallBuilder for TimelineAttachmentListCall<'a, C> {}
6898
6899impl<'a, C> TimelineAttachmentListCall<'a, C>
6900where
6901    C: common::Connector,
6902{
6903    /// Perform the operation you have build so far.
6904    pub async fn doit(mut self) -> common::Result<(common::Response, AttachmentsListResponse)> {
6905        use std::borrow::Cow;
6906        use std::io::{Read, Seek};
6907
6908        use common::{url::Params, ToParts};
6909        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6910
6911        let mut dd = common::DefaultDelegate;
6912        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6913        dlg.begin(common::MethodInfo {
6914            id: "mirror.timeline.attachments.list",
6915            http_method: hyper::Method::GET,
6916        });
6917
6918        for &field in ["alt", "itemId"].iter() {
6919            if self._additional_params.contains_key(field) {
6920                dlg.finished(false);
6921                return Err(common::Error::FieldClash(field));
6922            }
6923        }
6924
6925        let mut params = Params::with_capacity(3 + self._additional_params.len());
6926        params.push("itemId", self._item_id);
6927
6928        params.extend(self._additional_params.iter());
6929
6930        params.push("alt", "json");
6931        let mut url = self.hub._base_url.clone() + "timeline/{itemId}/attachments";
6932        if self._scopes.is_empty() {
6933            self._scopes
6934                .insert(Scope::GlasTimeline.as_ref().to_string());
6935        }
6936
6937        #[allow(clippy::single_element_loop)]
6938        for &(find_this, param_name) in [("{itemId}", "itemId")].iter() {
6939            url = params.uri_replacement(url, param_name, find_this, false);
6940        }
6941        {
6942            let to_remove = ["itemId"];
6943            params.remove_params(&to_remove);
6944        }
6945
6946        let url = params.parse_with_url(&url);
6947
6948        loop {
6949            let token = match self
6950                .hub
6951                .auth
6952                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6953                .await
6954            {
6955                Ok(token) => token,
6956                Err(e) => match dlg.token(e) {
6957                    Ok(token) => token,
6958                    Err(e) => {
6959                        dlg.finished(false);
6960                        return Err(common::Error::MissingToken(e));
6961                    }
6962                },
6963            };
6964            let mut req_result = {
6965                let client = &self.hub.client;
6966                dlg.pre_request();
6967                let mut req_builder = hyper::Request::builder()
6968                    .method(hyper::Method::GET)
6969                    .uri(url.as_str())
6970                    .header(USER_AGENT, self.hub._user_agent.clone());
6971
6972                if let Some(token) = token.as_ref() {
6973                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6974                }
6975
6976                let request = req_builder
6977                    .header(CONTENT_LENGTH, 0_u64)
6978                    .body(common::to_body::<String>(None));
6979
6980                client.request(request.unwrap()).await
6981            };
6982
6983            match req_result {
6984                Err(err) => {
6985                    if let common::Retry::After(d) = dlg.http_error(&err) {
6986                        sleep(d).await;
6987                        continue;
6988                    }
6989                    dlg.finished(false);
6990                    return Err(common::Error::HttpError(err));
6991                }
6992                Ok(res) => {
6993                    let (mut parts, body) = res.into_parts();
6994                    let mut body = common::Body::new(body);
6995                    if !parts.status.is_success() {
6996                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6997                        let error = serde_json::from_str(&common::to_string(&bytes));
6998                        let response = common::to_response(parts, bytes.into());
6999
7000                        if let common::Retry::After(d) =
7001                            dlg.http_failure(&response, error.as_ref().ok())
7002                        {
7003                            sleep(d).await;
7004                            continue;
7005                        }
7006
7007                        dlg.finished(false);
7008
7009                        return Err(match error {
7010                            Ok(value) => common::Error::BadRequest(value),
7011                            _ => common::Error::Failure(response),
7012                        });
7013                    }
7014                    let response = {
7015                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7016                        let encoded = common::to_string(&bytes);
7017                        match serde_json::from_str(&encoded) {
7018                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7019                            Err(error) => {
7020                                dlg.response_json_decode_error(&encoded, &error);
7021                                return Err(common::Error::JsonDecodeError(
7022                                    encoded.to_string(),
7023                                    error,
7024                                ));
7025                            }
7026                        }
7027                    };
7028
7029                    dlg.finished(true);
7030                    return Ok(response);
7031                }
7032            }
7033        }
7034    }
7035
7036    /// The ID of the timeline item whose attachments should be listed.
7037    ///
7038    /// Sets the *item id* path property to the given value.
7039    ///
7040    /// Even though the property as already been set when instantiating this call,
7041    /// we provide this method for API completeness.
7042    pub fn item_id(mut self, new_value: &str) -> TimelineAttachmentListCall<'a, C> {
7043        self._item_id = new_value.to_string();
7044        self
7045    }
7046    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7047    /// while executing the actual API request.
7048    ///
7049    /// ````text
7050    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7051    /// ````
7052    ///
7053    /// Sets the *delegate* property to the given value.
7054    pub fn delegate(
7055        mut self,
7056        new_value: &'a mut dyn common::Delegate,
7057    ) -> TimelineAttachmentListCall<'a, C> {
7058        self._delegate = Some(new_value);
7059        self
7060    }
7061
7062    /// Set any additional parameter of the query string used in the request.
7063    /// It should be used to set parameters which are not yet available through their own
7064    /// setters.
7065    ///
7066    /// Please note that this method must not be used to set any of the known parameters
7067    /// which have their own setter method. If done anyway, the request will fail.
7068    ///
7069    /// # Additional Parameters
7070    ///
7071    /// * *alt* (query-string) - Data format for the response.
7072    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7073    /// * *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.
7074    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7075    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7076    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7077    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7078    pub fn param<T>(mut self, name: T, value: T) -> TimelineAttachmentListCall<'a, C>
7079    where
7080        T: AsRef<str>,
7081    {
7082        self._additional_params
7083            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7084        self
7085    }
7086
7087    /// Identifies the authorization scope for the method you are building.
7088    ///
7089    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7090    /// [`Scope::GlasTimeline`].
7091    ///
7092    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7093    /// tokens for more than one scope.
7094    ///
7095    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7096    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7097    /// sufficient, a read-write scope will do as well.
7098    pub fn add_scope<St>(mut self, scope: St) -> TimelineAttachmentListCall<'a, C>
7099    where
7100        St: AsRef<str>,
7101    {
7102        self._scopes.insert(String::from(scope.as_ref()));
7103        self
7104    }
7105    /// Identifies the authorization scope(s) for the method you are building.
7106    ///
7107    /// See [`Self::add_scope()`] for details.
7108    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineAttachmentListCall<'a, C>
7109    where
7110        I: IntoIterator<Item = St>,
7111        St: AsRef<str>,
7112    {
7113        self._scopes
7114            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7115        self
7116    }
7117
7118    /// Removes all scopes, and no default scope will be used either.
7119    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7120    /// for details).
7121    pub fn clear_scopes(mut self) -> TimelineAttachmentListCall<'a, C> {
7122        self._scopes.clear();
7123        self
7124    }
7125}
7126
7127/// Deletes a timeline item.
7128///
7129/// A builder for the *delete* method supported by a *timeline* resource.
7130/// It is not used directly, but through a [`TimelineMethods`] instance.
7131///
7132/// # Example
7133///
7134/// Instantiate a resource method builder
7135///
7136/// ```test_harness,no_run
7137/// # extern crate hyper;
7138/// # extern crate hyper_rustls;
7139/// # extern crate google_mirror1 as mirror1;
7140/// # async fn dox() {
7141/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7142///
7143/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7144/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7145/// #     .with_native_roots()
7146/// #     .unwrap()
7147/// #     .https_only()
7148/// #     .enable_http2()
7149/// #     .build();
7150///
7151/// # let executor = hyper_util::rt::TokioExecutor::new();
7152/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7153/// #     secret,
7154/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7155/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7156/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7157/// #     ),
7158/// # ).build().await.unwrap();
7159///
7160/// # let client = hyper_util::client::legacy::Client::builder(
7161/// #     hyper_util::rt::TokioExecutor::new()
7162/// # )
7163/// # .build(
7164/// #     hyper_rustls::HttpsConnectorBuilder::new()
7165/// #         .with_native_roots()
7166/// #         .unwrap()
7167/// #         .https_or_http()
7168/// #         .enable_http2()
7169/// #         .build()
7170/// # );
7171/// # let mut hub = Mirror::new(client, auth);
7172/// // You can configure optional parameters by calling the respective setters at will, and
7173/// // execute the final call using `doit()`.
7174/// // Values shown here are possibly random and not representative !
7175/// let result = hub.timeline().delete("id")
7176///              .doit().await;
7177/// # }
7178/// ```
7179pub struct TimelineDeleteCall<'a, C>
7180where
7181    C: 'a,
7182{
7183    hub: &'a Mirror<C>,
7184    _id: String,
7185    _delegate: Option<&'a mut dyn common::Delegate>,
7186    _additional_params: HashMap<String, String>,
7187    _scopes: BTreeSet<String>,
7188}
7189
7190impl<'a, C> common::CallBuilder for TimelineDeleteCall<'a, C> {}
7191
7192impl<'a, C> TimelineDeleteCall<'a, C>
7193where
7194    C: common::Connector,
7195{
7196    /// Perform the operation you have build so far.
7197    pub async fn doit(mut self) -> common::Result<common::Response> {
7198        use std::borrow::Cow;
7199        use std::io::{Read, Seek};
7200
7201        use common::{url::Params, ToParts};
7202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7203
7204        let mut dd = common::DefaultDelegate;
7205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7206        dlg.begin(common::MethodInfo {
7207            id: "mirror.timeline.delete",
7208            http_method: hyper::Method::DELETE,
7209        });
7210
7211        for &field in ["id"].iter() {
7212            if self._additional_params.contains_key(field) {
7213                dlg.finished(false);
7214                return Err(common::Error::FieldClash(field));
7215            }
7216        }
7217
7218        let mut params = Params::with_capacity(2 + self._additional_params.len());
7219        params.push("id", self._id);
7220
7221        params.extend(self._additional_params.iter());
7222
7223        let mut url = self.hub._base_url.clone() + "timeline/{id}";
7224        if self._scopes.is_empty() {
7225            self._scopes
7226                .insert(Scope::GlasLocation.as_ref().to_string());
7227        }
7228
7229        #[allow(clippy::single_element_loop)]
7230        for &(find_this, param_name) in [("{id}", "id")].iter() {
7231            url = params.uri_replacement(url, param_name, find_this, false);
7232        }
7233        {
7234            let to_remove = ["id"];
7235            params.remove_params(&to_remove);
7236        }
7237
7238        let url = params.parse_with_url(&url);
7239
7240        loop {
7241            let token = match self
7242                .hub
7243                .auth
7244                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7245                .await
7246            {
7247                Ok(token) => token,
7248                Err(e) => match dlg.token(e) {
7249                    Ok(token) => token,
7250                    Err(e) => {
7251                        dlg.finished(false);
7252                        return Err(common::Error::MissingToken(e));
7253                    }
7254                },
7255            };
7256            let mut req_result = {
7257                let client = &self.hub.client;
7258                dlg.pre_request();
7259                let mut req_builder = hyper::Request::builder()
7260                    .method(hyper::Method::DELETE)
7261                    .uri(url.as_str())
7262                    .header(USER_AGENT, self.hub._user_agent.clone());
7263
7264                if let Some(token) = token.as_ref() {
7265                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7266                }
7267
7268                let request = req_builder
7269                    .header(CONTENT_LENGTH, 0_u64)
7270                    .body(common::to_body::<String>(None));
7271
7272                client.request(request.unwrap()).await
7273            };
7274
7275            match req_result {
7276                Err(err) => {
7277                    if let common::Retry::After(d) = dlg.http_error(&err) {
7278                        sleep(d).await;
7279                        continue;
7280                    }
7281                    dlg.finished(false);
7282                    return Err(common::Error::HttpError(err));
7283                }
7284                Ok(res) => {
7285                    let (mut parts, body) = res.into_parts();
7286                    let mut body = common::Body::new(body);
7287                    if !parts.status.is_success() {
7288                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7289                        let error = serde_json::from_str(&common::to_string(&bytes));
7290                        let response = common::to_response(parts, bytes.into());
7291
7292                        if let common::Retry::After(d) =
7293                            dlg.http_failure(&response, error.as_ref().ok())
7294                        {
7295                            sleep(d).await;
7296                            continue;
7297                        }
7298
7299                        dlg.finished(false);
7300
7301                        return Err(match error {
7302                            Ok(value) => common::Error::BadRequest(value),
7303                            _ => common::Error::Failure(response),
7304                        });
7305                    }
7306                    let response = common::Response::from_parts(parts, body);
7307
7308                    dlg.finished(true);
7309                    return Ok(response);
7310                }
7311            }
7312        }
7313    }
7314
7315    /// The ID of the timeline item.
7316    ///
7317    /// Sets the *id* path property to the given value.
7318    ///
7319    /// Even though the property as already been set when instantiating this call,
7320    /// we provide this method for API completeness.
7321    pub fn id(mut self, new_value: &str) -> TimelineDeleteCall<'a, C> {
7322        self._id = new_value.to_string();
7323        self
7324    }
7325    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7326    /// while executing the actual API request.
7327    ///
7328    /// ````text
7329    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7330    /// ````
7331    ///
7332    /// Sets the *delegate* property to the given value.
7333    pub fn delegate(
7334        mut self,
7335        new_value: &'a mut dyn common::Delegate,
7336    ) -> TimelineDeleteCall<'a, C> {
7337        self._delegate = Some(new_value);
7338        self
7339    }
7340
7341    /// Set any additional parameter of the query string used in the request.
7342    /// It should be used to set parameters which are not yet available through their own
7343    /// setters.
7344    ///
7345    /// Please note that this method must not be used to set any of the known parameters
7346    /// which have their own setter method. If done anyway, the request will fail.
7347    ///
7348    /// # Additional Parameters
7349    ///
7350    /// * *alt* (query-string) - Data format for the response.
7351    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7352    /// * *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.
7353    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7354    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7355    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7356    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7357    pub fn param<T>(mut self, name: T, value: T) -> TimelineDeleteCall<'a, C>
7358    where
7359        T: AsRef<str>,
7360    {
7361        self._additional_params
7362            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7363        self
7364    }
7365
7366    /// Identifies the authorization scope for the method you are building.
7367    ///
7368    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7369    /// [`Scope::GlasLocation`].
7370    ///
7371    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7372    /// tokens for more than one scope.
7373    ///
7374    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7375    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7376    /// sufficient, a read-write scope will do as well.
7377    pub fn add_scope<St>(mut self, scope: St) -> TimelineDeleteCall<'a, C>
7378    where
7379        St: AsRef<str>,
7380    {
7381        self._scopes.insert(String::from(scope.as_ref()));
7382        self
7383    }
7384    /// Identifies the authorization scope(s) for the method you are building.
7385    ///
7386    /// See [`Self::add_scope()`] for details.
7387    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineDeleteCall<'a, C>
7388    where
7389        I: IntoIterator<Item = St>,
7390        St: AsRef<str>,
7391    {
7392        self._scopes
7393            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7394        self
7395    }
7396
7397    /// Removes all scopes, and no default scope will be used either.
7398    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7399    /// for details).
7400    pub fn clear_scopes(mut self) -> TimelineDeleteCall<'a, C> {
7401        self._scopes.clear();
7402        self
7403    }
7404}
7405
7406/// Gets a single timeline item by ID.
7407///
7408/// A builder for the *get* method supported by a *timeline* resource.
7409/// It is not used directly, but through a [`TimelineMethods`] instance.
7410///
7411/// # Example
7412///
7413/// Instantiate a resource method builder
7414///
7415/// ```test_harness,no_run
7416/// # extern crate hyper;
7417/// # extern crate hyper_rustls;
7418/// # extern crate google_mirror1 as mirror1;
7419/// # async fn dox() {
7420/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7421///
7422/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7423/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7424/// #     .with_native_roots()
7425/// #     .unwrap()
7426/// #     .https_only()
7427/// #     .enable_http2()
7428/// #     .build();
7429///
7430/// # let executor = hyper_util::rt::TokioExecutor::new();
7431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7432/// #     secret,
7433/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7434/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7435/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7436/// #     ),
7437/// # ).build().await.unwrap();
7438///
7439/// # let client = hyper_util::client::legacy::Client::builder(
7440/// #     hyper_util::rt::TokioExecutor::new()
7441/// # )
7442/// # .build(
7443/// #     hyper_rustls::HttpsConnectorBuilder::new()
7444/// #         .with_native_roots()
7445/// #         .unwrap()
7446/// #         .https_or_http()
7447/// #         .enable_http2()
7448/// #         .build()
7449/// # );
7450/// # let mut hub = Mirror::new(client, auth);
7451/// // You can configure optional parameters by calling the respective setters at will, and
7452/// // execute the final call using `doit()`.
7453/// // Values shown here are possibly random and not representative !
7454/// let result = hub.timeline().get("id")
7455///              .doit().await;
7456/// # }
7457/// ```
7458pub struct TimelineGetCall<'a, C>
7459where
7460    C: 'a,
7461{
7462    hub: &'a Mirror<C>,
7463    _id: String,
7464    _delegate: Option<&'a mut dyn common::Delegate>,
7465    _additional_params: HashMap<String, String>,
7466    _scopes: BTreeSet<String>,
7467}
7468
7469impl<'a, C> common::CallBuilder for TimelineGetCall<'a, C> {}
7470
7471impl<'a, C> TimelineGetCall<'a, C>
7472where
7473    C: common::Connector,
7474{
7475    /// Perform the operation you have build so far.
7476    pub async fn doit(mut self) -> common::Result<(common::Response, TimelineItem)> {
7477        use std::borrow::Cow;
7478        use std::io::{Read, Seek};
7479
7480        use common::{url::Params, ToParts};
7481        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7482
7483        let mut dd = common::DefaultDelegate;
7484        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7485        dlg.begin(common::MethodInfo {
7486            id: "mirror.timeline.get",
7487            http_method: hyper::Method::GET,
7488        });
7489
7490        for &field in ["alt", "id"].iter() {
7491            if self._additional_params.contains_key(field) {
7492                dlg.finished(false);
7493                return Err(common::Error::FieldClash(field));
7494            }
7495        }
7496
7497        let mut params = Params::with_capacity(3 + self._additional_params.len());
7498        params.push("id", self._id);
7499
7500        params.extend(self._additional_params.iter());
7501
7502        params.push("alt", "json");
7503        let mut url = self.hub._base_url.clone() + "timeline/{id}";
7504        if self._scopes.is_empty() {
7505            self._scopes
7506                .insert(Scope::GlasLocation.as_ref().to_string());
7507        }
7508
7509        #[allow(clippy::single_element_loop)]
7510        for &(find_this, param_name) in [("{id}", "id")].iter() {
7511            url = params.uri_replacement(url, param_name, find_this, false);
7512        }
7513        {
7514            let to_remove = ["id"];
7515            params.remove_params(&to_remove);
7516        }
7517
7518        let url = params.parse_with_url(&url);
7519
7520        loop {
7521            let token = match self
7522                .hub
7523                .auth
7524                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7525                .await
7526            {
7527                Ok(token) => token,
7528                Err(e) => match dlg.token(e) {
7529                    Ok(token) => token,
7530                    Err(e) => {
7531                        dlg.finished(false);
7532                        return Err(common::Error::MissingToken(e));
7533                    }
7534                },
7535            };
7536            let mut req_result = {
7537                let client = &self.hub.client;
7538                dlg.pre_request();
7539                let mut req_builder = hyper::Request::builder()
7540                    .method(hyper::Method::GET)
7541                    .uri(url.as_str())
7542                    .header(USER_AGENT, self.hub._user_agent.clone());
7543
7544                if let Some(token) = token.as_ref() {
7545                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7546                }
7547
7548                let request = req_builder
7549                    .header(CONTENT_LENGTH, 0_u64)
7550                    .body(common::to_body::<String>(None));
7551
7552                client.request(request.unwrap()).await
7553            };
7554
7555            match req_result {
7556                Err(err) => {
7557                    if let common::Retry::After(d) = dlg.http_error(&err) {
7558                        sleep(d).await;
7559                        continue;
7560                    }
7561                    dlg.finished(false);
7562                    return Err(common::Error::HttpError(err));
7563                }
7564                Ok(res) => {
7565                    let (mut parts, body) = res.into_parts();
7566                    let mut body = common::Body::new(body);
7567                    if !parts.status.is_success() {
7568                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7569                        let error = serde_json::from_str(&common::to_string(&bytes));
7570                        let response = common::to_response(parts, bytes.into());
7571
7572                        if let common::Retry::After(d) =
7573                            dlg.http_failure(&response, error.as_ref().ok())
7574                        {
7575                            sleep(d).await;
7576                            continue;
7577                        }
7578
7579                        dlg.finished(false);
7580
7581                        return Err(match error {
7582                            Ok(value) => common::Error::BadRequest(value),
7583                            _ => common::Error::Failure(response),
7584                        });
7585                    }
7586                    let response = {
7587                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7588                        let encoded = common::to_string(&bytes);
7589                        match serde_json::from_str(&encoded) {
7590                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7591                            Err(error) => {
7592                                dlg.response_json_decode_error(&encoded, &error);
7593                                return Err(common::Error::JsonDecodeError(
7594                                    encoded.to_string(),
7595                                    error,
7596                                ));
7597                            }
7598                        }
7599                    };
7600
7601                    dlg.finished(true);
7602                    return Ok(response);
7603                }
7604            }
7605        }
7606    }
7607
7608    /// The ID of the timeline item.
7609    ///
7610    /// Sets the *id* path property to the given value.
7611    ///
7612    /// Even though the property as already been set when instantiating this call,
7613    /// we provide this method for API completeness.
7614    pub fn id(mut self, new_value: &str) -> TimelineGetCall<'a, C> {
7615        self._id = new_value.to_string();
7616        self
7617    }
7618    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7619    /// while executing the actual API request.
7620    ///
7621    /// ````text
7622    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7623    /// ````
7624    ///
7625    /// Sets the *delegate* property to the given value.
7626    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TimelineGetCall<'a, C> {
7627        self._delegate = Some(new_value);
7628        self
7629    }
7630
7631    /// Set any additional parameter of the query string used in the request.
7632    /// It should be used to set parameters which are not yet available through their own
7633    /// setters.
7634    ///
7635    /// Please note that this method must not be used to set any of the known parameters
7636    /// which have their own setter method. If done anyway, the request will fail.
7637    ///
7638    /// # Additional Parameters
7639    ///
7640    /// * *alt* (query-string) - Data format for the response.
7641    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7642    /// * *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.
7643    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7644    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7645    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7646    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7647    pub fn param<T>(mut self, name: T, value: T) -> TimelineGetCall<'a, C>
7648    where
7649        T: AsRef<str>,
7650    {
7651        self._additional_params
7652            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7653        self
7654    }
7655
7656    /// Identifies the authorization scope for the method you are building.
7657    ///
7658    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7659    /// [`Scope::GlasLocation`].
7660    ///
7661    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7662    /// tokens for more than one scope.
7663    ///
7664    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7665    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7666    /// sufficient, a read-write scope will do as well.
7667    pub fn add_scope<St>(mut self, scope: St) -> TimelineGetCall<'a, C>
7668    where
7669        St: AsRef<str>,
7670    {
7671        self._scopes.insert(String::from(scope.as_ref()));
7672        self
7673    }
7674    /// Identifies the authorization scope(s) for the method you are building.
7675    ///
7676    /// See [`Self::add_scope()`] for details.
7677    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineGetCall<'a, C>
7678    where
7679        I: IntoIterator<Item = St>,
7680        St: AsRef<str>,
7681    {
7682        self._scopes
7683            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7684        self
7685    }
7686
7687    /// Removes all scopes, and no default scope will be used either.
7688    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7689    /// for details).
7690    pub fn clear_scopes(mut self) -> TimelineGetCall<'a, C> {
7691        self._scopes.clear();
7692        self
7693    }
7694}
7695
7696/// Inserts a new item into the timeline.
7697///
7698/// A builder for the *insert* method supported by a *timeline* resource.
7699/// It is not used directly, but through a [`TimelineMethods`] instance.
7700///
7701/// # Example
7702///
7703/// Instantiate a resource method builder
7704///
7705/// ```test_harness,no_run
7706/// # extern crate hyper;
7707/// # extern crate hyper_rustls;
7708/// # extern crate google_mirror1 as mirror1;
7709/// use mirror1::api::TimelineItem;
7710/// use std::fs;
7711/// # async fn dox() {
7712/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7713///
7714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7715/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7716/// #     .with_native_roots()
7717/// #     .unwrap()
7718/// #     .https_only()
7719/// #     .enable_http2()
7720/// #     .build();
7721///
7722/// # let executor = hyper_util::rt::TokioExecutor::new();
7723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7724/// #     secret,
7725/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7726/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7727/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7728/// #     ),
7729/// # ).build().await.unwrap();
7730///
7731/// # let client = hyper_util::client::legacy::Client::builder(
7732/// #     hyper_util::rt::TokioExecutor::new()
7733/// # )
7734/// # .build(
7735/// #     hyper_rustls::HttpsConnectorBuilder::new()
7736/// #         .with_native_roots()
7737/// #         .unwrap()
7738/// #         .https_or_http()
7739/// #         .enable_http2()
7740/// #         .build()
7741/// # );
7742/// # let mut hub = Mirror::new(client, auth);
7743/// // As the method needs a request, you would usually fill it with the desired information
7744/// // into the respective structure. Some of the parts shown here might not be applicable !
7745/// // Values shown here are possibly random and not representative !
7746/// let mut req = TimelineItem::default();
7747///
7748/// // You can configure optional parameters by calling the respective setters at will, and
7749/// // execute the final call using `upload_resumable(...)`.
7750/// // Values shown here are possibly random and not representative !
7751/// let result = hub.timeline().insert(req)
7752///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
7753/// # }
7754/// ```
7755pub struct TimelineInsertCall<'a, C>
7756where
7757    C: 'a,
7758{
7759    hub: &'a Mirror<C>,
7760    _request: TimelineItem,
7761    _delegate: Option<&'a mut dyn common::Delegate>,
7762    _additional_params: HashMap<String, String>,
7763    _scopes: BTreeSet<String>,
7764}
7765
7766impl<'a, C> common::CallBuilder for TimelineInsertCall<'a, C> {}
7767
7768impl<'a, C> TimelineInsertCall<'a, C>
7769where
7770    C: common::Connector,
7771{
7772    /// Perform the operation you have build so far.
7773    async fn doit<RS>(
7774        mut self,
7775        mut reader: RS,
7776        reader_mime_type: mime::Mime,
7777        protocol: common::UploadProtocol,
7778    ) -> common::Result<(common::Response, TimelineItem)>
7779    where
7780        RS: common::ReadSeek,
7781    {
7782        use std::borrow::Cow;
7783        use std::io::{Read, Seek};
7784
7785        use common::{url::Params, ToParts};
7786        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7787
7788        let mut dd = common::DefaultDelegate;
7789        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7790        dlg.begin(common::MethodInfo {
7791            id: "mirror.timeline.insert",
7792            http_method: hyper::Method::POST,
7793        });
7794
7795        for &field in ["alt"].iter() {
7796            if self._additional_params.contains_key(field) {
7797                dlg.finished(false);
7798                return Err(common::Error::FieldClash(field));
7799            }
7800        }
7801
7802        let mut params = Params::with_capacity(3 + self._additional_params.len());
7803
7804        params.extend(self._additional_params.iter());
7805
7806        params.push("alt", "json");
7807        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
7808            (
7809                self.hub._root_url.clone() + "resumable/upload/mirror/v1/timeline",
7810                "resumable",
7811            )
7812        } else if protocol == common::UploadProtocol::Simple {
7813            (
7814                self.hub._root_url.clone() + "upload/mirror/v1/timeline",
7815                "multipart",
7816            )
7817        } else {
7818            unreachable!()
7819        };
7820        params.push("uploadType", upload_type);
7821        if self._scopes.is_empty() {
7822            self._scopes
7823                .insert(Scope::GlasLocation.as_ref().to_string());
7824        }
7825
7826        let url = params.parse_with_url(&url);
7827
7828        let mut json_mime_type = mime::APPLICATION_JSON;
7829        let mut request_value_reader = {
7830            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7831            common::remove_json_null_values(&mut value);
7832            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7833            serde_json::to_writer(&mut dst, &value).unwrap();
7834            dst
7835        };
7836        let request_size = request_value_reader
7837            .seek(std::io::SeekFrom::End(0))
7838            .unwrap();
7839        request_value_reader
7840            .seek(std::io::SeekFrom::Start(0))
7841            .unwrap();
7842
7843        let mut upload_url_from_server;
7844
7845        loop {
7846            let token = match self
7847                .hub
7848                .auth
7849                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7850                .await
7851            {
7852                Ok(token) => token,
7853                Err(e) => match dlg.token(e) {
7854                    Ok(token) => token,
7855                    Err(e) => {
7856                        dlg.finished(false);
7857                        return Err(common::Error::MissingToken(e));
7858                    }
7859                },
7860            };
7861            request_value_reader
7862                .seek(std::io::SeekFrom::Start(0))
7863                .unwrap();
7864            let mut req_result = {
7865                let mut mp_reader: common::MultiPartReader = Default::default();
7866                let (mut body_reader, content_type) = match protocol {
7867                    common::UploadProtocol::Simple => {
7868                        mp_reader.reserve_exact(2);
7869                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
7870                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
7871                        if size > 10485760 {
7872                            return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
7873                        }
7874                        mp_reader
7875                            .add_part(
7876                                &mut request_value_reader,
7877                                request_size,
7878                                json_mime_type.clone(),
7879                            )
7880                            .add_part(&mut reader, size, reader_mime_type.clone());
7881                        (
7882                            &mut mp_reader as &mut (dyn std::io::Read + Send),
7883                            common::MultiPartReader::mime_type(),
7884                        )
7885                    }
7886                    _ => (
7887                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
7888                        json_mime_type.clone(),
7889                    ),
7890                };
7891                let client = &self.hub.client;
7892                dlg.pre_request();
7893                let mut req_builder = hyper::Request::builder()
7894                    .method(hyper::Method::POST)
7895                    .uri(url.as_str())
7896                    .header(USER_AGENT, self.hub._user_agent.clone());
7897
7898                if let Some(token) = token.as_ref() {
7899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7900                }
7901
7902                upload_url_from_server = true;
7903                if protocol == common::UploadProtocol::Resumable {
7904                    req_builder = req_builder
7905                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
7906                }
7907
7908                let mut body_reader_bytes = vec![];
7909                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
7910                let request = req_builder
7911                    .header(CONTENT_TYPE, content_type.to_string())
7912                    .body(common::to_body(body_reader_bytes.into()));
7913
7914                client.request(request.unwrap()).await
7915            };
7916
7917            match req_result {
7918                Err(err) => {
7919                    if let common::Retry::After(d) = dlg.http_error(&err) {
7920                        sleep(d).await;
7921                        continue;
7922                    }
7923                    dlg.finished(false);
7924                    return Err(common::Error::HttpError(err));
7925                }
7926                Ok(res) => {
7927                    let (mut parts, body) = res.into_parts();
7928                    let mut body = common::Body::new(body);
7929                    if !parts.status.is_success() {
7930                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7931                        let error = serde_json::from_str(&common::to_string(&bytes));
7932                        let response = common::to_response(parts, bytes.into());
7933
7934                        if let common::Retry::After(d) =
7935                            dlg.http_failure(&response, error.as_ref().ok())
7936                        {
7937                            sleep(d).await;
7938                            continue;
7939                        }
7940
7941                        dlg.finished(false);
7942
7943                        return Err(match error {
7944                            Ok(value) => common::Error::BadRequest(value),
7945                            _ => common::Error::Failure(response),
7946                        });
7947                    }
7948                    if protocol == common::UploadProtocol::Resumable {
7949                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
7950                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
7951                        if size > 10485760 {
7952                            return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
7953                        }
7954                        let upload_result = {
7955                            let url_str = &parts
7956                                .headers
7957                                .get("Location")
7958                                .expect("LOCATION header is part of protocol")
7959                                .to_str()
7960                                .unwrap();
7961                            if upload_url_from_server {
7962                                dlg.store_upload_url(Some(url_str));
7963                            }
7964
7965                            common::ResumableUploadHelper {
7966                                client: &self.hub.client,
7967                                delegate: dlg,
7968                                start_at: if upload_url_from_server {
7969                                    Some(0)
7970                                } else {
7971                                    None
7972                                },
7973                                auth: &self.hub.auth,
7974                                user_agent: &self.hub._user_agent,
7975                                // TODO: Check this assumption
7976                                auth_header: format!(
7977                                    "Bearer {}",
7978                                    token
7979                                        .ok_or_else(|| common::Error::MissingToken(
7980                                            "resumable upload requires token".into()
7981                                        ))?
7982                                        .as_str()
7983                                ),
7984                                url: url_str,
7985                                reader: &mut reader,
7986                                media_type: reader_mime_type.clone(),
7987                                content_length: size,
7988                            }
7989                            .upload()
7990                            .await
7991                        };
7992                        match upload_result {
7993                            None => {
7994                                dlg.finished(false);
7995                                return Err(common::Error::Cancelled);
7996                            }
7997                            Some(Err(err)) => {
7998                                dlg.finished(false);
7999                                return Err(common::Error::HttpError(err));
8000                            }
8001                            Some(Ok(response)) => {
8002                                (parts, body) = response.into_parts();
8003                                if !parts.status.is_success() {
8004                                    dlg.store_upload_url(None);
8005                                    dlg.finished(false);
8006                                    return Err(common::Error::Failure(
8007                                        common::Response::from_parts(parts, body),
8008                                    ));
8009                                }
8010                            }
8011                        }
8012                    }
8013                    let response = {
8014                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8015                        let encoded = common::to_string(&bytes);
8016                        match serde_json::from_str(&encoded) {
8017                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8018                            Err(error) => {
8019                                dlg.response_json_decode_error(&encoded, &error);
8020                                return Err(common::Error::JsonDecodeError(
8021                                    encoded.to_string(),
8022                                    error,
8023                                ));
8024                            }
8025                        }
8026                    };
8027
8028                    dlg.finished(true);
8029                    return Ok(response);
8030                }
8031            }
8032        }
8033    }
8034
8035    /// Upload media in a resumable fashion.
8036    /// Even if the upload fails or is interrupted, it can be resumed for a
8037    /// certain amount of time as the server maintains state temporarily.
8038    ///
8039    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
8040    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
8041    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
8042    /// `cancel_chunk_upload(...)`.
8043    ///
8044    /// * *multipart*: yes
8045    /// * *max size*: 10MB
8046    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
8047    pub async fn upload_resumable<RS>(
8048        self,
8049        resumeable_stream: RS,
8050        mime_type: mime::Mime,
8051    ) -> common::Result<(common::Response, TimelineItem)>
8052    where
8053        RS: common::ReadSeek,
8054    {
8055        self.doit(
8056            resumeable_stream,
8057            mime_type,
8058            common::UploadProtocol::Resumable,
8059        )
8060        .await
8061    }
8062    /// Upload media all at once.
8063    /// If the upload fails for whichever reason, all progress is lost.
8064    ///
8065    /// * *multipart*: yes
8066    /// * *max size*: 10MB
8067    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
8068    pub async fn upload<RS>(
8069        self,
8070        stream: RS,
8071        mime_type: mime::Mime,
8072    ) -> common::Result<(common::Response, TimelineItem)>
8073    where
8074        RS: common::ReadSeek,
8075    {
8076        self.doit(stream, mime_type, common::UploadProtocol::Simple)
8077            .await
8078    }
8079
8080    ///
8081    /// Sets the *request* property to the given value.
8082    ///
8083    /// Even though the property as already been set when instantiating this call,
8084    /// we provide this method for API completeness.
8085    pub fn request(mut self, new_value: TimelineItem) -> TimelineInsertCall<'a, C> {
8086        self._request = new_value;
8087        self
8088    }
8089    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8090    /// while executing the actual API request.
8091    ///
8092    /// ````text
8093    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8094    /// ````
8095    ///
8096    /// Sets the *delegate* property to the given value.
8097    pub fn delegate(
8098        mut self,
8099        new_value: &'a mut dyn common::Delegate,
8100    ) -> TimelineInsertCall<'a, C> {
8101        self._delegate = Some(new_value);
8102        self
8103    }
8104
8105    /// Set any additional parameter of the query string used in the request.
8106    /// It should be used to set parameters which are not yet available through their own
8107    /// setters.
8108    ///
8109    /// Please note that this method must not be used to set any of the known parameters
8110    /// which have their own setter method. If done anyway, the request will fail.
8111    ///
8112    /// # Additional Parameters
8113    ///
8114    /// * *alt* (query-string) - Data format for the response.
8115    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8116    /// * *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.
8117    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8118    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8119    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8120    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8121    pub fn param<T>(mut self, name: T, value: T) -> TimelineInsertCall<'a, C>
8122    where
8123        T: AsRef<str>,
8124    {
8125        self._additional_params
8126            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8127        self
8128    }
8129
8130    /// Identifies the authorization scope for the method you are building.
8131    ///
8132    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8133    /// [`Scope::GlasLocation`].
8134    ///
8135    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8136    /// tokens for more than one scope.
8137    ///
8138    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8139    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8140    /// sufficient, a read-write scope will do as well.
8141    pub fn add_scope<St>(mut self, scope: St) -> TimelineInsertCall<'a, C>
8142    where
8143        St: AsRef<str>,
8144    {
8145        self._scopes.insert(String::from(scope.as_ref()));
8146        self
8147    }
8148    /// Identifies the authorization scope(s) for the method you are building.
8149    ///
8150    /// See [`Self::add_scope()`] for details.
8151    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineInsertCall<'a, C>
8152    where
8153        I: IntoIterator<Item = St>,
8154        St: AsRef<str>,
8155    {
8156        self._scopes
8157            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8158        self
8159    }
8160
8161    /// Removes all scopes, and no default scope will be used either.
8162    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8163    /// for details).
8164    pub fn clear_scopes(mut self) -> TimelineInsertCall<'a, C> {
8165        self._scopes.clear();
8166        self
8167    }
8168}
8169
8170/// Retrieves a list of timeline items for the authenticated user.
8171///
8172/// A builder for the *list* method supported by a *timeline* resource.
8173/// It is not used directly, but through a [`TimelineMethods`] instance.
8174///
8175/// # Example
8176///
8177/// Instantiate a resource method builder
8178///
8179/// ```test_harness,no_run
8180/// # extern crate hyper;
8181/// # extern crate hyper_rustls;
8182/// # extern crate google_mirror1 as mirror1;
8183/// # async fn dox() {
8184/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8185///
8186/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8187/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8188/// #     .with_native_roots()
8189/// #     .unwrap()
8190/// #     .https_only()
8191/// #     .enable_http2()
8192/// #     .build();
8193///
8194/// # let executor = hyper_util::rt::TokioExecutor::new();
8195/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8196/// #     secret,
8197/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8198/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8199/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8200/// #     ),
8201/// # ).build().await.unwrap();
8202///
8203/// # let client = hyper_util::client::legacy::Client::builder(
8204/// #     hyper_util::rt::TokioExecutor::new()
8205/// # )
8206/// # .build(
8207/// #     hyper_rustls::HttpsConnectorBuilder::new()
8208/// #         .with_native_roots()
8209/// #         .unwrap()
8210/// #         .https_or_http()
8211/// #         .enable_http2()
8212/// #         .build()
8213/// # );
8214/// # let mut hub = Mirror::new(client, auth);
8215/// // You can configure optional parameters by calling the respective setters at will, and
8216/// // execute the final call using `doit()`.
8217/// // Values shown here are possibly random and not representative !
8218/// let result = hub.timeline().list()
8219///              .source_item_id("duo")
8220///              .pinned_only(true)
8221///              .page_token("sed")
8222///              .order_by("ut")
8223///              .max_results(89)
8224///              .include_deleted(true)
8225///              .bundle_id("ipsum")
8226///              .doit().await;
8227/// # }
8228/// ```
8229pub struct TimelineListCall<'a, C>
8230where
8231    C: 'a,
8232{
8233    hub: &'a Mirror<C>,
8234    _source_item_id: Option<String>,
8235    _pinned_only: Option<bool>,
8236    _page_token: Option<String>,
8237    _order_by: Option<String>,
8238    _max_results: Option<u32>,
8239    _include_deleted: Option<bool>,
8240    _bundle_id: Option<String>,
8241    _delegate: Option<&'a mut dyn common::Delegate>,
8242    _additional_params: HashMap<String, String>,
8243    _scopes: BTreeSet<String>,
8244}
8245
8246impl<'a, C> common::CallBuilder for TimelineListCall<'a, C> {}
8247
8248impl<'a, C> TimelineListCall<'a, C>
8249where
8250    C: common::Connector,
8251{
8252    /// Perform the operation you have build so far.
8253    pub async fn doit(mut self) -> common::Result<(common::Response, TimelineListResponse)> {
8254        use std::borrow::Cow;
8255        use std::io::{Read, Seek};
8256
8257        use common::{url::Params, ToParts};
8258        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8259
8260        let mut dd = common::DefaultDelegate;
8261        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8262        dlg.begin(common::MethodInfo {
8263            id: "mirror.timeline.list",
8264            http_method: hyper::Method::GET,
8265        });
8266
8267        for &field in [
8268            "alt",
8269            "sourceItemId",
8270            "pinnedOnly",
8271            "pageToken",
8272            "orderBy",
8273            "maxResults",
8274            "includeDeleted",
8275            "bundleId",
8276        ]
8277        .iter()
8278        {
8279            if self._additional_params.contains_key(field) {
8280                dlg.finished(false);
8281                return Err(common::Error::FieldClash(field));
8282            }
8283        }
8284
8285        let mut params = Params::with_capacity(9 + self._additional_params.len());
8286        if let Some(value) = self._source_item_id.as_ref() {
8287            params.push("sourceItemId", value);
8288        }
8289        if let Some(value) = self._pinned_only.as_ref() {
8290            params.push("pinnedOnly", value.to_string());
8291        }
8292        if let Some(value) = self._page_token.as_ref() {
8293            params.push("pageToken", value);
8294        }
8295        if let Some(value) = self._order_by.as_ref() {
8296            params.push("orderBy", value);
8297        }
8298        if let Some(value) = self._max_results.as_ref() {
8299            params.push("maxResults", value.to_string());
8300        }
8301        if let Some(value) = self._include_deleted.as_ref() {
8302            params.push("includeDeleted", value.to_string());
8303        }
8304        if let Some(value) = self._bundle_id.as_ref() {
8305            params.push("bundleId", value);
8306        }
8307
8308        params.extend(self._additional_params.iter());
8309
8310        params.push("alt", "json");
8311        let mut url = self.hub._base_url.clone() + "timeline";
8312        if self._scopes.is_empty() {
8313            self._scopes
8314                .insert(Scope::GlasLocation.as_ref().to_string());
8315        }
8316
8317        let url = params.parse_with_url(&url);
8318
8319        loop {
8320            let token = match self
8321                .hub
8322                .auth
8323                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8324                .await
8325            {
8326                Ok(token) => token,
8327                Err(e) => match dlg.token(e) {
8328                    Ok(token) => token,
8329                    Err(e) => {
8330                        dlg.finished(false);
8331                        return Err(common::Error::MissingToken(e));
8332                    }
8333                },
8334            };
8335            let mut req_result = {
8336                let client = &self.hub.client;
8337                dlg.pre_request();
8338                let mut req_builder = hyper::Request::builder()
8339                    .method(hyper::Method::GET)
8340                    .uri(url.as_str())
8341                    .header(USER_AGENT, self.hub._user_agent.clone());
8342
8343                if let Some(token) = token.as_ref() {
8344                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8345                }
8346
8347                let request = req_builder
8348                    .header(CONTENT_LENGTH, 0_u64)
8349                    .body(common::to_body::<String>(None));
8350
8351                client.request(request.unwrap()).await
8352            };
8353
8354            match req_result {
8355                Err(err) => {
8356                    if let common::Retry::After(d) = dlg.http_error(&err) {
8357                        sleep(d).await;
8358                        continue;
8359                    }
8360                    dlg.finished(false);
8361                    return Err(common::Error::HttpError(err));
8362                }
8363                Ok(res) => {
8364                    let (mut parts, body) = res.into_parts();
8365                    let mut body = common::Body::new(body);
8366                    if !parts.status.is_success() {
8367                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8368                        let error = serde_json::from_str(&common::to_string(&bytes));
8369                        let response = common::to_response(parts, bytes.into());
8370
8371                        if let common::Retry::After(d) =
8372                            dlg.http_failure(&response, error.as_ref().ok())
8373                        {
8374                            sleep(d).await;
8375                            continue;
8376                        }
8377
8378                        dlg.finished(false);
8379
8380                        return Err(match error {
8381                            Ok(value) => common::Error::BadRequest(value),
8382                            _ => common::Error::Failure(response),
8383                        });
8384                    }
8385                    let response = {
8386                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8387                        let encoded = common::to_string(&bytes);
8388                        match serde_json::from_str(&encoded) {
8389                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8390                            Err(error) => {
8391                                dlg.response_json_decode_error(&encoded, &error);
8392                                return Err(common::Error::JsonDecodeError(
8393                                    encoded.to_string(),
8394                                    error,
8395                                ));
8396                            }
8397                        }
8398                    };
8399
8400                    dlg.finished(true);
8401                    return Ok(response);
8402                }
8403            }
8404        }
8405    }
8406
8407    /// If provided, only items with the given sourceItemId will be returned.
8408    ///
8409    /// Sets the *source item id* query property to the given value.
8410    pub fn source_item_id(mut self, new_value: &str) -> TimelineListCall<'a, C> {
8411        self._source_item_id = Some(new_value.to_string());
8412        self
8413    }
8414    /// If true, only pinned items will be returned.
8415    ///
8416    /// Sets the *pinned only* query property to the given value.
8417    pub fn pinned_only(mut self, new_value: bool) -> TimelineListCall<'a, C> {
8418        self._pinned_only = Some(new_value);
8419        self
8420    }
8421    /// Token for the page of results to return.
8422    ///
8423    /// Sets the *page token* query property to the given value.
8424    pub fn page_token(mut self, new_value: &str) -> TimelineListCall<'a, C> {
8425        self._page_token = Some(new_value.to_string());
8426        self
8427    }
8428    /// Controls the order in which timeline items are returned.
8429    ///
8430    /// Sets the *order by* query property to the given value.
8431    pub fn order_by(mut self, new_value: &str) -> TimelineListCall<'a, C> {
8432        self._order_by = Some(new_value.to_string());
8433        self
8434    }
8435    /// The maximum number of items to include in the response, used for paging.
8436    ///
8437    /// Sets the *max results* query property to the given value.
8438    pub fn max_results(mut self, new_value: u32) -> TimelineListCall<'a, C> {
8439        self._max_results = Some(new_value);
8440        self
8441    }
8442    /// If true, tombstone records for deleted items will be returned.
8443    ///
8444    /// Sets the *include deleted* query property to the given value.
8445    pub fn include_deleted(mut self, new_value: bool) -> TimelineListCall<'a, C> {
8446        self._include_deleted = Some(new_value);
8447        self
8448    }
8449    /// If provided, only items with the given bundleId will be returned.
8450    ///
8451    /// Sets the *bundle id* query property to the given value.
8452    pub fn bundle_id(mut self, new_value: &str) -> TimelineListCall<'a, C> {
8453        self._bundle_id = Some(new_value.to_string());
8454        self
8455    }
8456    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8457    /// while executing the actual API request.
8458    ///
8459    /// ````text
8460    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8461    /// ````
8462    ///
8463    /// Sets the *delegate* property to the given value.
8464    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TimelineListCall<'a, C> {
8465        self._delegate = Some(new_value);
8466        self
8467    }
8468
8469    /// Set any additional parameter of the query string used in the request.
8470    /// It should be used to set parameters which are not yet available through their own
8471    /// setters.
8472    ///
8473    /// Please note that this method must not be used to set any of the known parameters
8474    /// which have their own setter method. If done anyway, the request will fail.
8475    ///
8476    /// # Additional Parameters
8477    ///
8478    /// * *alt* (query-string) - Data format for the response.
8479    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8480    /// * *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.
8481    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8482    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8483    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8484    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8485    pub fn param<T>(mut self, name: T, value: T) -> TimelineListCall<'a, C>
8486    where
8487        T: AsRef<str>,
8488    {
8489        self._additional_params
8490            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8491        self
8492    }
8493
8494    /// Identifies the authorization scope for the method you are building.
8495    ///
8496    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8497    /// [`Scope::GlasLocation`].
8498    ///
8499    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8500    /// tokens for more than one scope.
8501    ///
8502    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8503    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8504    /// sufficient, a read-write scope will do as well.
8505    pub fn add_scope<St>(mut self, scope: St) -> TimelineListCall<'a, C>
8506    where
8507        St: AsRef<str>,
8508    {
8509        self._scopes.insert(String::from(scope.as_ref()));
8510        self
8511    }
8512    /// Identifies the authorization scope(s) for the method you are building.
8513    ///
8514    /// See [`Self::add_scope()`] for details.
8515    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineListCall<'a, C>
8516    where
8517        I: IntoIterator<Item = St>,
8518        St: AsRef<str>,
8519    {
8520        self._scopes
8521            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8522        self
8523    }
8524
8525    /// Removes all scopes, and no default scope will be used either.
8526    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8527    /// for details).
8528    pub fn clear_scopes(mut self) -> TimelineListCall<'a, C> {
8529        self._scopes.clear();
8530        self
8531    }
8532}
8533
8534/// Updates a timeline item in place. This method supports patch semantics.
8535///
8536/// A builder for the *patch* method supported by a *timeline* resource.
8537/// It is not used directly, but through a [`TimelineMethods`] instance.
8538///
8539/// # Example
8540///
8541/// Instantiate a resource method builder
8542///
8543/// ```test_harness,no_run
8544/// # extern crate hyper;
8545/// # extern crate hyper_rustls;
8546/// # extern crate google_mirror1 as mirror1;
8547/// use mirror1::api::TimelineItem;
8548/// # async fn dox() {
8549/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8550///
8551/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8552/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8553/// #     .with_native_roots()
8554/// #     .unwrap()
8555/// #     .https_only()
8556/// #     .enable_http2()
8557/// #     .build();
8558///
8559/// # let executor = hyper_util::rt::TokioExecutor::new();
8560/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8561/// #     secret,
8562/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8563/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8564/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8565/// #     ),
8566/// # ).build().await.unwrap();
8567///
8568/// # let client = hyper_util::client::legacy::Client::builder(
8569/// #     hyper_util::rt::TokioExecutor::new()
8570/// # )
8571/// # .build(
8572/// #     hyper_rustls::HttpsConnectorBuilder::new()
8573/// #         .with_native_roots()
8574/// #         .unwrap()
8575/// #         .https_or_http()
8576/// #         .enable_http2()
8577/// #         .build()
8578/// # );
8579/// # let mut hub = Mirror::new(client, auth);
8580/// // As the method needs a request, you would usually fill it with the desired information
8581/// // into the respective structure. Some of the parts shown here might not be applicable !
8582/// // Values shown here are possibly random and not representative !
8583/// let mut req = TimelineItem::default();
8584///
8585/// // You can configure optional parameters by calling the respective setters at will, and
8586/// // execute the final call using `doit()`.
8587/// // Values shown here are possibly random and not representative !
8588/// let result = hub.timeline().patch(req, "id")
8589///              .doit().await;
8590/// # }
8591/// ```
8592pub struct TimelinePatchCall<'a, C>
8593where
8594    C: 'a,
8595{
8596    hub: &'a Mirror<C>,
8597    _request: TimelineItem,
8598    _id: String,
8599    _delegate: Option<&'a mut dyn common::Delegate>,
8600    _additional_params: HashMap<String, String>,
8601    _scopes: BTreeSet<String>,
8602}
8603
8604impl<'a, C> common::CallBuilder for TimelinePatchCall<'a, C> {}
8605
8606impl<'a, C> TimelinePatchCall<'a, C>
8607where
8608    C: common::Connector,
8609{
8610    /// Perform the operation you have build so far.
8611    pub async fn doit(mut self) -> common::Result<(common::Response, TimelineItem)> {
8612        use std::borrow::Cow;
8613        use std::io::{Read, Seek};
8614
8615        use common::{url::Params, ToParts};
8616        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8617
8618        let mut dd = common::DefaultDelegate;
8619        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8620        dlg.begin(common::MethodInfo {
8621            id: "mirror.timeline.patch",
8622            http_method: hyper::Method::PATCH,
8623        });
8624
8625        for &field in ["alt", "id"].iter() {
8626            if self._additional_params.contains_key(field) {
8627                dlg.finished(false);
8628                return Err(common::Error::FieldClash(field));
8629            }
8630        }
8631
8632        let mut params = Params::with_capacity(4 + self._additional_params.len());
8633        params.push("id", self._id);
8634
8635        params.extend(self._additional_params.iter());
8636
8637        params.push("alt", "json");
8638        let mut url = self.hub._base_url.clone() + "timeline/{id}";
8639        if self._scopes.is_empty() {
8640            self._scopes
8641                .insert(Scope::GlasLocation.as_ref().to_string());
8642        }
8643
8644        #[allow(clippy::single_element_loop)]
8645        for &(find_this, param_name) in [("{id}", "id")].iter() {
8646            url = params.uri_replacement(url, param_name, find_this, false);
8647        }
8648        {
8649            let to_remove = ["id"];
8650            params.remove_params(&to_remove);
8651        }
8652
8653        let url = params.parse_with_url(&url);
8654
8655        let mut json_mime_type = mime::APPLICATION_JSON;
8656        let mut request_value_reader = {
8657            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8658            common::remove_json_null_values(&mut value);
8659            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8660            serde_json::to_writer(&mut dst, &value).unwrap();
8661            dst
8662        };
8663        let request_size = request_value_reader
8664            .seek(std::io::SeekFrom::End(0))
8665            .unwrap();
8666        request_value_reader
8667            .seek(std::io::SeekFrom::Start(0))
8668            .unwrap();
8669
8670        loop {
8671            let token = match self
8672                .hub
8673                .auth
8674                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8675                .await
8676            {
8677                Ok(token) => token,
8678                Err(e) => match dlg.token(e) {
8679                    Ok(token) => token,
8680                    Err(e) => {
8681                        dlg.finished(false);
8682                        return Err(common::Error::MissingToken(e));
8683                    }
8684                },
8685            };
8686            request_value_reader
8687                .seek(std::io::SeekFrom::Start(0))
8688                .unwrap();
8689            let mut req_result = {
8690                let client = &self.hub.client;
8691                dlg.pre_request();
8692                let mut req_builder = hyper::Request::builder()
8693                    .method(hyper::Method::PATCH)
8694                    .uri(url.as_str())
8695                    .header(USER_AGENT, self.hub._user_agent.clone());
8696
8697                if let Some(token) = token.as_ref() {
8698                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8699                }
8700
8701                let request = req_builder
8702                    .header(CONTENT_TYPE, json_mime_type.to_string())
8703                    .header(CONTENT_LENGTH, request_size as u64)
8704                    .body(common::to_body(
8705                        request_value_reader.get_ref().clone().into(),
8706                    ));
8707
8708                client.request(request.unwrap()).await
8709            };
8710
8711            match req_result {
8712                Err(err) => {
8713                    if let common::Retry::After(d) = dlg.http_error(&err) {
8714                        sleep(d).await;
8715                        continue;
8716                    }
8717                    dlg.finished(false);
8718                    return Err(common::Error::HttpError(err));
8719                }
8720                Ok(res) => {
8721                    let (mut parts, body) = res.into_parts();
8722                    let mut body = common::Body::new(body);
8723                    if !parts.status.is_success() {
8724                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8725                        let error = serde_json::from_str(&common::to_string(&bytes));
8726                        let response = common::to_response(parts, bytes.into());
8727
8728                        if let common::Retry::After(d) =
8729                            dlg.http_failure(&response, error.as_ref().ok())
8730                        {
8731                            sleep(d).await;
8732                            continue;
8733                        }
8734
8735                        dlg.finished(false);
8736
8737                        return Err(match error {
8738                            Ok(value) => common::Error::BadRequest(value),
8739                            _ => common::Error::Failure(response),
8740                        });
8741                    }
8742                    let response = {
8743                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8744                        let encoded = common::to_string(&bytes);
8745                        match serde_json::from_str(&encoded) {
8746                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8747                            Err(error) => {
8748                                dlg.response_json_decode_error(&encoded, &error);
8749                                return Err(common::Error::JsonDecodeError(
8750                                    encoded.to_string(),
8751                                    error,
8752                                ));
8753                            }
8754                        }
8755                    };
8756
8757                    dlg.finished(true);
8758                    return Ok(response);
8759                }
8760            }
8761        }
8762    }
8763
8764    ///
8765    /// Sets the *request* property to the given value.
8766    ///
8767    /// Even though the property as already been set when instantiating this call,
8768    /// we provide this method for API completeness.
8769    pub fn request(mut self, new_value: TimelineItem) -> TimelinePatchCall<'a, C> {
8770        self._request = new_value;
8771        self
8772    }
8773    /// The ID of the timeline item.
8774    ///
8775    /// Sets the *id* path property to the given value.
8776    ///
8777    /// Even though the property as already been set when instantiating this call,
8778    /// we provide this method for API completeness.
8779    pub fn id(mut self, new_value: &str) -> TimelinePatchCall<'a, C> {
8780        self._id = new_value.to_string();
8781        self
8782    }
8783    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8784    /// while executing the actual API request.
8785    ///
8786    /// ````text
8787    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8788    /// ````
8789    ///
8790    /// Sets the *delegate* property to the given value.
8791    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> TimelinePatchCall<'a, C> {
8792        self._delegate = Some(new_value);
8793        self
8794    }
8795
8796    /// Set any additional parameter of the query string used in the request.
8797    /// It should be used to set parameters which are not yet available through their own
8798    /// setters.
8799    ///
8800    /// Please note that this method must not be used to set any of the known parameters
8801    /// which have their own setter method. If done anyway, the request will fail.
8802    ///
8803    /// # Additional Parameters
8804    ///
8805    /// * *alt* (query-string) - Data format for the response.
8806    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8807    /// * *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.
8808    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8809    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8810    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8811    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8812    pub fn param<T>(mut self, name: T, value: T) -> TimelinePatchCall<'a, C>
8813    where
8814        T: AsRef<str>,
8815    {
8816        self._additional_params
8817            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8818        self
8819    }
8820
8821    /// Identifies the authorization scope for the method you are building.
8822    ///
8823    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8824    /// [`Scope::GlasLocation`].
8825    ///
8826    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8827    /// tokens for more than one scope.
8828    ///
8829    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8830    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8831    /// sufficient, a read-write scope will do as well.
8832    pub fn add_scope<St>(mut self, scope: St) -> TimelinePatchCall<'a, C>
8833    where
8834        St: AsRef<str>,
8835    {
8836        self._scopes.insert(String::from(scope.as_ref()));
8837        self
8838    }
8839    /// Identifies the authorization scope(s) for the method you are building.
8840    ///
8841    /// See [`Self::add_scope()`] for details.
8842    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelinePatchCall<'a, C>
8843    where
8844        I: IntoIterator<Item = St>,
8845        St: AsRef<str>,
8846    {
8847        self._scopes
8848            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8849        self
8850    }
8851
8852    /// Removes all scopes, and no default scope will be used either.
8853    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8854    /// for details).
8855    pub fn clear_scopes(mut self) -> TimelinePatchCall<'a, C> {
8856        self._scopes.clear();
8857        self
8858    }
8859}
8860
8861/// Updates a timeline item in place.
8862///
8863/// A builder for the *update* method supported by a *timeline* resource.
8864/// It is not used directly, but through a [`TimelineMethods`] instance.
8865///
8866/// # Example
8867///
8868/// Instantiate a resource method builder
8869///
8870/// ```test_harness,no_run
8871/// # extern crate hyper;
8872/// # extern crate hyper_rustls;
8873/// # extern crate google_mirror1 as mirror1;
8874/// use mirror1::api::TimelineItem;
8875/// use std::fs;
8876/// # async fn dox() {
8877/// # use mirror1::{Mirror, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8878///
8879/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8880/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8881/// #     .with_native_roots()
8882/// #     .unwrap()
8883/// #     .https_only()
8884/// #     .enable_http2()
8885/// #     .build();
8886///
8887/// # let executor = hyper_util::rt::TokioExecutor::new();
8888/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8889/// #     secret,
8890/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8891/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8892/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8893/// #     ),
8894/// # ).build().await.unwrap();
8895///
8896/// # let client = hyper_util::client::legacy::Client::builder(
8897/// #     hyper_util::rt::TokioExecutor::new()
8898/// # )
8899/// # .build(
8900/// #     hyper_rustls::HttpsConnectorBuilder::new()
8901/// #         .with_native_roots()
8902/// #         .unwrap()
8903/// #         .https_or_http()
8904/// #         .enable_http2()
8905/// #         .build()
8906/// # );
8907/// # let mut hub = Mirror::new(client, auth);
8908/// // As the method needs a request, you would usually fill it with the desired information
8909/// // into the respective structure. Some of the parts shown here might not be applicable !
8910/// // Values shown here are possibly random and not representative !
8911/// let mut req = TimelineItem::default();
8912///
8913/// // You can configure optional parameters by calling the respective setters at will, and
8914/// // execute the final call using `upload_resumable(...)`.
8915/// // Values shown here are possibly random and not representative !
8916/// let result = hub.timeline().update(req, "id")
8917///              .upload_resumable(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
8918/// # }
8919/// ```
8920pub struct TimelineUpdateCall<'a, C>
8921where
8922    C: 'a,
8923{
8924    hub: &'a Mirror<C>,
8925    _request: TimelineItem,
8926    _id: String,
8927    _delegate: Option<&'a mut dyn common::Delegate>,
8928    _additional_params: HashMap<String, String>,
8929    _scopes: BTreeSet<String>,
8930}
8931
8932impl<'a, C> common::CallBuilder for TimelineUpdateCall<'a, C> {}
8933
8934impl<'a, C> TimelineUpdateCall<'a, C>
8935where
8936    C: common::Connector,
8937{
8938    /// Perform the operation you have build so far.
8939    async fn doit<RS>(
8940        mut self,
8941        mut reader: RS,
8942        reader_mime_type: mime::Mime,
8943        protocol: common::UploadProtocol,
8944    ) -> common::Result<(common::Response, TimelineItem)>
8945    where
8946        RS: common::ReadSeek,
8947    {
8948        use std::borrow::Cow;
8949        use std::io::{Read, Seek};
8950
8951        use common::{url::Params, ToParts};
8952        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8953
8954        let mut dd = common::DefaultDelegate;
8955        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8956        dlg.begin(common::MethodInfo {
8957            id: "mirror.timeline.update",
8958            http_method: hyper::Method::PUT,
8959        });
8960
8961        for &field in ["alt", "id"].iter() {
8962            if self._additional_params.contains_key(field) {
8963                dlg.finished(false);
8964                return Err(common::Error::FieldClash(field));
8965            }
8966        }
8967
8968        let mut params = Params::with_capacity(4 + self._additional_params.len());
8969        params.push("id", self._id);
8970
8971        params.extend(self._additional_params.iter());
8972
8973        params.push("alt", "json");
8974        let (mut url, upload_type) = if protocol == common::UploadProtocol::Resumable {
8975            (
8976                self.hub._root_url.clone() + "resumable/upload/mirror/v1/timeline/{id}",
8977                "resumable",
8978            )
8979        } else if protocol == common::UploadProtocol::Simple {
8980            (
8981                self.hub._root_url.clone() + "upload/mirror/v1/timeline/{id}",
8982                "multipart",
8983            )
8984        } else {
8985            unreachable!()
8986        };
8987        params.push("uploadType", upload_type);
8988        if self._scopes.is_empty() {
8989            self._scopes
8990                .insert(Scope::GlasLocation.as_ref().to_string());
8991        }
8992
8993        #[allow(clippy::single_element_loop)]
8994        for &(find_this, param_name) in [("{id}", "id")].iter() {
8995            url = params.uri_replacement(url, param_name, find_this, false);
8996        }
8997        {
8998            let to_remove = ["id"];
8999            params.remove_params(&to_remove);
9000        }
9001
9002        let url = params.parse_with_url(&url);
9003
9004        let mut json_mime_type = mime::APPLICATION_JSON;
9005        let mut request_value_reader = {
9006            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9007            common::remove_json_null_values(&mut value);
9008            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9009            serde_json::to_writer(&mut dst, &value).unwrap();
9010            dst
9011        };
9012        let request_size = request_value_reader
9013            .seek(std::io::SeekFrom::End(0))
9014            .unwrap();
9015        request_value_reader
9016            .seek(std::io::SeekFrom::Start(0))
9017            .unwrap();
9018
9019        let mut upload_url_from_server;
9020
9021        loop {
9022            let token = match self
9023                .hub
9024                .auth
9025                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9026                .await
9027            {
9028                Ok(token) => token,
9029                Err(e) => match dlg.token(e) {
9030                    Ok(token) => token,
9031                    Err(e) => {
9032                        dlg.finished(false);
9033                        return Err(common::Error::MissingToken(e));
9034                    }
9035                },
9036            };
9037            request_value_reader
9038                .seek(std::io::SeekFrom::Start(0))
9039                .unwrap();
9040            let mut req_result = {
9041                let mut mp_reader: common::MultiPartReader = Default::default();
9042                let (mut body_reader, content_type) = match protocol {
9043                    common::UploadProtocol::Simple => {
9044                        mp_reader.reserve_exact(2);
9045                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
9046                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
9047                        if size > 10485760 {
9048                            return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
9049                        }
9050                        mp_reader
9051                            .add_part(
9052                                &mut request_value_reader,
9053                                request_size,
9054                                json_mime_type.clone(),
9055                            )
9056                            .add_part(&mut reader, size, reader_mime_type.clone());
9057                        (
9058                            &mut mp_reader as &mut (dyn std::io::Read + Send),
9059                            common::MultiPartReader::mime_type(),
9060                        )
9061                    }
9062                    _ => (
9063                        &mut request_value_reader as &mut (dyn std::io::Read + Send),
9064                        json_mime_type.clone(),
9065                    ),
9066                };
9067                let client = &self.hub.client;
9068                dlg.pre_request();
9069                let mut req_builder = hyper::Request::builder()
9070                    .method(hyper::Method::PUT)
9071                    .uri(url.as_str())
9072                    .header(USER_AGENT, self.hub._user_agent.clone());
9073
9074                if let Some(token) = token.as_ref() {
9075                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9076                }
9077
9078                upload_url_from_server = true;
9079                if protocol == common::UploadProtocol::Resumable {
9080                    req_builder = req_builder
9081                        .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
9082                }
9083
9084                let mut body_reader_bytes = vec![];
9085                body_reader.read_to_end(&mut body_reader_bytes).unwrap();
9086                let request = req_builder
9087                    .header(CONTENT_TYPE, content_type.to_string())
9088                    .body(common::to_body(body_reader_bytes.into()));
9089
9090                client.request(request.unwrap()).await
9091            };
9092
9093            match req_result {
9094                Err(err) => {
9095                    if let common::Retry::After(d) = dlg.http_error(&err) {
9096                        sleep(d).await;
9097                        continue;
9098                    }
9099                    dlg.finished(false);
9100                    return Err(common::Error::HttpError(err));
9101                }
9102                Ok(res) => {
9103                    let (mut parts, body) = res.into_parts();
9104                    let mut body = common::Body::new(body);
9105                    if !parts.status.is_success() {
9106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9107                        let error = serde_json::from_str(&common::to_string(&bytes));
9108                        let response = common::to_response(parts, bytes.into());
9109
9110                        if let common::Retry::After(d) =
9111                            dlg.http_failure(&response, error.as_ref().ok())
9112                        {
9113                            sleep(d).await;
9114                            continue;
9115                        }
9116
9117                        dlg.finished(false);
9118
9119                        return Err(match error {
9120                            Ok(value) => common::Error::BadRequest(value),
9121                            _ => common::Error::Failure(response),
9122                        });
9123                    }
9124                    if protocol == common::UploadProtocol::Resumable {
9125                        let size = reader.seek(std::io::SeekFrom::End(0)).unwrap();
9126                        reader.seek(std::io::SeekFrom::Start(0)).unwrap();
9127                        if size > 10485760 {
9128                            return Err(common::Error::UploadSizeLimitExceeded(size, 10485760));
9129                        }
9130                        let upload_result = {
9131                            let url_str = &parts
9132                                .headers
9133                                .get("Location")
9134                                .expect("LOCATION header is part of protocol")
9135                                .to_str()
9136                                .unwrap();
9137                            if upload_url_from_server {
9138                                dlg.store_upload_url(Some(url_str));
9139                            }
9140
9141                            common::ResumableUploadHelper {
9142                                client: &self.hub.client,
9143                                delegate: dlg,
9144                                start_at: if upload_url_from_server {
9145                                    Some(0)
9146                                } else {
9147                                    None
9148                                },
9149                                auth: &self.hub.auth,
9150                                user_agent: &self.hub._user_agent,
9151                                // TODO: Check this assumption
9152                                auth_header: format!(
9153                                    "Bearer {}",
9154                                    token
9155                                        .ok_or_else(|| common::Error::MissingToken(
9156                                            "resumable upload requires token".into()
9157                                        ))?
9158                                        .as_str()
9159                                ),
9160                                url: url_str,
9161                                reader: &mut reader,
9162                                media_type: reader_mime_type.clone(),
9163                                content_length: size,
9164                            }
9165                            .upload()
9166                            .await
9167                        };
9168                        match upload_result {
9169                            None => {
9170                                dlg.finished(false);
9171                                return Err(common::Error::Cancelled);
9172                            }
9173                            Some(Err(err)) => {
9174                                dlg.finished(false);
9175                                return Err(common::Error::HttpError(err));
9176                            }
9177                            Some(Ok(response)) => {
9178                                (parts, body) = response.into_parts();
9179                                if !parts.status.is_success() {
9180                                    dlg.store_upload_url(None);
9181                                    dlg.finished(false);
9182                                    return Err(common::Error::Failure(
9183                                        common::Response::from_parts(parts, body),
9184                                    ));
9185                                }
9186                            }
9187                        }
9188                    }
9189                    let response = {
9190                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9191                        let encoded = common::to_string(&bytes);
9192                        match serde_json::from_str(&encoded) {
9193                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9194                            Err(error) => {
9195                                dlg.response_json_decode_error(&encoded, &error);
9196                                return Err(common::Error::JsonDecodeError(
9197                                    encoded.to_string(),
9198                                    error,
9199                                ));
9200                            }
9201                        }
9202                    };
9203
9204                    dlg.finished(true);
9205                    return Ok(response);
9206                }
9207            }
9208        }
9209    }
9210
9211    /// Upload media in a resumable fashion.
9212    /// Even if the upload fails or is interrupted, it can be resumed for a
9213    /// certain amount of time as the server maintains state temporarily.
9214    ///
9215    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
9216    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
9217    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
9218    /// `cancel_chunk_upload(...)`.
9219    ///
9220    /// * *multipart*: yes
9221    /// * *max size*: 10MB
9222    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
9223    pub async fn upload_resumable<RS>(
9224        self,
9225        resumeable_stream: RS,
9226        mime_type: mime::Mime,
9227    ) -> common::Result<(common::Response, TimelineItem)>
9228    where
9229        RS: common::ReadSeek,
9230    {
9231        self.doit(
9232            resumeable_stream,
9233            mime_type,
9234            common::UploadProtocol::Resumable,
9235        )
9236        .await
9237    }
9238    /// Upload media all at once.
9239    /// If the upload fails for whichever reason, all progress is lost.
9240    ///
9241    /// * *multipart*: yes
9242    /// * *max size*: 10MB
9243    /// * *valid mime types*: 'audio/*', 'image/*' and 'video/*'
9244    pub async fn upload<RS>(
9245        self,
9246        stream: RS,
9247        mime_type: mime::Mime,
9248    ) -> common::Result<(common::Response, TimelineItem)>
9249    where
9250        RS: common::ReadSeek,
9251    {
9252        self.doit(stream, mime_type, common::UploadProtocol::Simple)
9253            .await
9254    }
9255
9256    ///
9257    /// Sets the *request* property to the given value.
9258    ///
9259    /// Even though the property as already been set when instantiating this call,
9260    /// we provide this method for API completeness.
9261    pub fn request(mut self, new_value: TimelineItem) -> TimelineUpdateCall<'a, C> {
9262        self._request = new_value;
9263        self
9264    }
9265    /// The ID of the timeline item.
9266    ///
9267    /// Sets the *id* path property to the given value.
9268    ///
9269    /// Even though the property as already been set when instantiating this call,
9270    /// we provide this method for API completeness.
9271    pub fn id(mut self, new_value: &str) -> TimelineUpdateCall<'a, C> {
9272        self._id = new_value.to_string();
9273        self
9274    }
9275    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9276    /// while executing the actual API request.
9277    ///
9278    /// ````text
9279    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9280    /// ````
9281    ///
9282    /// Sets the *delegate* property to the given value.
9283    pub fn delegate(
9284        mut self,
9285        new_value: &'a mut dyn common::Delegate,
9286    ) -> TimelineUpdateCall<'a, C> {
9287        self._delegate = Some(new_value);
9288        self
9289    }
9290
9291    /// Set any additional parameter of the query string used in the request.
9292    /// It should be used to set parameters which are not yet available through their own
9293    /// setters.
9294    ///
9295    /// Please note that this method must not be used to set any of the known parameters
9296    /// which have their own setter method. If done anyway, the request will fail.
9297    ///
9298    /// # Additional Parameters
9299    ///
9300    /// * *alt* (query-string) - Data format for the response.
9301    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9302    /// * *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.
9303    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9304    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9305    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9306    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9307    pub fn param<T>(mut self, name: T, value: T) -> TimelineUpdateCall<'a, C>
9308    where
9309        T: AsRef<str>,
9310    {
9311        self._additional_params
9312            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9313        self
9314    }
9315
9316    /// Identifies the authorization scope for the method you are building.
9317    ///
9318    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9319    /// [`Scope::GlasLocation`].
9320    ///
9321    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9322    /// tokens for more than one scope.
9323    ///
9324    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9325    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9326    /// sufficient, a read-write scope will do as well.
9327    pub fn add_scope<St>(mut self, scope: St) -> TimelineUpdateCall<'a, C>
9328    where
9329        St: AsRef<str>,
9330    {
9331        self._scopes.insert(String::from(scope.as_ref()));
9332        self
9333    }
9334    /// Identifies the authorization scope(s) for the method you are building.
9335    ///
9336    /// See [`Self::add_scope()`] for details.
9337    pub fn add_scopes<I, St>(mut self, scopes: I) -> TimelineUpdateCall<'a, C>
9338    where
9339        I: IntoIterator<Item = St>,
9340        St: AsRef<str>,
9341    {
9342        self._scopes
9343            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9344        self
9345    }
9346
9347    /// Removes all scopes, and no default scope will be used either.
9348    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9349    /// for details).
9350    pub fn clear_scopes(mut self) -> TimelineUpdateCall<'a, C> {
9351        self._scopes.clear();
9352        self
9353    }
9354}