anni_google_drive3/
api.rs

1use serde_json as json;
2use std::cell::RefCell;
3use std::collections::BTreeMap;
4use std::collections::HashMap;
5use std::default::Default;
6use std::error::Error as StdError;
7use std::fs;
8use std::io;
9use std::mem;
10use std::thread::sleep;
11
12use crate::client;
13use http::Uri;
14use hyper::client::connect;
15use tokio::io::{AsyncRead, AsyncWrite};
16use tower_service;
17
18// ##############
19// UTILITIES ###
20// ############
21
22/// Identifies the an OAuth2 authorization scope.
23/// A scope is needed when requesting an
24/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
25#[derive(PartialEq, Eq, Hash)]
26pub enum Scope {
27    /// See, edit, create, and delete all of your Google Drive files
28    Full,
29
30    /// See, create, and delete its own configuration data in your Google Drive
31    Appdata,
32
33    /// See, edit, create, and delete only the specific Google Drive files you use with this app
34    File,
35
36    /// View and manage metadata of files in your Google Drive
37    Metadata,
38
39    /// See information about your Google Drive files
40    MetadataReadonly,
41
42    /// View the photos, videos and albums in your Google Photos
43    PhotoReadonly,
44
45    /// See and download all your Google Drive files
46    Readonly,
47
48    /// Modify your Google Apps Script scripts' behavior
49    Script,
50}
51
52impl AsRef<str> for Scope {
53    fn as_ref(&self) -> &str {
54        match *self {
55            Scope::Full => "https://www.googleapis.com/auth/drive",
56            Scope::Appdata => "https://www.googleapis.com/auth/drive.appdata",
57            Scope::File => "https://www.googleapis.com/auth/drive.file",
58            Scope::Metadata => "https://www.googleapis.com/auth/drive.metadata",
59            Scope::MetadataReadonly => "https://www.googleapis.com/auth/drive.metadata.readonly",
60            Scope::PhotoReadonly => "https://www.googleapis.com/auth/drive.photos.readonly",
61            Scope::Readonly => "https://www.googleapis.com/auth/drive.readonly",
62            Scope::Script => "https://www.googleapis.com/auth/drive.scripts",
63        }
64    }
65}
66
67impl Default for Scope {
68    fn default() -> Scope {
69        Scope::MetadataReadonly
70    }
71}
72
73// ########
74// HUB ###
75// ######
76
77/// Central instance to access all DriveHub related resource activities
78///
79/// # Examples
80///
81/// Instantiate a new hub
82///
83/// ```test_harness,no_run
84/// extern crate hyper;
85/// extern crate hyper_rustls;
86/// extern crate google_drive3 as drive3;
87/// use drive3::{Result, Error};
88/// # async fn dox() {
89/// use std::default::Default;
90/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
91///
92/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
93/// // `client_secret`, among other things.
94/// let secret: oauth2::ApplicationSecret = Default::default();
95/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
96/// // unless you replace  `None` with the desired Flow.
97/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
98/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
99/// // retrieve them from storage.
100/// let auth = oauth2::InstalledFlowAuthenticator::builder(
101///         secret,
102///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
103///     ).build().await.unwrap();
104/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
105/// // You can configure optional parameters by calling the respective setters at will, and
106/// // execute the final call using `doit()`.
107/// // Values shown here are possibly random and not representative !
108/// let result = hub.files().list()
109///              .team_drive_id("eos")
110///              .supports_team_drives(false)
111///              .supports_all_drives(true)
112///              .spaces("duo")
113///              .q("sed")
114///              .page_token("no")
115///              .page_size(-15)
116///              .order_by("kasd")
117///              .include_team_drive_items(true)
118///              .include_permissions_for_view("et")
119///              .include_items_from_all_drives(true)
120///              .drive_id("vero")
121///              .corpus("erat")
122///              .corpora("sed")
123///              .doit().await;
124///
125/// match result {
126///     Err(e) => match e {
127///         // The Error enum provides details about what exactly happened.
128///         // You can also just use its `Debug`, `Display` or `Error` traits
129///          Error::HttpError(_)
130///         |Error::Io(_)
131///         |Error::MissingAPIKey
132///         |Error::MissingToken(_)
133///         |Error::Cancelled
134///         |Error::UploadSizeLimitExceeded(_, _)
135///         |Error::Failure(_)
136///         |Error::BadRequest(_)
137///         |Error::FieldClash(_)
138///         |Error::JsonDecodeError(_, _) => println!("{}", e),
139///     },
140///     Ok(res) => println!("Success: {:?}", res),
141/// }
142/// # }
143/// ```
144#[derive(Clone)]
145pub struct DriveHub<S> {
146    pub client: hyper::Client<S, hyper::body::Body>,
147    pub auth: oauth2::authenticator::Authenticator<S>,
148    _user_agent: String,
149    _base_url: String,
150    _root_url: String,
151}
152
153impl<'a, S> client::Hub for DriveHub<S> {}
154
155impl<'a, S> DriveHub<S> {
156    pub fn new(
157        client: hyper::Client<S, hyper::body::Body>,
158        authenticator: oauth2::authenticator::Authenticator<S>,
159    ) -> DriveHub<S> {
160        DriveHub {
161            client,
162            auth: authenticator,
163            _user_agent: "google-api-rust-client/4.0.0".to_string(),
164            _base_url: "https://www.googleapis.com/drive/v3/".to_string(),
165            _root_url: "https://www.googleapis.com/".to_string(),
166        }
167    }
168
169    pub fn about(&'a self) -> AboutMethods<'a, S> {
170        AboutMethods { hub: &self }
171    }
172    pub fn changes(&'a self) -> ChangeMethods<'a, S> {
173        ChangeMethods { hub: &self }
174    }
175    pub fn channels(&'a self) -> ChannelMethods<'a, S> {
176        ChannelMethods { hub: &self }
177    }
178    pub fn comments(&'a self) -> CommentMethods<'a, S> {
179        CommentMethods { hub: &self }
180    }
181    pub fn drives(&'a self) -> DriveMethods<'a, S> {
182        DriveMethods { hub: &self }
183    }
184    pub fn files(&'a self) -> FileMethods<'a, S> {
185        FileMethods { hub: &self }
186    }
187    pub fn permissions(&'a self) -> PermissionMethods<'a, S> {
188        PermissionMethods { hub: &self }
189    }
190    pub fn replies(&'a self) -> ReplyMethods<'a, S> {
191        ReplyMethods { hub: &self }
192    }
193    pub fn revisions(&'a self) -> RevisionMethods<'a, S> {
194        RevisionMethods { hub: &self }
195    }
196    pub fn teamdrives(&'a self) -> TeamdriveMethods<'a, S> {
197        TeamdriveMethods { hub: &self }
198    }
199
200    /// Set the user-agent header field to use in all requests to the server.
201    /// It defaults to `google-api-rust-client/4.0.0`.
202    ///
203    /// Returns the previously set user-agent.
204    pub fn user_agent(&mut self, agent_name: String) -> String {
205        mem::replace(&mut self._user_agent, agent_name)
206    }
207
208    /// Set the base url to use in all requests to the server.
209    /// It defaults to `https://www.googleapis.com/drive/v3/`.
210    ///
211    /// Returns the previously set base url.
212    pub fn base_url(&mut self, new_base_url: String) -> String {
213        mem::replace(&mut self._base_url, new_base_url)
214    }
215
216    /// Set the root url to use in all requests to the server.
217    /// It defaults to `https://www.googleapis.com/`.
218    ///
219    /// Returns the previously set root url.
220    pub fn root_url(&mut self, new_root_url: String) -> String {
221        mem::replace(&mut self._root_url, new_root_url)
222    }
223}
224
225// ############
226// SCHEMAS ###
227// ##########
228/// Information about the user, the user's Drive, and system capabilities.
229///
230/// # Activities
231///
232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
234///
235/// * [get about](AboutGetCall) (response)
236///
237#[derive(Default, Clone, Debug, Serialize, Deserialize)]
238pub struct About {
239    /// Whether the user has installed the requesting app.
240    #[serde(rename = "appInstalled")]
241    pub app_installed: Option<bool>,
242    /// Whether the user can create shared drives.
243    #[serde(rename = "canCreateDrives")]
244    pub can_create_drives: Option<bool>,
245    /// Deprecated - use canCreateDrives instead.
246    #[serde(rename = "canCreateTeamDrives")]
247    pub can_create_team_drives: Option<bool>,
248    /// A list of themes that are supported for shared drives.
249    #[serde(rename = "driveThemes")]
250    pub drive_themes: Option<Vec<AboutDriveThemes>>,
251    /// A map of source MIME type to possible targets for all supported exports.
252    #[serde(rename = "exportFormats")]
253    pub export_formats: Option<HashMap<String, Vec<String>>>,
254    /// The currently supported folder colors as RGB hex strings.
255    #[serde(rename = "folderColorPalette")]
256    pub folder_color_palette: Option<Vec<String>>,
257    /// A map of source MIME type to possible targets for all supported imports.
258    #[serde(rename = "importFormats")]
259    pub import_formats: Option<HashMap<String, Vec<String>>>,
260    /// Identifies what kind of resource this is. Value: the fixed string "drive#about".
261    pub kind: Option<String>,
262    /// A map of maximum import sizes by MIME type, in bytes.
263    #[serde(rename = "maxImportSizes")]
264    pub max_import_sizes: Option<HashMap<String, String>>,
265    /// The maximum upload size in bytes.
266    #[serde(rename = "maxUploadSize")]
267    pub max_upload_size: Option<String>,
268    /// The user's storage quota limits and usage. All fields are measured in bytes.
269    #[serde(rename = "storageQuota")]
270    pub storage_quota: Option<AboutStorageQuota>,
271    /// Deprecated - use driveThemes instead.
272    #[serde(rename = "teamDriveThemes")]
273    pub team_drive_themes: Option<Vec<AboutTeamDriveThemes>>,
274    /// The authenticated user.
275    pub user: Option<User>,
276}
277
278impl client::ResponseResult for About {}
279
280/// A change to a file or shared drive.
281///
282/// # Activities
283///
284/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
285/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
286///
287/// * [get start page token changes](ChangeGetStartPageTokenCall) (none)
288/// * [list changes](ChangeListCall) (none)
289/// * [watch changes](ChangeWatchCall) (none)
290///
291#[derive(Default, Clone, Debug, Serialize, Deserialize)]
292pub struct Change {
293    /// The type of the change. Possible values are file and drive.
294    #[serde(rename = "changeType")]
295    pub change_type: Option<String>,
296    /// The updated state of the shared drive. Present if the changeType is drive, the user is still a member of the shared drive, and the shared drive has not been deleted.
297    pub drive: Option<Drive>,
298    /// The ID of the shared drive associated with this change.
299    #[serde(rename = "driveId")]
300    pub drive_id: Option<String>,
301    /// The updated state of the file. Present if the type is file and the file has not been removed from this list of changes.
302    pub file: Option<File>,
303    /// The ID of the file which has changed.
304    #[serde(rename = "fileId")]
305    pub file_id: Option<String>,
306    /// Identifies what kind of resource this is. Value: the fixed string "drive#change".
307    pub kind: Option<String>,
308    /// Whether the file or shared drive has been removed from this list of changes, for example by deletion or loss of access.
309    pub removed: Option<bool>,
310    /// Deprecated - use drive instead.
311    #[serde(rename = "teamDrive")]
312    pub team_drive: Option<TeamDrive>,
313    /// Deprecated - use driveId instead.
314    #[serde(rename = "teamDriveId")]
315    pub team_drive_id: Option<String>,
316    /// The time of this change (RFC 3339 date-time).
317    pub time: Option<String>,
318    /// Deprecated - use changeType instead.
319    #[serde(rename = "type")]
320    pub type_: Option<String>,
321}
322
323impl client::Resource for Change {}
324
325/// A list of changes for a user.
326///
327/// # Activities
328///
329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
331///
332/// * [list changes](ChangeListCall) (response)
333///
334#[derive(Default, Clone, Debug, Serialize, Deserialize)]
335pub struct ChangeList {
336    /// The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
337    pub changes: Option<Vec<Change>>,
338    /// Identifies what kind of resource this is. Value: the fixed string "drive#changeList".
339    pub kind: Option<String>,
340    /// The starting page token for future changes. This will be present only if the end of the current changes list has been reached.
341    #[serde(rename = "newStartPageToken")]
342    pub new_start_page_token: Option<String>,
343    /// The page token for the next page of changes. This will be absent if the end of the changes list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
344    #[serde(rename = "nextPageToken")]
345    pub next_page_token: Option<String>,
346}
347
348impl client::ResponseResult for ChangeList {}
349
350/// An notification channel used to watch for resource changes.
351///
352/// # Activities
353///
354/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
355/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
356///
357/// * [watch changes](ChangeWatchCall) (request|response)
358/// * [stop channels](ChannelStopCall) (request)
359/// * [watch files](FileWatchCall) (request|response)
360///
361#[derive(Default, Clone, Debug, Serialize, Deserialize)]
362pub struct Channel {
363    /// The address where notifications are delivered for this channel.
364    pub address: Option<String>,
365    /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
366    pub expiration: Option<String>,
367    /// A UUID or similar unique string that identifies this channel.
368    pub id: Option<String>,
369    /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
370    pub kind: Option<String>,
371    /// Additional parameters controlling delivery channel behavior. Optional.
372    pub params: Option<HashMap<String, String>>,
373    /// A Boolean value to indicate whether payload is wanted. Optional.
374    pub payload: Option<bool>,
375    /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
376    #[serde(rename = "resourceId")]
377    pub resource_id: Option<String>,
378    /// A version-specific identifier for the watched resource.
379    #[serde(rename = "resourceUri")]
380    pub resource_uri: Option<String>,
381    /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
382    pub token: Option<String>,
383    /// The type of delivery mechanism used for this channel. Valid values are "web_hook" (or "webhook"). Both values refer to a channel where Http requests are used to deliver messages.
384    #[serde(rename = "type")]
385    pub type_: Option<String>,
386}
387
388impl client::RequestValue for Channel {}
389impl client::Resource for Channel {}
390impl client::ResponseResult for Channel {}
391
392/// A comment on a file.
393///
394/// # Activities
395///
396/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
397/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
398///
399/// * [create comments](CommentCreateCall) (request|response)
400/// * [delete comments](CommentDeleteCall) (none)
401/// * [get comments](CommentGetCall) (response)
402/// * [list comments](CommentListCall) (none)
403/// * [update comments](CommentUpdateCall) (request|response)
404///
405#[derive(Default, Clone, Debug, Serialize, Deserialize)]
406pub struct Comment {
407    /// A region of the document represented as a JSON string. For details on defining anchor properties, refer to  Add comments and replies.
408    pub anchor: Option<String>,
409    /// The author of the comment. The author's email address and permission ID will not be populated.
410    pub author: Option<User>,
411    /// The plain text content of the comment. This field is used for setting the content, while htmlContent should be displayed.
412    pub content: Option<String>,
413    /// The time at which the comment was created (RFC 3339 date-time).
414    #[serde(rename = "createdTime")]
415    pub created_time: Option<String>,
416    /// Whether the comment has been deleted. A deleted comment has no content.
417    pub deleted: Option<bool>,
418    /// The content of the comment with HTML formatting.
419    #[serde(rename = "htmlContent")]
420    pub html_content: Option<String>,
421    /// The ID of the comment.
422    pub id: Option<String>,
423    /// Identifies what kind of resource this is. Value: the fixed string "drive#comment".
424    pub kind: Option<String>,
425    /// The last time the comment or any of its replies was modified (RFC 3339 date-time).
426    #[serde(rename = "modifiedTime")]
427    pub modified_time: Option<String>,
428    /// The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.
429    #[serde(rename = "quotedFileContent")]
430    pub quoted_file_content: Option<CommentQuotedFileContent>,
431    /// The full list of replies to the comment in chronological order.
432    pub replies: Option<Vec<Reply>>,
433    /// Whether the comment has been resolved by one of its replies.
434    pub resolved: Option<bool>,
435}
436
437impl client::RequestValue for Comment {}
438impl client::Resource for Comment {}
439impl client::ResponseResult for Comment {}
440
441/// A list of comments on a file.
442///
443/// # Activities
444///
445/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
446/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
447///
448/// * [list comments](CommentListCall) (response)
449///
450#[derive(Default, Clone, Debug, Serialize, Deserialize)]
451pub struct CommentList {
452    /// The list of comments. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
453    pub comments: Option<Vec<Comment>>,
454    /// Identifies what kind of resource this is. Value: the fixed string "drive#commentList".
455    pub kind: Option<String>,
456    /// The page token for the next page of comments. This will be absent if the end of the comments list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
457    #[serde(rename = "nextPageToken")]
458    pub next_page_token: Option<String>,
459}
460
461impl client::ResponseResult for CommentList {}
462
463/// A restriction for accessing the content of the file.
464///
465/// This type is not used in any activity, and only used as *part* of another schema.
466///
467#[derive(Default, Clone, Debug, Serialize, Deserialize)]
468pub struct ContentRestriction {
469    /// Whether the content of the file is read-only. If a file is read-only, a new revision of the file may not be added, comments may not be added or modified, and the title of the file may not be modified.
470    #[serde(rename = "readOnly")]
471    pub read_only: Option<bool>,
472    /// Reason for why the content of the file is restricted. This is only mutable on requests that also set readOnly=true.
473    pub reason: Option<String>,
474    /// The user who set the content restriction. Only populated if readOnly is true.
475    #[serde(rename = "restrictingUser")]
476    pub restricting_user: Option<User>,
477    /// The time at which the content restriction was set (formatted RFC 3339 timestamp). Only populated if readOnly is true.
478    #[serde(rename = "restrictionTime")]
479    pub restriction_time: Option<String>,
480    /// The type of the content restriction. Currently the only possible value is globalContentRestriction.
481    #[serde(rename = "type")]
482    pub type_: Option<String>,
483}
484
485impl client::Part for ContentRestriction {}
486
487/// Representation of a shared drive.
488///
489/// # Activities
490///
491/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
492/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
493///
494/// * [create drives](DriveCreateCall) (request|response)
495/// * [delete drives](DriveDeleteCall) (none)
496/// * [get drives](DriveGetCall) (response)
497/// * [hide drives](DriveHideCall) (response)
498/// * [list drives](DriveListCall) (none)
499/// * [unhide drives](DriveUnhideCall) (response)
500/// * [update drives](DriveUpdateCall) (request|response)
501///
502#[derive(Default, Clone, Debug, Serialize, Deserialize)]
503pub struct Drive {
504    /// An image file and cropping parameters from which a background image for this shared drive is set. This is a write only field; it can only be set on drive.drives.update requests that don't set themeId. When specified, all fields of the backgroundImageFile must be set.
505    #[serde(rename = "backgroundImageFile")]
506    pub background_image_file: Option<DriveBackgroundImageFile>,
507    /// A short-lived link to this shared drive's background image.
508    #[serde(rename = "backgroundImageLink")]
509    pub background_image_link: Option<String>,
510    /// Capabilities the current user has on this shared drive.
511    pub capabilities: Option<DriveCapabilities>,
512    /// The color of this shared drive as an RGB hex string. It can only be set on a drive.drives.update request that does not set themeId.
513    #[serde(rename = "colorRgb")]
514    pub color_rgb: Option<String>,
515    /// The time at which the shared drive was created (RFC 3339 date-time).
516    #[serde(rename = "createdTime")]
517    pub created_time: Option<String>,
518    /// Whether the shared drive is hidden from default view.
519    pub hidden: Option<bool>,
520    /// The ID of this shared drive which is also the ID of the top level folder of this shared drive.
521    pub id: Option<String>,
522    /// Identifies what kind of resource this is. Value: the fixed string "drive#drive".
523    pub kind: Option<String>,
524    /// The name of this shared drive.
525    pub name: Option<String>,
526    /// The organizational unit of this shared drive. This field is only populated on drives.list responses when the useDomainAdminAccess parameter is set to true.
527    #[serde(rename = "orgUnitId")]
528    pub org_unit_id: Option<String>,
529    /// A set of restrictions that apply to this shared drive or items inside this shared drive.
530    pub restrictions: Option<DriveRestrictions>,
531    /// The ID of the theme from which the background image and color will be set. The set of possible driveThemes can be retrieved from a drive.about.get response. When not specified on a drive.drives.create request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set colorRgb or backgroundImageFile.
532    #[serde(rename = "themeId")]
533    pub theme_id: Option<String>,
534}
535
536impl client::RequestValue for Drive {}
537impl client::Resource for Drive {}
538impl client::ResponseResult for Drive {}
539
540/// A list of shared drives.
541///
542/// # Activities
543///
544/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
545/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
546///
547/// * [list drives](DriveListCall) (response)
548///
549#[derive(Default, Clone, Debug, Serialize, Deserialize)]
550pub struct DriveList {
551    /// The list of shared drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
552    pub drives: Option<Vec<Drive>>,
553    /// Identifies what kind of resource this is. Value: the fixed string "drive#driveList".
554    pub kind: Option<String>,
555    /// The page token for the next page of shared drives. This will be absent if the end of the list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
556    #[serde(rename = "nextPageToken")]
557    pub next_page_token: Option<String>,
558}
559
560impl client::ResponseResult for DriveList {}
561
562/// The metadata for a file.
563///
564/// # Activities
565///
566/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
567/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
568///
569/// * [copy files](FileCopyCall) (request|response)
570/// * [create files](FileCreateCall) (request|response)
571/// * [delete files](FileDeleteCall) (none)
572/// * [empty trash files](FileEmptyTrashCall) (none)
573/// * [export files](FileExportCall) (none)
574/// * [generate ids files](FileGenerateIdCall) (none)
575/// * [get files](FileGetCall) (response)
576/// * [list files](FileListCall) (none)
577/// * [update files](FileUpdateCall) (request|response)
578/// * [watch files](FileWatchCall) (none)
579///
580#[derive(Default, Clone, Debug, Serialize, Deserialize)]
581pub struct File {
582    /// A collection of arbitrary key-value pairs which are private to the requesting app.
583    /// Entries with null values are cleared in update and copy requests. These properties can only be retrieved using an authenticated request. An authenticated request uses an access token obtained with a OAuth 2 client ID. You cannot use an API key to retrieve private properties.
584    #[serde(rename = "appProperties")]
585    pub app_properties: Option<HashMap<String, String>>,
586    /// Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.
587    pub capabilities: Option<FileCapabilities>,
588    /// Additional information about the content of the file. These fields are never populated in responses.
589    #[serde(rename = "contentHints")]
590    pub content_hints: Option<FileContentHints>,
591    /// Restrictions for accessing the content of the file. Only populated if such a restriction exists.
592    #[serde(rename = "contentRestrictions")]
593    pub content_restrictions: Option<Vec<ContentRestriction>>,
594    /// Whether the options to copy, print, or download this file, should be disabled for readers and commenters.
595    #[serde(rename = "copyRequiresWriterPermission")]
596    pub copy_requires_writer_permission: Option<bool>,
597    /// The time at which the file was created (RFC 3339 date-time).
598    #[serde(rename = "createdTime")]
599    pub created_time: Option<String>,
600    /// A short description of the file.
601    pub description: Option<String>,
602    /// ID of the shared drive the file resides in. Only populated for items in shared drives.
603    #[serde(rename = "driveId")]
604    pub drive_id: Option<String>,
605    /// Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.
606    #[serde(rename = "explicitlyTrashed")]
607    pub explicitly_trashed: Option<bool>,
608    /// Links for exporting Docs Editors files to specific formats.
609    #[serde(rename = "exportLinks")]
610    pub export_links: Option<HashMap<String, String>>,
611    /// The final component of fullFileExtension. This is only available for files with binary content in Google Drive.
612    #[serde(rename = "fileExtension")]
613    pub file_extension: Option<String>,
614    /// The color for a folder or shortcut to a folder as an RGB hex string. The supported colors are published in the folderColorPalette field of the About resource.
615    /// If an unsupported color is specified, the closest color in the palette will be used instead.
616    #[serde(rename = "folderColorRgb")]
617    pub folder_color_rgb: Option<String>,
618    /// The full file extension extracted from the name field. May contain multiple concatenated extensions, such as "tar.gz". This is only available for files with binary content in Google Drive.
619    /// This is automatically updated when the name field changes, however it is not cleared if the new name does not contain a valid extension.
620    #[serde(rename = "fullFileExtension")]
621    pub full_file_extension: Option<String>,
622    /// Whether there are permissions directly on this file. This field is only populated for items in shared drives.
623    #[serde(rename = "hasAugmentedPermissions")]
624    pub has_augmented_permissions: Option<bool>,
625    /// Whether this file has a thumbnail. This does not indicate whether the requesting app has access to the thumbnail. To check access, look for the presence of the thumbnailLink field.
626    #[serde(rename = "hasThumbnail")]
627    pub has_thumbnail: Option<bool>,
628    /// The ID of the file's head revision. This is currently only available for files with binary content in Google Drive.
629    #[serde(rename = "headRevisionId")]
630    pub head_revision_id: Option<String>,
631    /// A static, unauthenticated link to the file's icon.
632    #[serde(rename = "iconLink")]
633    pub icon_link: Option<String>,
634    /// The ID of the file.
635    pub id: Option<String>,
636    /// Additional metadata about image media, if available.
637    #[serde(rename = "imageMediaMetadata")]
638    pub image_media_metadata: Option<FileImageMediaMetadata>,
639    /// Whether the file was created or opened by the requesting app.
640    #[serde(rename = "isAppAuthorized")]
641    pub is_app_authorized: Option<bool>,
642    /// Identifies what kind of resource this is. Value: the fixed string "drive#file".
643    pub kind: Option<String>,
644    /// The last user to modify the file.
645    #[serde(rename = "lastModifyingUser")]
646    pub last_modifying_user: Option<User>,
647    /// Contains details about the link URLs that clients are using to refer to this item.
648    #[serde(rename = "linkShareMetadata")]
649    pub link_share_metadata: Option<FileLinkShareMetadata>,
650    /// The MD5 checksum for the content of the file. This is only applicable to files with binary content in Google Drive.
651    #[serde(rename = "md5Checksum")]
652    pub md5_checksum: Option<String>,
653    /// The MIME type of the file.
654    /// Google Drive will attempt to automatically detect an appropriate value from uploaded content if no value is provided. The value cannot be changed unless a new revision is uploaded.
655    /// If a file is created with a Google Doc MIME type, the uploaded content will be imported if possible. The supported import formats are published in the About resource.
656    #[serde(rename = "mimeType")]
657    pub mime_type: Option<String>,
658    /// Whether the file has been modified by this user.
659    #[serde(rename = "modifiedByMe")]
660    pub modified_by_me: Option<bool>,
661    /// The last time the file was modified by the user (RFC 3339 date-time).
662    #[serde(rename = "modifiedByMeTime")]
663    pub modified_by_me_time: Option<String>,
664    /// The last time the file was modified by anyone (RFC 3339 date-time).
665    /// Note that setting modifiedTime will also update modifiedByMeTime for the user.
666    #[serde(rename = "modifiedTime")]
667    pub modified_time: Option<String>,
668    /// The name of the file. This is not necessarily unique within a folder. Note that for immutable items such as the top level folders of shared drives, My Drive root folder, and Application Data folder the name is constant.
669    pub name: Option<String>,
670    /// The original filename of the uploaded content if available, or else the original value of the name field. This is only available for files with binary content in Google Drive.
671    #[serde(rename = "originalFilename")]
672    pub original_filename: Option<String>,
673    /// Whether the user owns the file. Not populated for items in shared drives.
674    #[serde(rename = "ownedByMe")]
675    pub owned_by_me: Option<bool>,
676    /// The owner of this file. Only certain legacy files may have more than one owner. This field isn't populated for items in shared drives.
677    pub owners: Option<Vec<User>>,
678    /// The IDs of the parent folders which contain the file.
679    /// If not specified as part of a create request, the file will be placed directly in the user's My Drive folder. If not specified as part of a copy request, the file will inherit any discoverable parents of the source file. Update requests must use the addParents and removeParents parameters to modify the parents list.
680    pub parents: Option<Vec<String>>,
681    /// List of permission IDs for users with access to this file.
682    #[serde(rename = "permissionIds")]
683    pub permission_ids: Option<Vec<String>>,
684    /// The full list of permissions for the file. This is only available if the requesting user can share the file. Not populated for items in shared drives.
685    pub permissions: Option<Vec<Permission>>,
686    /// A collection of arbitrary key-value pairs which are visible to all apps.
687    /// Entries with null values are cleared in update and copy requests.
688    pub properties: Option<HashMap<String, String>>,
689    /// The number of storage quota bytes used by the file. This includes the head revision as well as previous revisions with keepForever enabled.
690    #[serde(rename = "quotaBytesUsed")]
691    pub quota_bytes_used: Option<String>,
692    /// A key needed to access the item via a shared link.
693    #[serde(rename = "resourceKey")]
694    pub resource_key: Option<String>,
695    /// Whether the file has been shared. Not populated for items in shared drives.
696    pub shared: Option<bool>,
697    /// The time at which the file was shared with the user, if applicable (RFC 3339 date-time).
698    #[serde(rename = "sharedWithMeTime")]
699    pub shared_with_me_time: Option<String>,
700    /// The user who shared the file with the requesting user, if applicable.
701    #[serde(rename = "sharingUser")]
702    pub sharing_user: Option<User>,
703    /// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to application/vnd.google-apps.shortcut.
704    #[serde(rename = "shortcutDetails")]
705    pub shortcut_details: Option<FileShortcutDetails>,
706    /// The size of the file's content in bytes. This is applicable to binary files in Google Drive and Google Docs files.
707    pub size: Option<String>,
708    /// The list of spaces which contain the file. The currently supported values are 'drive', 'appDataFolder' and 'photos'.
709    pub spaces: Option<Vec<String>>,
710    /// Whether the user has starred the file.
711    pub starred: Option<bool>,
712    /// Deprecated - use driveId instead.
713    #[serde(rename = "teamDriveId")]
714    pub team_drive_id: Option<String>,
715    /// A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in Files.thumbnailLink must be fetched using a credentialed request.
716    #[serde(rename = "thumbnailLink")]
717    pub thumbnail_link: Option<String>,
718    /// The thumbnail version for use in thumbnail cache invalidation.
719    #[serde(rename = "thumbnailVersion")]
720    pub thumbnail_version: Option<String>,
721    /// Whether the file has been trashed, either explicitly or from a trashed parent folder. Only the owner may trash a file. The trashed item is excluded from all files.list responses returned for any user who does not own the file. However, all users with access to the file can see the trashed item metadata in an API response. All users with access can copy, download, export, and share the file.
722    pub trashed: Option<bool>,
723    /// The time that the item was trashed (RFC 3339 date-time). Only populated for items in shared drives.
724    #[serde(rename = "trashedTime")]
725    pub trashed_time: Option<String>,
726    /// If the file has been explicitly trashed, the user who trashed it. Only populated for items in shared drives.
727    #[serde(rename = "trashingUser")]
728    pub trashing_user: Option<User>,
729    /// A monotonically increasing version number for the file. This reflects every change made to the file on the server, even those not visible to the user.
730    pub version: Option<String>,
731    /// Additional metadata about video media. This may not be available immediately upon upload.
732    #[serde(rename = "videoMediaMetadata")]
733    pub video_media_metadata: Option<FileVideoMediaMetadata>,
734    /// Whether the file has been viewed by this user.
735    #[serde(rename = "viewedByMe")]
736    pub viewed_by_me: Option<bool>,
737    /// The last time the file was viewed by the user (RFC 3339 date-time).
738    #[serde(rename = "viewedByMeTime")]
739    pub viewed_by_me_time: Option<String>,
740    /// Deprecated - use copyRequiresWriterPermission instead.
741    #[serde(rename = "viewersCanCopyContent")]
742    pub viewers_can_copy_content: Option<bool>,
743    /// A link for downloading the content of the file in a browser. This is only available for files with binary content in Google Drive.
744    #[serde(rename = "webContentLink")]
745    pub web_content_link: Option<String>,
746    /// A link for opening the file in a relevant Google editor or viewer in a browser.
747    #[serde(rename = "webViewLink")]
748    pub web_view_link: Option<String>,
749    /// Whether users with only writer permission can modify the file's permissions. Not populated for items in shared drives.
750    #[serde(rename = "writersCanShare")]
751    pub writers_can_share: Option<bool>,
752}
753
754impl client::RequestValue for File {}
755impl client::Resource for File {}
756impl client::ResponseResult for File {}
757
758/// A list of files.
759///
760/// # Activities
761///
762/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
763/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
764///
765/// * [list files](FileListCall) (response)
766///
767#[derive(Default, Clone, Debug, Serialize, Deserialize)]
768pub struct FileList {
769    /// The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
770    pub files: Option<Vec<File>>,
771    /// Whether the search process was incomplete. If true, then some search results may be missing, since all documents were not searched. This may occur when searching multiple drives with the "allDrives" corpora, but all corpora could not be searched. When this happens, it is suggested that clients narrow their query by choosing a different corpus such as "user" or "drive".
772    #[serde(rename = "incompleteSearch")]
773    pub incomplete_search: Option<bool>,
774    /// Identifies what kind of resource this is. Value: the fixed string "drive#fileList".
775    pub kind: Option<String>,
776    /// The page token for the next page of files. This will be absent if the end of the files list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
777    #[serde(rename = "nextPageToken")]
778    pub next_page_token: Option<String>,
779}
780
781impl client::ResponseResult for FileList {}
782
783/// A list of generated file IDs which can be provided in create requests.
784///
785/// # Activities
786///
787/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
788/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
789///
790/// * [generate ids files](FileGenerateIdCall) (response)
791///
792#[derive(Default, Clone, Debug, Serialize, Deserialize)]
793pub struct GeneratedIds {
794    /// The IDs generated for the requesting user in the specified space.
795    pub ids: Option<Vec<String>>,
796    /// Identifies what kind of resource this is. Value: the fixed string "drive#generatedIds".
797    pub kind: Option<String>,
798    /// The type of file that can be created with these IDs.
799    pub space: Option<String>,
800}
801
802impl client::ResponseResult for GeneratedIds {}
803
804/// A permission for a file. A permission grants a user, group, domain or the world access to a file or a folder hierarchy.
805///
806/// # Activities
807///
808/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
809/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
810///
811/// * [create permissions](PermissionCreateCall) (request|response)
812/// * [delete permissions](PermissionDeleteCall) (none)
813/// * [get permissions](PermissionGetCall) (response)
814/// * [list permissions](PermissionListCall) (none)
815/// * [update permissions](PermissionUpdateCall) (request|response)
816///
817#[derive(Default, Clone, Debug, Serialize, Deserialize)]
818pub struct Permission {
819    /// Whether the permission allows the file to be discovered through search. This is only applicable for permissions of type domain or anyone.
820    #[serde(rename = "allowFileDiscovery")]
821    pub allow_file_discovery: Option<bool>,
822    /// Whether the account associated with this permission has been deleted. This field only pertains to user and group permissions.
823    pub deleted: Option<bool>,
824    /// The "pretty" name of the value of the permission. The following is a list of examples for each type of permission:
825    /// - user - User's full name, as defined for their Google account, such as "Joe Smith."
826    /// - group - Name of the Google Group, such as "The Company Administrators."
827    /// - domain - String domain name, such as "thecompany.com."
828    /// - anyone - No displayName is present.
829    #[serde(rename = "displayName")]
830    pub display_name: Option<String>,
831    /// The domain to which this permission refers.
832    pub domain: Option<String>,
833    /// The email address of the user or group to which this permission refers.
834    #[serde(rename = "emailAddress")]
835    pub email_address: Option<String>,
836    /// The time at which this permission will expire (RFC 3339 date-time). Expiration times have the following restrictions:
837    /// - They can only be set on user and group permissions
838    /// - The time must be in the future
839    /// - The time cannot be more than a year in the future
840    #[serde(rename = "expirationTime")]
841    pub expiration_time: Option<String>,
842    /// The ID of this permission. This is a unique identifier for the grantee, and is published in User resources as permissionId. IDs should be treated as opaque values.
843    pub id: Option<String>,
844    /// Identifies what kind of resource this is. Value: the fixed string "drive#permission".
845    pub kind: Option<String>,
846    /// Whether the account associated with this permission is a pending owner. Only populated for user type permissions for files that are not in a shared drive.
847    #[serde(rename = "pendingOwner")]
848    pub pending_owner: Option<bool>,
849    /// Details of whether the permissions on this shared drive item are inherited or directly on this item. This is an output-only field which is present only for shared drive items.
850    #[serde(rename = "permissionDetails")]
851    pub permission_details: Option<Vec<PermissionPermissionDetails>>,
852    /// A link to the user's profile photo, if available.
853    #[serde(rename = "photoLink")]
854    pub photo_link: Option<String>,
855    /// The role granted by this permission. While new values may be supported in the future, the following are currently allowed:
856    /// - owner
857    /// - organizer
858    /// - fileOrganizer
859    /// - writer
860    /// - commenter
861    /// - reader
862    pub role: Option<String>,
863    /// Deprecated - use permissionDetails instead.
864    #[serde(rename = "teamDrivePermissionDetails")]
865    pub team_drive_permission_details: Option<Vec<PermissionTeamDrivePermissionDetails>>,
866    /// The type of the grantee. Valid values are:
867    /// - user
868    /// - group
869    /// - domain
870    /// - anyone  When creating a permission, if type is user or group, you must provide an emailAddress for the user or group. When type is domain, you must provide a domain. There isn't extra information required for a anyone type.
871    #[serde(rename = "type")]
872    pub type_: Option<String>,
873    /// Indicates the view for this permission. Only populated for permissions that belong to a view. published is the only supported value.
874    pub view: Option<String>,
875}
876
877impl client::RequestValue for Permission {}
878impl client::Resource for Permission {}
879impl client::ResponseResult for Permission {}
880
881/// A list of permissions for a file.
882///
883/// # Activities
884///
885/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
886/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
887///
888/// * [list permissions](PermissionListCall) (response)
889///
890#[derive(Default, Clone, Debug, Serialize, Deserialize)]
891pub struct PermissionList {
892    /// Identifies what kind of resource this is. Value: the fixed string "drive#permissionList".
893    pub kind: Option<String>,
894    /// The page token for the next page of permissions. This field will be absent if the end of the permissions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
895    #[serde(rename = "nextPageToken")]
896    pub next_page_token: Option<String>,
897    /// The list of permissions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
898    pub permissions: Option<Vec<Permission>>,
899}
900
901impl client::ResponseResult for PermissionList {}
902
903/// A reply to a comment on a file.
904///
905/// # Activities
906///
907/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
908/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
909///
910/// * [create replies](ReplyCreateCall) (request|response)
911/// * [get replies](ReplyGetCall) (response)
912/// * [update replies](ReplyUpdateCall) (request|response)
913///
914#[derive(Default, Clone, Debug, Serialize, Deserialize)]
915pub struct Reply {
916    /// The action the reply performed to the parent comment. Valid values are:
917    /// - resolve
918    /// - reopen
919    pub action: Option<String>,
920    /// The author of the reply. The author's email address and permission ID will not be populated.
921    pub author: Option<User>,
922    /// The plain text content of the reply. This field is used for setting the content, while htmlContent should be displayed. This is required on creates if no action is specified.
923    pub content: Option<String>,
924    /// The time at which the reply was created (RFC 3339 date-time).
925    #[serde(rename = "createdTime")]
926    pub created_time: Option<String>,
927    /// Whether the reply has been deleted. A deleted reply has no content.
928    pub deleted: Option<bool>,
929    /// The content of the reply with HTML formatting.
930    #[serde(rename = "htmlContent")]
931    pub html_content: Option<String>,
932    /// The ID of the reply.
933    pub id: Option<String>,
934    /// Identifies what kind of resource this is. Value: the fixed string "drive#reply".
935    pub kind: Option<String>,
936    /// The last time the reply was modified (RFC 3339 date-time).
937    #[serde(rename = "modifiedTime")]
938    pub modified_time: Option<String>,
939}
940
941impl client::RequestValue for Reply {}
942impl client::ResponseResult for Reply {}
943
944/// A list of replies to a comment on a file.
945///
946/// # Activities
947///
948/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
949/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
950///
951/// * [list replies](ReplyListCall) (response)
952///
953#[derive(Default, Clone, Debug, Serialize, Deserialize)]
954pub struct ReplyList {
955    /// Identifies what kind of resource this is. Value: the fixed string "drive#replyList".
956    pub kind: Option<String>,
957    /// The page token for the next page of replies. This will be absent if the end of the replies list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
958    #[serde(rename = "nextPageToken")]
959    pub next_page_token: Option<String>,
960    /// The list of replies. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
961    pub replies: Option<Vec<Reply>>,
962}
963
964impl client::ResponseResult for ReplyList {}
965
966/// The metadata for a revision to a file.
967///
968/// # Activities
969///
970/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
971/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
972///
973/// * [delete revisions](RevisionDeleteCall) (none)
974/// * [get revisions](RevisionGetCall) (response)
975/// * [list revisions](RevisionListCall) (none)
976/// * [update revisions](RevisionUpdateCall) (request|response)
977///
978#[derive(Default, Clone, Debug, Serialize, Deserialize)]
979pub struct Revision {
980    /// Links for exporting Docs Editors files to specific formats.
981    #[serde(rename = "exportLinks")]
982    pub export_links: Option<HashMap<String, String>>,
983    /// The ID of the revision.
984    pub id: Option<String>,
985    /// Whether to keep this revision forever, even if it is no longer the head revision. If not set, the revision will be automatically purged 30 days after newer content is uploaded. This can be set on a maximum of 200 revisions for a file.
986    /// This field is only applicable to files with binary content in Drive.
987    #[serde(rename = "keepForever")]
988    pub keep_forever: Option<bool>,
989    /// Identifies what kind of resource this is. Value: the fixed string "drive#revision".
990    pub kind: Option<String>,
991    /// The last user to modify this revision.
992    #[serde(rename = "lastModifyingUser")]
993    pub last_modifying_user: Option<User>,
994    /// The MD5 checksum of the revision's content. This is only applicable to files with binary content in Drive.
995    #[serde(rename = "md5Checksum")]
996    pub md5_checksum: Option<String>,
997    /// The MIME type of the revision.
998    #[serde(rename = "mimeType")]
999    pub mime_type: Option<String>,
1000    /// The last time the revision was modified (RFC 3339 date-time).
1001    #[serde(rename = "modifiedTime")]
1002    pub modified_time: Option<String>,
1003    /// The original filename used to create this revision. This is only applicable to files with binary content in Drive.
1004    #[serde(rename = "originalFilename")]
1005    pub original_filename: Option<String>,
1006    /// Whether subsequent revisions will be automatically republished. This is only applicable to Docs Editors files.
1007    #[serde(rename = "publishAuto")]
1008    pub publish_auto: Option<bool>,
1009    /// Whether this revision is published. This is only applicable to Docs Editors files.
1010    pub published: Option<bool>,
1011    /// A link to the published revision. This is only populated for Google Sites files.
1012    #[serde(rename = "publishedLink")]
1013    pub published_link: Option<String>,
1014    /// Whether this revision is published outside the domain. This is only applicable to Docs Editors files.
1015    #[serde(rename = "publishedOutsideDomain")]
1016    pub published_outside_domain: Option<bool>,
1017    /// The size of the revision's content in bytes. This is only applicable to files with binary content in Drive.
1018    pub size: Option<String>,
1019}
1020
1021impl client::RequestValue for Revision {}
1022impl client::Resource for Revision {}
1023impl client::ResponseResult for Revision {}
1024
1025/// A list of revisions of a file.
1026///
1027/// # Activities
1028///
1029/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1030/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1031///
1032/// * [list revisions](RevisionListCall) (response)
1033///
1034#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1035pub struct RevisionList {
1036    /// Identifies what kind of resource this is. Value: the fixed string "drive#revisionList".
1037    pub kind: Option<String>,
1038    /// The page token for the next page of revisions. This will be absent if the end of the revisions list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
1039    #[serde(rename = "nextPageToken")]
1040    pub next_page_token: Option<String>,
1041    /// The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1042    pub revisions: Option<Vec<Revision>>,
1043}
1044
1045impl client::ResponseResult for RevisionList {}
1046
1047/// There is no detailed description.
1048///
1049/// # Activities
1050///
1051/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1052/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1053///
1054/// * [get start page token changes](ChangeGetStartPageTokenCall) (response)
1055///
1056#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1057pub struct StartPageToken {
1058    /// Identifies what kind of resource this is. Value: the fixed string "drive#startPageToken".
1059    pub kind: Option<String>,
1060    /// The starting page token for listing changes.
1061    #[serde(rename = "startPageToken")]
1062    pub start_page_token: Option<String>,
1063}
1064
1065impl client::ResponseResult for StartPageToken {}
1066
1067/// Deprecated: use the drive collection instead.
1068///
1069/// # Activities
1070///
1071/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1072/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1073///
1074/// * [create teamdrives](TeamdriveCreateCall) (request|response)
1075/// * [get teamdrives](TeamdriveGetCall) (response)
1076/// * [update teamdrives](TeamdriveUpdateCall) (request|response)
1077///
1078#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1079pub struct TeamDrive {
1080    /// An image file and cropping parameters from which a background image for this Team Drive is set. This is a write only field; it can only be set on drive.teamdrives.update requests that don't set themeId. When specified, all fields of the backgroundImageFile must be set.
1081    #[serde(rename = "backgroundImageFile")]
1082    pub background_image_file: Option<TeamDriveBackgroundImageFile>,
1083    /// A short-lived link to this Team Drive's background image.
1084    #[serde(rename = "backgroundImageLink")]
1085    pub background_image_link: Option<String>,
1086    /// Capabilities the current user has on this Team Drive.
1087    pub capabilities: Option<TeamDriveCapabilities>,
1088    /// The color of this Team Drive as an RGB hex string. It can only be set on a drive.teamdrives.update request that does not set themeId.
1089    #[serde(rename = "colorRgb")]
1090    pub color_rgb: Option<String>,
1091    /// The time at which the Team Drive was created (RFC 3339 date-time).
1092    #[serde(rename = "createdTime")]
1093    pub created_time: Option<String>,
1094    /// The ID of this Team Drive which is also the ID of the top level folder of this Team Drive.
1095    pub id: Option<String>,
1096    /// Identifies what kind of resource this is. Value: the fixed string "drive#teamDrive".
1097    pub kind: Option<String>,
1098    /// The name of this Team Drive.
1099    pub name: Option<String>,
1100    /// The organizational unit of this shared drive. This field is only populated on drives.list responses when the useDomainAdminAccess parameter is set to true.
1101    #[serde(rename = "orgUnitId")]
1102    pub org_unit_id: Option<String>,
1103    /// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
1104    pub restrictions: Option<TeamDriveRestrictions>,
1105    /// The ID of the theme from which the background image and color will be set. The set of possible teamDriveThemes can be retrieved from a drive.about.get response. When not specified on a drive.teamdrives.create request, a random theme is chosen from which the background image and color are set. This is a write-only field; it can only be set on requests that don't set colorRgb or backgroundImageFile.
1106    #[serde(rename = "themeId")]
1107    pub theme_id: Option<String>,
1108}
1109
1110impl client::RequestValue for TeamDrive {}
1111impl client::Resource for TeamDrive {}
1112impl client::ResponseResult for TeamDrive {}
1113
1114/// A list of Team Drives.
1115///
1116/// # Activities
1117///
1118/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1119/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1120///
1121/// * [list teamdrives](TeamdriveListCall) (response)
1122///
1123#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1124pub struct TeamDriveList {
1125    /// Identifies what kind of resource this is. Value: the fixed string "drive#teamDriveList".
1126    pub kind: Option<String>,
1127    /// The page token for the next page of Team Drives. This will be absent if the end of the Team Drives list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results.
1128    #[serde(rename = "nextPageToken")]
1129    pub next_page_token: Option<String>,
1130    /// The list of Team Drives. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.
1131    #[serde(rename = "teamDrives")]
1132    pub team_drives: Option<Vec<TeamDrive>>,
1133}
1134
1135impl client::ResponseResult for TeamDriveList {}
1136
1137/// Information about a Drive user.
1138///
1139/// This type is not used in any activity, and only used as *part* of another schema.
1140///
1141#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1142pub struct User {
1143    /// A plain text displayable name for this user.
1144    #[serde(rename = "displayName")]
1145    pub display_name: Option<String>,
1146    /// The email address of the user. This may not be present in certain contexts if the user has not made their email address visible to the requester.
1147    #[serde(rename = "emailAddress")]
1148    pub email_address: Option<String>,
1149    /// Identifies what kind of resource this is. Value: the fixed string "drive#user".
1150    pub kind: Option<String>,
1151    /// Whether this user is the requesting user.
1152    pub me: Option<bool>,
1153    /// The user's ID as visible in Permission resources.
1154    #[serde(rename = "permissionId")]
1155    pub permission_id: Option<String>,
1156    /// A link to the user's profile photo, if available.
1157    #[serde(rename = "photoLink")]
1158    pub photo_link: Option<String>,
1159}
1160
1161impl client::Part for User {}
1162
1163/// A list of themes that are supported for shared drives.
1164///
1165/// This type is not used in any activity, and only used as *part* of another schema.
1166///
1167#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1168pub struct AboutDriveThemes {
1169    /// A link to this theme's background image.
1170    #[serde(rename = "backgroundImageLink")]
1171    pub background_image_link: Option<String>,
1172    /// The color of this theme as an RGB hex string.
1173    #[serde(rename = "colorRgb")]
1174    pub color_rgb: Option<String>,
1175    /// The ID of the theme.
1176    pub id: Option<String>,
1177}
1178
1179impl client::NestedType for AboutDriveThemes {}
1180impl client::Part for AboutDriveThemes {}
1181
1182/// The user's storage quota limits and usage. All fields are measured in bytes.
1183///
1184/// This type is not used in any activity, and only used as *part* of another schema.
1185///
1186#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1187pub struct AboutStorageQuota {
1188    /// The usage limit, if applicable. This will not be present if the user has unlimited storage.
1189    pub limit: Option<String>,
1190    /// The total usage across all services.
1191    pub usage: Option<String>,
1192    /// The usage by all files in Google Drive.
1193    #[serde(rename = "usageInDrive")]
1194    pub usage_in_drive: Option<String>,
1195    /// The usage by trashed files in Google Drive.
1196    #[serde(rename = "usageInDriveTrash")]
1197    pub usage_in_drive_trash: Option<String>,
1198}
1199
1200impl client::NestedType for AboutStorageQuota {}
1201impl client::Part for AboutStorageQuota {}
1202
1203/// Deprecated - use driveThemes instead.
1204///
1205/// This type is not used in any activity, and only used as *part* of another schema.
1206///
1207#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1208pub struct AboutTeamDriveThemes {
1209    /// Deprecated - use driveThemes/backgroundImageLink instead.
1210    #[serde(rename = "backgroundImageLink")]
1211    pub background_image_link: Option<String>,
1212    /// Deprecated - use driveThemes/colorRgb instead.
1213    #[serde(rename = "colorRgb")]
1214    pub color_rgb: Option<String>,
1215    /// Deprecated - use driveThemes/id instead.
1216    pub id: Option<String>,
1217}
1218
1219impl client::NestedType for AboutTeamDriveThemes {}
1220impl client::Part for AboutTeamDriveThemes {}
1221
1222/// The file content to which the comment refers, typically within the anchor region. For a text file, for example, this would be the text at the location of the comment.
1223///
1224/// This type is not used in any activity, and only used as *part* of another schema.
1225///
1226#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1227pub struct CommentQuotedFileContent {
1228    /// The MIME type of the quoted content.
1229    #[serde(rename = "mimeType")]
1230    pub mime_type: Option<String>,
1231    /// The quoted content itself. This is interpreted as plain text if set through the API.
1232    pub value: Option<String>,
1233}
1234
1235impl client::NestedType for CommentQuotedFileContent {}
1236impl client::Part for CommentQuotedFileContent {}
1237
1238/// An image file and cropping parameters from which a background image for this shared drive is set. This is a write only field; it can only be set on drive.drives.update requests that don't set themeId. When specified, all fields of the backgroundImageFile must be set.
1239///
1240/// This type is not used in any activity, and only used as *part* of another schema.
1241///
1242#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1243pub struct DriveBackgroundImageFile {
1244    /// The ID of an image file in Google Drive to use for the background image.
1245    pub id: Option<String>,
1246    /// The width of the cropped image in the closed range of 0 to 1. This value represents the width of the cropped image divided by the width of the entire image. The height is computed by applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280 pixels wide and 144 pixels high.
1247    pub width: Option<f32>,
1248    /// The X coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the horizontal distance from the left side of the entire image to the left side of the cropping area divided by the width of the entire image.
1249    #[serde(rename = "xCoordinate")]
1250    pub x_coordinate: Option<f32>,
1251    /// The Y coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the vertical distance from the top side of the entire image to the top side of the cropping area divided by the height of the entire image.
1252    #[serde(rename = "yCoordinate")]
1253    pub y_coordinate: Option<f32>,
1254}
1255
1256impl client::NestedType for DriveBackgroundImageFile {}
1257impl client::Part for DriveBackgroundImageFile {}
1258
1259/// Capabilities the current user has on this shared drive.
1260///
1261/// This type is not used in any activity, and only used as *part* of another schema.
1262///
1263#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1264pub struct DriveCapabilities {
1265    /// Whether the current user can add children to folders in this shared drive.
1266    #[serde(rename = "canAddChildren")]
1267    pub can_add_children: Option<bool>,
1268    /// Whether the current user can change the copyRequiresWriterPermission restriction of this shared drive.
1269    #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
1270    pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
1271    /// Whether the current user can change the domainUsersOnly restriction of this shared drive.
1272    #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
1273    pub can_change_domain_users_only_restriction: Option<bool>,
1274    /// Whether the current user can change the background of this shared drive.
1275    #[serde(rename = "canChangeDriveBackground")]
1276    pub can_change_drive_background: Option<bool>,
1277    /// Whether the current user can change the driveMembersOnly restriction of this shared drive.
1278    #[serde(rename = "canChangeDriveMembersOnlyRestriction")]
1279    pub can_change_drive_members_only_restriction: Option<bool>,
1280    /// Whether the current user can comment on files in this shared drive.
1281    #[serde(rename = "canComment")]
1282    pub can_comment: Option<bool>,
1283    /// Whether the current user can copy files in this shared drive.
1284    #[serde(rename = "canCopy")]
1285    pub can_copy: Option<bool>,
1286    /// Whether the current user can delete children from folders in this shared drive.
1287    #[serde(rename = "canDeleteChildren")]
1288    pub can_delete_children: Option<bool>,
1289    /// Whether the current user can delete this shared drive. Attempting to delete the shared drive may still fail if there are untrashed items inside the shared drive.
1290    #[serde(rename = "canDeleteDrive")]
1291    pub can_delete_drive: Option<bool>,
1292    /// Whether the current user can download files in this shared drive.
1293    #[serde(rename = "canDownload")]
1294    pub can_download: Option<bool>,
1295    /// Whether the current user can edit files in this shared drive
1296    #[serde(rename = "canEdit")]
1297    pub can_edit: Option<bool>,
1298    /// Whether the current user can list the children of folders in this shared drive.
1299    #[serde(rename = "canListChildren")]
1300    pub can_list_children: Option<bool>,
1301    /// Whether the current user can add members to this shared drive or remove them or change their role.
1302    #[serde(rename = "canManageMembers")]
1303    pub can_manage_members: Option<bool>,
1304    /// Whether the current user can read the revisions resource of files in this shared drive.
1305    #[serde(rename = "canReadRevisions")]
1306    pub can_read_revisions: Option<bool>,
1307    /// Whether the current user can rename files or folders in this shared drive.
1308    #[serde(rename = "canRename")]
1309    pub can_rename: Option<bool>,
1310    /// Whether the current user can rename this shared drive.
1311    #[serde(rename = "canRenameDrive")]
1312    pub can_rename_drive: Option<bool>,
1313    /// Whether the current user can share files or folders in this shared drive.
1314    #[serde(rename = "canShare")]
1315    pub can_share: Option<bool>,
1316    /// Whether the current user can trash children from folders in this shared drive.
1317    #[serde(rename = "canTrashChildren")]
1318    pub can_trash_children: Option<bool>,
1319}
1320
1321impl client::NestedType for DriveCapabilities {}
1322impl client::Part for DriveCapabilities {}
1323
1324/// A set of restrictions that apply to this shared drive or items inside this shared drive.
1325///
1326/// This type is not used in any activity, and only used as *part* of another schema.
1327///
1328#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1329pub struct DriveRestrictions {
1330    /// Whether administrative privileges on this shared drive are required to modify restrictions.
1331    #[serde(rename = "adminManagedRestrictions")]
1332    pub admin_managed_restrictions: Option<bool>,
1333    /// Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.
1334    #[serde(rename = "copyRequiresWriterPermission")]
1335    pub copy_requires_writer_permission: Option<bool>,
1336    /// Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs. This restriction may be overridden by other sharing policies controlled outside of this shared drive.
1337    #[serde(rename = "domainUsersOnly")]
1338    pub domain_users_only: Option<bool>,
1339    /// Whether access to items inside this shared drive is restricted to its members.
1340    #[serde(rename = "driveMembersOnly")]
1341    pub drive_members_only: Option<bool>,
1342}
1343
1344impl client::NestedType for DriveRestrictions {}
1345impl client::Part for DriveRestrictions {}
1346
1347/// Capabilities the current user has on this file. Each capability corresponds to a fine-grained action that a user may take.
1348///
1349/// This type is not used in any activity, and only used as *part* of another schema.
1350///
1351#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1352pub struct FileCapabilities {
1353    /// Whether the current user is the pending owner of the file. Not populated for shared drive files.
1354    #[serde(rename = "canAcceptOwnership")]
1355    pub can_accept_ownership: Option<bool>,
1356    /// Whether the current user can add children to this folder. This is always false when the item is not a folder.
1357    #[serde(rename = "canAddChildren")]
1358    pub can_add_children: Option<bool>,
1359    /// Whether the current user can add a folder from another drive (different shared drive or My Drive) to this folder. This is false when the item is not a folder. Only populated for items in shared drives.
1360    #[serde(rename = "canAddFolderFromAnotherDrive")]
1361    pub can_add_folder_from_another_drive: Option<bool>,
1362    /// Whether the current user can add a parent for the item without removing an existing parent in the same request. Not populated for shared drive files.
1363    #[serde(rename = "canAddMyDriveParent")]
1364    pub can_add_my_drive_parent: Option<bool>,
1365    /// Whether the current user can change the copyRequiresWriterPermission restriction of this file.
1366    #[serde(rename = "canChangeCopyRequiresWriterPermission")]
1367    pub can_change_copy_requires_writer_permission: Option<bool>,
1368    /// Whether the current user can change the securityUpdateEnabled field on link share metadata.
1369    #[serde(rename = "canChangeSecurityUpdateEnabled")]
1370    pub can_change_security_update_enabled: Option<bool>,
1371    /// Deprecated
1372    #[serde(rename = "canChangeViewersCanCopyContent")]
1373    pub can_change_viewers_can_copy_content: Option<bool>,
1374    /// Whether the current user can comment on this file.
1375    #[serde(rename = "canComment")]
1376    pub can_comment: Option<bool>,
1377    /// Whether the current user can copy this file. For an item in a shared drive, whether the current user can copy non-folder descendants of this item, or this item itself if it is not a folder.
1378    #[serde(rename = "canCopy")]
1379    pub can_copy: Option<bool>,
1380    /// Whether the current user can delete this file.
1381    #[serde(rename = "canDelete")]
1382    pub can_delete: Option<bool>,
1383    /// Whether the current user can delete children of this folder. This is false when the item is not a folder. Only populated for items in shared drives.
1384    #[serde(rename = "canDeleteChildren")]
1385    pub can_delete_children: Option<bool>,
1386    /// Whether the current user can download this file.
1387    #[serde(rename = "canDownload")]
1388    pub can_download: Option<bool>,
1389    /// Whether the current user can edit this file. Other factors may limit the type of changes a user can make to a file. For example, see canChangeCopyRequiresWriterPermission or canModifyContent.
1390    #[serde(rename = "canEdit")]
1391    pub can_edit: Option<bool>,
1392    /// Whether the current user can list the children of this folder. This is always false when the item is not a folder.
1393    #[serde(rename = "canListChildren")]
1394    pub can_list_children: Option<bool>,
1395    /// Whether the current user can modify the content of this file.
1396    #[serde(rename = "canModifyContent")]
1397    pub can_modify_content: Option<bool>,
1398    /// Whether the current user can modify restrictions on content of this file.
1399    #[serde(rename = "canModifyContentRestriction")]
1400    pub can_modify_content_restriction: Option<bool>,
1401    /// Whether the current user can move children of this folder outside of the shared drive. This is false when the item is not a folder. Only populated for items in shared drives.
1402    #[serde(rename = "canMoveChildrenOutOfDrive")]
1403    pub can_move_children_out_of_drive: Option<bool>,
1404    /// Deprecated - use canMoveChildrenOutOfDrive instead.
1405    #[serde(rename = "canMoveChildrenOutOfTeamDrive")]
1406    pub can_move_children_out_of_team_drive: Option<bool>,
1407    /// Whether the current user can move children of this folder within this drive. This is false when the item is not a folder. Note that a request to move the child may still fail depending on the current user's access to the child and to the destination folder.
1408    #[serde(rename = "canMoveChildrenWithinDrive")]
1409    pub can_move_children_within_drive: Option<bool>,
1410    /// Deprecated - use canMoveChildrenWithinDrive instead.
1411    #[serde(rename = "canMoveChildrenWithinTeamDrive")]
1412    pub can_move_children_within_team_drive: Option<bool>,
1413    /// Deprecated - use canMoveItemOutOfDrive instead.
1414    #[serde(rename = "canMoveItemIntoTeamDrive")]
1415    pub can_move_item_into_team_drive: Option<bool>,
1416    /// Whether the current user can move this item outside of this drive by changing its parent. Note that a request to change the parent of the item may still fail depending on the new parent that is being added.
1417    #[serde(rename = "canMoveItemOutOfDrive")]
1418    pub can_move_item_out_of_drive: Option<bool>,
1419    /// Deprecated - use canMoveItemOutOfDrive instead.
1420    #[serde(rename = "canMoveItemOutOfTeamDrive")]
1421    pub can_move_item_out_of_team_drive: Option<bool>,
1422    /// Whether the current user can move this item within this drive. Note that a request to change the parent of the item may still fail depending on the new parent that is being added and the parent that is being removed.
1423    #[serde(rename = "canMoveItemWithinDrive")]
1424    pub can_move_item_within_drive: Option<bool>,
1425    /// Deprecated - use canMoveItemWithinDrive instead.
1426    #[serde(rename = "canMoveItemWithinTeamDrive")]
1427    pub can_move_item_within_team_drive: Option<bool>,
1428    /// Deprecated - use canMoveItemWithinDrive or canMoveItemOutOfDrive instead.
1429    #[serde(rename = "canMoveTeamDriveItem")]
1430    pub can_move_team_drive_item: Option<bool>,
1431    /// Whether the current user can read the shared drive to which this file belongs. Only populated for items in shared drives.
1432    #[serde(rename = "canReadDrive")]
1433    pub can_read_drive: Option<bool>,
1434    /// Whether the current user can read the revisions resource of this file. For a shared drive item, whether revisions of non-folder descendants of this item, or this item itself if it is not a folder, can be read.
1435    #[serde(rename = "canReadRevisions")]
1436    pub can_read_revisions: Option<bool>,
1437    /// Deprecated - use canReadDrive instead.
1438    #[serde(rename = "canReadTeamDrive")]
1439    pub can_read_team_drive: Option<bool>,
1440    /// Whether the current user can remove children from this folder. This is always false when the item is not a folder. For a folder in a shared drive, use canDeleteChildren or canTrashChildren instead.
1441    #[serde(rename = "canRemoveChildren")]
1442    pub can_remove_children: Option<bool>,
1443    /// Whether the current user can remove a parent from the item without adding another parent in the same request. Not populated for shared drive files.
1444    #[serde(rename = "canRemoveMyDriveParent")]
1445    pub can_remove_my_drive_parent: Option<bool>,
1446    /// Whether the current user can rename this file.
1447    #[serde(rename = "canRename")]
1448    pub can_rename: Option<bool>,
1449    /// Whether the current user can modify the sharing settings for this file.
1450    #[serde(rename = "canShare")]
1451    pub can_share: Option<bool>,
1452    /// Whether the current user can move this file to trash.
1453    #[serde(rename = "canTrash")]
1454    pub can_trash: Option<bool>,
1455    /// Whether the current user can trash children of this folder. This is false when the item is not a folder. Only populated for items in shared drives.
1456    #[serde(rename = "canTrashChildren")]
1457    pub can_trash_children: Option<bool>,
1458    /// Whether the current user can restore this file from trash.
1459    #[serde(rename = "canUntrash")]
1460    pub can_untrash: Option<bool>,
1461}
1462
1463impl client::NestedType for FileCapabilities {}
1464impl client::Part for FileCapabilities {}
1465
1466/// Additional information about the content of the file. These fields are never populated in responses.
1467///
1468/// This type is not used in any activity, and only used as *part* of another schema.
1469///
1470#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1471pub struct FileContentHints {
1472    /// Text to be indexed for the file to improve fullText queries. This is limited to 128KB in length and may contain HTML elements.
1473    #[serde(rename = "indexableText")]
1474    pub indexable_text: Option<String>,
1475    /// A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail.
1476    pub thumbnail: Option<FileContentHintsThumbnail>,
1477}
1478
1479impl client::NestedType for FileContentHints {}
1480impl client::Part for FileContentHints {}
1481
1482/// A thumbnail for the file. This will only be used if Google Drive cannot generate a standard thumbnail.
1483///
1484/// This type is not used in any activity, and only used as *part* of another schema.
1485///
1486#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1487pub struct FileContentHintsThumbnail {
1488    /// The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).
1489    pub image: Option<String>,
1490    /// The MIME type of the thumbnail.
1491    #[serde(rename = "mimeType")]
1492    pub mime_type: Option<String>,
1493}
1494
1495impl client::NestedType for FileContentHintsThumbnail {}
1496impl client::Part for FileContentHintsThumbnail {}
1497
1498/// Additional metadata about image media, if available.
1499///
1500/// This type is not used in any activity, and only used as *part* of another schema.
1501///
1502#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1503pub struct FileImageMediaMetadata {
1504    /// The aperture used to create the photo (f-number).
1505    pub aperture: Option<f32>,
1506    /// The make of the camera used to create the photo.
1507    #[serde(rename = "cameraMake")]
1508    pub camera_make: Option<String>,
1509    /// The model of the camera used to create the photo.
1510    #[serde(rename = "cameraModel")]
1511    pub camera_model: Option<String>,
1512    /// The color space of the photo.
1513    #[serde(rename = "colorSpace")]
1514    pub color_space: Option<String>,
1515    /// The exposure bias of the photo (APEX value).
1516    #[serde(rename = "exposureBias")]
1517    pub exposure_bias: Option<f32>,
1518    /// The exposure mode used to create the photo.
1519    #[serde(rename = "exposureMode")]
1520    pub exposure_mode: Option<String>,
1521    /// The length of the exposure, in seconds.
1522    #[serde(rename = "exposureTime")]
1523    pub exposure_time: Option<f32>,
1524    /// Whether a flash was used to create the photo.
1525    #[serde(rename = "flashUsed")]
1526    pub flash_used: Option<bool>,
1527    /// The focal length used to create the photo, in millimeters.
1528    #[serde(rename = "focalLength")]
1529    pub focal_length: Option<f32>,
1530    /// The height of the image in pixels.
1531    pub height: Option<i32>,
1532    /// The ISO speed used to create the photo.
1533    #[serde(rename = "isoSpeed")]
1534    pub iso_speed: Option<i32>,
1535    /// The lens used to create the photo.
1536    pub lens: Option<String>,
1537    /// Geographic location information stored in the image.
1538    pub location: Option<FileImageMediaMetadataLocation>,
1539    /// The smallest f-number of the lens at the focal length used to create the photo (APEX value).
1540    #[serde(rename = "maxApertureValue")]
1541    pub max_aperture_value: Option<f32>,
1542    /// The metering mode used to create the photo.
1543    #[serde(rename = "meteringMode")]
1544    pub metering_mode: Option<String>,
1545    /// The number of clockwise 90 degree rotations applied from the image's original orientation.
1546    pub rotation: Option<i32>,
1547    /// The type of sensor used to create the photo.
1548    pub sensor: Option<String>,
1549    /// The distance to the subject of the photo, in meters.
1550    #[serde(rename = "subjectDistance")]
1551    pub subject_distance: Option<i32>,
1552    /// The date and time the photo was taken (EXIF DateTime).
1553    pub time: Option<String>,
1554    /// The white balance mode used to create the photo.
1555    #[serde(rename = "whiteBalance")]
1556    pub white_balance: Option<String>,
1557    /// The width of the image in pixels.
1558    pub width: Option<i32>,
1559}
1560
1561impl client::NestedType for FileImageMediaMetadata {}
1562impl client::Part for FileImageMediaMetadata {}
1563
1564/// Geographic location information stored in the image.
1565///
1566/// This type is not used in any activity, and only used as *part* of another schema.
1567///
1568#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1569pub struct FileImageMediaMetadataLocation {
1570    /// The altitude stored in the image.
1571    pub altitude: Option<f64>,
1572    /// The latitude stored in the image.
1573    pub latitude: Option<f64>,
1574    /// The longitude stored in the image.
1575    pub longitude: Option<f64>,
1576}
1577
1578impl client::NestedType for FileImageMediaMetadataLocation {}
1579impl client::Part for FileImageMediaMetadataLocation {}
1580
1581/// Contains details about the link URLs that clients are using to refer to this item.
1582///
1583/// This type is not used in any activity, and only used as *part* of another schema.
1584///
1585#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1586pub struct FileLinkShareMetadata {
1587    /// Whether the file is eligible for security update.
1588    #[serde(rename = "securityUpdateEligible")]
1589    pub security_update_eligible: Option<bool>,
1590    /// Whether the security update is enabled for this file.
1591    #[serde(rename = "securityUpdateEnabled")]
1592    pub security_update_enabled: Option<bool>,
1593}
1594
1595impl client::NestedType for FileLinkShareMetadata {}
1596impl client::Part for FileLinkShareMetadata {}
1597
1598/// Shortcut file details. Only populated for shortcut files, which have the mimeType field set to application/vnd.google-apps.shortcut.
1599///
1600/// This type is not used in any activity, and only used as *part* of another schema.
1601///
1602#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1603pub struct FileShortcutDetails {
1604    /// The ID of the file that this shortcut points to.
1605    #[serde(rename = "targetId")]
1606    pub target_id: Option<String>,
1607    /// The MIME type of the file that this shortcut points to. The value of this field is a snapshot of the target's MIME type, captured when the shortcut is created.
1608    #[serde(rename = "targetMimeType")]
1609    pub target_mime_type: Option<String>,
1610    /// The ResourceKey for the target file.
1611    #[serde(rename = "targetResourceKey")]
1612    pub target_resource_key: Option<String>,
1613}
1614
1615impl client::NestedType for FileShortcutDetails {}
1616impl client::Part for FileShortcutDetails {}
1617
1618/// Additional metadata about video media. This may not be available immediately upon upload.
1619///
1620/// This type is not used in any activity, and only used as *part* of another schema.
1621///
1622#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1623pub struct FileVideoMediaMetadata {
1624    /// The duration of the video in milliseconds.
1625    #[serde(rename = "durationMillis")]
1626    pub duration_millis: Option<String>,
1627    /// The height of the video in pixels.
1628    pub height: Option<i32>,
1629    /// The width of the video in pixels.
1630    pub width: Option<i32>,
1631}
1632
1633impl client::NestedType for FileVideoMediaMetadata {}
1634impl client::Part for FileVideoMediaMetadata {}
1635
1636/// Details of whether the permissions on this shared drive item are inherited or directly on this item. This is an output-only field which is present only for shared drive items.
1637///
1638/// This type is not used in any activity, and only used as *part* of another schema.
1639///
1640#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1641pub struct PermissionPermissionDetails {
1642    /// Whether this permission is inherited. This field is always populated. This is an output-only field.
1643    pub inherited: Option<bool>,
1644    /// The ID of the item from which this permission is inherited. This is an output-only field.
1645    #[serde(rename = "inheritedFrom")]
1646    pub inherited_from: Option<String>,
1647    /// The permission type for this user. While new values may be added in future, the following are currently possible:
1648    /// - file
1649    /// - member
1650    #[serde(rename = "permissionType")]
1651    pub permission_type: Option<String>,
1652    /// The primary role for this user. While new values may be added in the future, the following are currently possible:
1653    /// - organizer
1654    /// - fileOrganizer
1655    /// - writer
1656    /// - commenter
1657    /// - reader
1658    pub role: Option<String>,
1659}
1660
1661impl client::NestedType for PermissionPermissionDetails {}
1662impl client::Part for PermissionPermissionDetails {}
1663
1664/// Deprecated - use permissionDetails instead.
1665///
1666/// This type is not used in any activity, and only used as *part* of another schema.
1667///
1668#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1669pub struct PermissionTeamDrivePermissionDetails {
1670    /// Deprecated - use permissionDetails/inherited instead.
1671    pub inherited: Option<bool>,
1672    /// Deprecated - use permissionDetails/inheritedFrom instead.
1673    #[serde(rename = "inheritedFrom")]
1674    pub inherited_from: Option<String>,
1675    /// Deprecated - use permissionDetails/role instead.
1676    pub role: Option<String>,
1677    /// Deprecated - use permissionDetails/permissionType instead.
1678    #[serde(rename = "teamDrivePermissionType")]
1679    pub team_drive_permission_type: Option<String>,
1680}
1681
1682impl client::NestedType for PermissionTeamDrivePermissionDetails {}
1683impl client::Part for PermissionTeamDrivePermissionDetails {}
1684
1685/// An image file and cropping parameters from which a background image for this Team Drive is set. This is a write only field; it can only be set on drive.teamdrives.update requests that don't set themeId. When specified, all fields of the backgroundImageFile must be set.
1686///
1687/// This type is not used in any activity, and only used as *part* of another schema.
1688///
1689#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1690pub struct TeamDriveBackgroundImageFile {
1691    /// The ID of an image file in Drive to use for the background image.
1692    pub id: Option<String>,
1693    /// The width of the cropped image in the closed range of 0 to 1. This value represents the width of the cropped image divided by the width of the entire image. The height is computed by applying a width to height aspect ratio of 80 to 9. The resulting image must be at least 1280 pixels wide and 144 pixels high.
1694    pub width: Option<f32>,
1695    /// The X coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the horizontal distance from the left side of the entire image to the left side of the cropping area divided by the width of the entire image.
1696    #[serde(rename = "xCoordinate")]
1697    pub x_coordinate: Option<f32>,
1698    /// The Y coordinate of the upper left corner of the cropping area in the background image. This is a value in the closed range of 0 to 1. This value represents the vertical distance from the top side of the entire image to the top side of the cropping area divided by the height of the entire image.
1699    #[serde(rename = "yCoordinate")]
1700    pub y_coordinate: Option<f32>,
1701}
1702
1703impl client::NestedType for TeamDriveBackgroundImageFile {}
1704impl client::Part for TeamDriveBackgroundImageFile {}
1705
1706/// Capabilities the current user has on this Team Drive.
1707///
1708/// This type is not used in any activity, and only used as *part* of another schema.
1709///
1710#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1711pub struct TeamDriveCapabilities {
1712    /// Whether the current user can add children to folders in this Team Drive.
1713    #[serde(rename = "canAddChildren")]
1714    pub can_add_children: Option<bool>,
1715    /// Whether the current user can change the copyRequiresWriterPermission restriction of this Team Drive.
1716    #[serde(rename = "canChangeCopyRequiresWriterPermissionRestriction")]
1717    pub can_change_copy_requires_writer_permission_restriction: Option<bool>,
1718    /// Whether the current user can change the domainUsersOnly restriction of this Team Drive.
1719    #[serde(rename = "canChangeDomainUsersOnlyRestriction")]
1720    pub can_change_domain_users_only_restriction: Option<bool>,
1721    /// Whether the current user can change the background of this Team Drive.
1722    #[serde(rename = "canChangeTeamDriveBackground")]
1723    pub can_change_team_drive_background: Option<bool>,
1724    /// Whether the current user can change the teamMembersOnly restriction of this Team Drive.
1725    #[serde(rename = "canChangeTeamMembersOnlyRestriction")]
1726    pub can_change_team_members_only_restriction: Option<bool>,
1727    /// Whether the current user can comment on files in this Team Drive.
1728    #[serde(rename = "canComment")]
1729    pub can_comment: Option<bool>,
1730    /// Whether the current user can copy files in this Team Drive.
1731    #[serde(rename = "canCopy")]
1732    pub can_copy: Option<bool>,
1733    /// Whether the current user can delete children from folders in this Team Drive.
1734    #[serde(rename = "canDeleteChildren")]
1735    pub can_delete_children: Option<bool>,
1736    /// Whether the current user can delete this Team Drive. Attempting to delete the Team Drive may still fail if there are untrashed items inside the Team Drive.
1737    #[serde(rename = "canDeleteTeamDrive")]
1738    pub can_delete_team_drive: Option<bool>,
1739    /// Whether the current user can download files in this Team Drive.
1740    #[serde(rename = "canDownload")]
1741    pub can_download: Option<bool>,
1742    /// Whether the current user can edit files in this Team Drive
1743    #[serde(rename = "canEdit")]
1744    pub can_edit: Option<bool>,
1745    /// Whether the current user can list the children of folders in this Team Drive.
1746    #[serde(rename = "canListChildren")]
1747    pub can_list_children: Option<bool>,
1748    /// Whether the current user can add members to this Team Drive or remove them or change their role.
1749    #[serde(rename = "canManageMembers")]
1750    pub can_manage_members: Option<bool>,
1751    /// Whether the current user can read the revisions resource of files in this Team Drive.
1752    #[serde(rename = "canReadRevisions")]
1753    pub can_read_revisions: Option<bool>,
1754    /// Deprecated - use canDeleteChildren or canTrashChildren instead.
1755    #[serde(rename = "canRemoveChildren")]
1756    pub can_remove_children: Option<bool>,
1757    /// Whether the current user can rename files or folders in this Team Drive.
1758    #[serde(rename = "canRename")]
1759    pub can_rename: Option<bool>,
1760    /// Whether the current user can rename this Team Drive.
1761    #[serde(rename = "canRenameTeamDrive")]
1762    pub can_rename_team_drive: Option<bool>,
1763    /// Whether the current user can share files or folders in this Team Drive.
1764    #[serde(rename = "canShare")]
1765    pub can_share: Option<bool>,
1766    /// Whether the current user can trash children from folders in this Team Drive.
1767    #[serde(rename = "canTrashChildren")]
1768    pub can_trash_children: Option<bool>,
1769}
1770
1771impl client::NestedType for TeamDriveCapabilities {}
1772impl client::Part for TeamDriveCapabilities {}
1773
1774/// A set of restrictions that apply to this Team Drive or items inside this Team Drive.
1775///
1776/// This type is not used in any activity, and only used as *part* of another schema.
1777///
1778#[derive(Default, Clone, Debug, Serialize, Deserialize)]
1779pub struct TeamDriveRestrictions {
1780    /// Whether administrative privileges on this Team Drive are required to modify restrictions.
1781    #[serde(rename = "adminManagedRestrictions")]
1782    pub admin_managed_restrictions: Option<bool>,
1783    /// Whether the options to copy, print, or download files inside this Team Drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this Team Drive.
1784    #[serde(rename = "copyRequiresWriterPermission")]
1785    pub copy_requires_writer_permission: Option<bool>,
1786    /// Whether access to this Team Drive and items inside this Team Drive is restricted to users of the domain to which this Team Drive belongs. This restriction may be overridden by other sharing policies controlled outside of this Team Drive.
1787    #[serde(rename = "domainUsersOnly")]
1788    pub domain_users_only: Option<bool>,
1789    /// Whether access to items inside this Team Drive is restricted to members of this Team Drive.
1790    #[serde(rename = "teamMembersOnly")]
1791    pub team_members_only: Option<bool>,
1792}
1793
1794impl client::NestedType for TeamDriveRestrictions {}
1795impl client::Part for TeamDriveRestrictions {}
1796
1797// ###################
1798// MethodBuilders ###
1799// #################
1800
1801/// A builder providing access to all methods supported on *about* resources.
1802/// It is not used directly, but through the `DriveHub` hub.
1803///
1804/// # Example
1805///
1806/// Instantiate a resource builder
1807///
1808/// ```test_harness,no_run
1809/// extern crate hyper;
1810/// extern crate hyper_rustls;
1811/// extern crate google_drive3 as drive3;
1812///
1813/// # async fn dox() {
1814/// use std::default::Default;
1815/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
1816///
1817/// let secret: oauth2::ApplicationSecret = Default::default();
1818/// let auth = oauth2::InstalledFlowAuthenticator::builder(
1819///         secret,
1820///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1821///     ).build().await.unwrap();
1822/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
1823/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1824/// // like `get(...)`
1825/// // to build up your call.
1826/// let rb = hub.about();
1827/// # }
1828/// ```
1829pub struct AboutMethods<'a, S>
1830where
1831    S: 'a,
1832{
1833    hub: &'a DriveHub<S>,
1834}
1835
1836impl<'a, S> client::MethodsBuilder for AboutMethods<'a, S> {}
1837
1838impl<'a, S> AboutMethods<'a, S> {
1839    /// Create a builder to help you perform the following task:
1840    ///
1841    /// Gets information about the user, the user's Drive, and system capabilities.
1842    pub fn get(&self) -> AboutGetCall<'a, S> {
1843        AboutGetCall {
1844            hub: self.hub,
1845            _delegate: Default::default(),
1846            _additional_params: Default::default(),
1847            _scopes: Default::default(),
1848        }
1849    }
1850}
1851
1852/// A builder providing access to all methods supported on *change* resources.
1853/// It is not used directly, but through the `DriveHub` hub.
1854///
1855/// # Example
1856///
1857/// Instantiate a resource builder
1858///
1859/// ```test_harness,no_run
1860/// extern crate hyper;
1861/// extern crate hyper_rustls;
1862/// extern crate google_drive3 as drive3;
1863///
1864/// # async fn dox() {
1865/// use std::default::Default;
1866/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
1867///
1868/// let secret: oauth2::ApplicationSecret = Default::default();
1869/// let auth = oauth2::InstalledFlowAuthenticator::builder(
1870///         secret,
1871///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1872///     ).build().await.unwrap();
1873/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
1874/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1875/// // like `get_start_page_token(...)`, `list(...)` and `watch(...)`
1876/// // to build up your call.
1877/// let rb = hub.changes();
1878/// # }
1879/// ```
1880pub struct ChangeMethods<'a, S>
1881where
1882    S: 'a,
1883{
1884    hub: &'a DriveHub<S>,
1885}
1886
1887impl<'a, S> client::MethodsBuilder for ChangeMethods<'a, S> {}
1888
1889impl<'a, S> ChangeMethods<'a, S> {
1890    /// Create a builder to help you perform the following task:
1891    ///
1892    /// Gets the starting pageToken for listing future changes.
1893    pub fn get_start_page_token(&self) -> ChangeGetStartPageTokenCall<'a, S> {
1894        ChangeGetStartPageTokenCall {
1895            hub: self.hub,
1896            _team_drive_id: Default::default(),
1897            _supports_team_drives: Default::default(),
1898            _supports_all_drives: Default::default(),
1899            _drive_id: Default::default(),
1900            _delegate: Default::default(),
1901            _additional_params: Default::default(),
1902            _scopes: Default::default(),
1903        }
1904    }
1905
1906    /// Create a builder to help you perform the following task:
1907    ///
1908    /// Lists the changes for a user or shared drive.
1909    ///
1910    /// # Arguments
1911    ///
1912    /// * `pageToken` - The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
1913    pub fn list(&self, page_token: &str) -> ChangeListCall<'a, S> {
1914        ChangeListCall {
1915            hub: self.hub,
1916            _page_token: page_token.to_string(),
1917            _team_drive_id: Default::default(),
1918            _supports_team_drives: Default::default(),
1919            _supports_all_drives: Default::default(),
1920            _spaces: Default::default(),
1921            _restrict_to_my_drive: Default::default(),
1922            _page_size: Default::default(),
1923            _include_team_drive_items: Default::default(),
1924            _include_removed: Default::default(),
1925            _include_permissions_for_view: Default::default(),
1926            _include_items_from_all_drives: Default::default(),
1927            _include_corpus_removals: Default::default(),
1928            _drive_id: Default::default(),
1929            _delegate: Default::default(),
1930            _additional_params: Default::default(),
1931            _scopes: Default::default(),
1932        }
1933    }
1934
1935    /// Create a builder to help you perform the following task:
1936    ///
1937    /// Subscribes to changes for a user.
1938    ///
1939    /// # Arguments
1940    ///
1941    /// * `request` - No description provided.
1942    /// * `pageToken` - The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
1943    pub fn watch(&self, request: Channel, page_token: &str) -> ChangeWatchCall<'a, S> {
1944        ChangeWatchCall {
1945            hub: self.hub,
1946            _request: request,
1947            _page_token: page_token.to_string(),
1948            _team_drive_id: Default::default(),
1949            _supports_team_drives: Default::default(),
1950            _supports_all_drives: Default::default(),
1951            _spaces: Default::default(),
1952            _restrict_to_my_drive: Default::default(),
1953            _page_size: Default::default(),
1954            _include_team_drive_items: Default::default(),
1955            _include_removed: Default::default(),
1956            _include_permissions_for_view: Default::default(),
1957            _include_items_from_all_drives: Default::default(),
1958            _include_corpus_removals: Default::default(),
1959            _drive_id: Default::default(),
1960            _delegate: Default::default(),
1961            _additional_params: Default::default(),
1962            _scopes: Default::default(),
1963        }
1964    }
1965}
1966
1967/// A builder providing access to all methods supported on *channel* resources.
1968/// It is not used directly, but through the `DriveHub` hub.
1969///
1970/// # Example
1971///
1972/// Instantiate a resource builder
1973///
1974/// ```test_harness,no_run
1975/// extern crate hyper;
1976/// extern crate hyper_rustls;
1977/// extern crate google_drive3 as drive3;
1978///
1979/// # async fn dox() {
1980/// use std::default::Default;
1981/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
1982///
1983/// let secret: oauth2::ApplicationSecret = Default::default();
1984/// let auth = oauth2::InstalledFlowAuthenticator::builder(
1985///         secret,
1986///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1987///     ).build().await.unwrap();
1988/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
1989/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1990/// // like `stop(...)`
1991/// // to build up your call.
1992/// let rb = hub.channels();
1993/// # }
1994/// ```
1995pub struct ChannelMethods<'a, S>
1996where
1997    S: 'a,
1998{
1999    hub: &'a DriveHub<S>,
2000}
2001
2002impl<'a, S> client::MethodsBuilder for ChannelMethods<'a, S> {}
2003
2004impl<'a, S> ChannelMethods<'a, S> {
2005    /// Create a builder to help you perform the following task:
2006    ///
2007    /// Stop watching resources through this channel
2008    ///
2009    /// # Arguments
2010    ///
2011    /// * `request` - No description provided.
2012    pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, S> {
2013        ChannelStopCall {
2014            hub: self.hub,
2015            _request: request,
2016            _delegate: Default::default(),
2017            _additional_params: Default::default(),
2018            _scopes: Default::default(),
2019        }
2020    }
2021}
2022
2023/// A builder providing access to all methods supported on *comment* resources.
2024/// It is not used directly, but through the `DriveHub` hub.
2025///
2026/// # Example
2027///
2028/// Instantiate a resource builder
2029///
2030/// ```test_harness,no_run
2031/// extern crate hyper;
2032/// extern crate hyper_rustls;
2033/// extern crate google_drive3 as drive3;
2034///
2035/// # async fn dox() {
2036/// use std::default::Default;
2037/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2038///
2039/// let secret: oauth2::ApplicationSecret = Default::default();
2040/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2041///         secret,
2042///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2043///     ).build().await.unwrap();
2044/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2045/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2046/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
2047/// // to build up your call.
2048/// let rb = hub.comments();
2049/// # }
2050/// ```
2051pub struct CommentMethods<'a, S>
2052where
2053    S: 'a,
2054{
2055    hub: &'a DriveHub<S>,
2056}
2057
2058impl<'a, S> client::MethodsBuilder for CommentMethods<'a, S> {}
2059
2060impl<'a, S> CommentMethods<'a, S> {
2061    /// Create a builder to help you perform the following task:
2062    ///
2063    /// Creates a new comment on a file.
2064    ///
2065    /// # Arguments
2066    ///
2067    /// * `request` - No description provided.
2068    /// * `fileId` - The ID of the file.
2069    pub fn create(&self, request: Comment, file_id: &str) -> CommentCreateCall<'a, S> {
2070        CommentCreateCall {
2071            hub: self.hub,
2072            _request: request,
2073            _file_id: file_id.to_string(),
2074            _delegate: Default::default(),
2075            _additional_params: Default::default(),
2076            _scopes: Default::default(),
2077        }
2078    }
2079
2080    /// Create a builder to help you perform the following task:
2081    ///
2082    /// Deletes a comment.
2083    ///
2084    /// # Arguments
2085    ///
2086    /// * `fileId` - The ID of the file.
2087    /// * `commentId` - The ID of the comment.
2088    pub fn delete(&self, file_id: &str, comment_id: &str) -> CommentDeleteCall<'a, S> {
2089        CommentDeleteCall {
2090            hub: self.hub,
2091            _file_id: file_id.to_string(),
2092            _comment_id: comment_id.to_string(),
2093            _delegate: Default::default(),
2094            _additional_params: Default::default(),
2095            _scopes: Default::default(),
2096        }
2097    }
2098
2099    /// Create a builder to help you perform the following task:
2100    ///
2101    /// Gets a comment by ID.
2102    ///
2103    /// # Arguments
2104    ///
2105    /// * `fileId` - The ID of the file.
2106    /// * `commentId` - The ID of the comment.
2107    pub fn get(&self, file_id: &str, comment_id: &str) -> CommentGetCall<'a, S> {
2108        CommentGetCall {
2109            hub: self.hub,
2110            _file_id: file_id.to_string(),
2111            _comment_id: comment_id.to_string(),
2112            _include_deleted: Default::default(),
2113            _delegate: Default::default(),
2114            _additional_params: Default::default(),
2115            _scopes: Default::default(),
2116        }
2117    }
2118
2119    /// Create a builder to help you perform the following task:
2120    ///
2121    /// Lists a file's comments.
2122    ///
2123    /// # Arguments
2124    ///
2125    /// * `fileId` - The ID of the file.
2126    pub fn list(&self, file_id: &str) -> CommentListCall<'a, S> {
2127        CommentListCall {
2128            hub: self.hub,
2129            _file_id: file_id.to_string(),
2130            _start_modified_time: Default::default(),
2131            _page_token: Default::default(),
2132            _page_size: Default::default(),
2133            _include_deleted: Default::default(),
2134            _delegate: Default::default(),
2135            _additional_params: Default::default(),
2136            _scopes: Default::default(),
2137        }
2138    }
2139
2140    /// Create a builder to help you perform the following task:
2141    ///
2142    /// Updates a comment with patch semantics.
2143    ///
2144    /// # Arguments
2145    ///
2146    /// * `request` - No description provided.
2147    /// * `fileId` - The ID of the file.
2148    /// * `commentId` - The ID of the comment.
2149    pub fn update(
2150        &self,
2151        request: Comment,
2152        file_id: &str,
2153        comment_id: &str,
2154    ) -> CommentUpdateCall<'a, S> {
2155        CommentUpdateCall {
2156            hub: self.hub,
2157            _request: request,
2158            _file_id: file_id.to_string(),
2159            _comment_id: comment_id.to_string(),
2160            _delegate: Default::default(),
2161            _additional_params: Default::default(),
2162            _scopes: Default::default(),
2163        }
2164    }
2165}
2166
2167/// A builder providing access to all methods supported on *drive* resources.
2168/// It is not used directly, but through the `DriveHub` hub.
2169///
2170/// # Example
2171///
2172/// Instantiate a resource builder
2173///
2174/// ```test_harness,no_run
2175/// extern crate hyper;
2176/// extern crate hyper_rustls;
2177/// extern crate google_drive3 as drive3;
2178///
2179/// # async fn dox() {
2180/// use std::default::Default;
2181/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2182///
2183/// let secret: oauth2::ApplicationSecret = Default::default();
2184/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2185///         secret,
2186///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2187///     ).build().await.unwrap();
2188/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2189/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2190/// // like `create(...)`, `delete(...)`, `get(...)`, `hide(...)`, `list(...)`, `unhide(...)` and `update(...)`
2191/// // to build up your call.
2192/// let rb = hub.drives();
2193/// # }
2194/// ```
2195pub struct DriveMethods<'a, S>
2196where
2197    S: 'a,
2198{
2199    hub: &'a DriveHub<S>,
2200}
2201
2202impl<'a, S> client::MethodsBuilder for DriveMethods<'a, S> {}
2203
2204impl<'a, S> DriveMethods<'a, S> {
2205    /// Create a builder to help you perform the following task:
2206    ///
2207    /// Creates a new shared drive.
2208    ///
2209    /// # Arguments
2210    ///
2211    /// * `request` - No description provided.
2212    /// * `requestId` - An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a shared drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same shared drive. If the shared drive already exists a 409 error will be returned.
2213    pub fn create(&self, request: Drive, request_id: &str) -> DriveCreateCall<'a, S> {
2214        DriveCreateCall {
2215            hub: self.hub,
2216            _request: request,
2217            _request_id: request_id.to_string(),
2218            _delegate: Default::default(),
2219            _additional_params: Default::default(),
2220            _scopes: Default::default(),
2221        }
2222    }
2223
2224    /// Create a builder to help you perform the following task:
2225    ///
2226    /// Permanently deletes a shared drive for which the user is an organizer. The shared drive cannot contain any untrashed items.
2227    ///
2228    /// # Arguments
2229    ///
2230    /// * `driveId` - The ID of the shared drive.
2231    pub fn delete(&self, drive_id: &str) -> DriveDeleteCall<'a, S> {
2232        DriveDeleteCall {
2233            hub: self.hub,
2234            _drive_id: drive_id.to_string(),
2235            _delegate: Default::default(),
2236            _additional_params: Default::default(),
2237            _scopes: Default::default(),
2238        }
2239    }
2240
2241    /// Create a builder to help you perform the following task:
2242    ///
2243    /// Gets a shared drive's metadata by ID.
2244    ///
2245    /// # Arguments
2246    ///
2247    /// * `driveId` - The ID of the shared drive.
2248    pub fn get(&self, drive_id: &str) -> DriveGetCall<'a, S> {
2249        DriveGetCall {
2250            hub: self.hub,
2251            _drive_id: drive_id.to_string(),
2252            _use_domain_admin_access: Default::default(),
2253            _delegate: Default::default(),
2254            _additional_params: Default::default(),
2255            _scopes: Default::default(),
2256        }
2257    }
2258
2259    /// Create a builder to help you perform the following task:
2260    ///
2261    /// Hides a shared drive from the default view.
2262    ///
2263    /// # Arguments
2264    ///
2265    /// * `driveId` - The ID of the shared drive.
2266    pub fn hide(&self, drive_id: &str) -> DriveHideCall<'a, S> {
2267        DriveHideCall {
2268            hub: self.hub,
2269            _drive_id: drive_id.to_string(),
2270            _delegate: Default::default(),
2271            _additional_params: Default::default(),
2272            _scopes: Default::default(),
2273        }
2274    }
2275
2276    /// Create a builder to help you perform the following task:
2277    ///
2278    /// Lists the user's shared drives.
2279    pub fn list(&self) -> DriveListCall<'a, S> {
2280        DriveListCall {
2281            hub: self.hub,
2282            _use_domain_admin_access: Default::default(),
2283            _q: Default::default(),
2284            _page_token: Default::default(),
2285            _page_size: Default::default(),
2286            _delegate: Default::default(),
2287            _additional_params: Default::default(),
2288            _scopes: Default::default(),
2289        }
2290    }
2291
2292    /// Create a builder to help you perform the following task:
2293    ///
2294    /// Restores a shared drive to the default view.
2295    ///
2296    /// # Arguments
2297    ///
2298    /// * `driveId` - The ID of the shared drive.
2299    pub fn unhide(&self, drive_id: &str) -> DriveUnhideCall<'a, S> {
2300        DriveUnhideCall {
2301            hub: self.hub,
2302            _drive_id: drive_id.to_string(),
2303            _delegate: Default::default(),
2304            _additional_params: Default::default(),
2305            _scopes: Default::default(),
2306        }
2307    }
2308
2309    /// Create a builder to help you perform the following task:
2310    ///
2311    /// Updates the metadate for a shared drive.
2312    ///
2313    /// # Arguments
2314    ///
2315    /// * `request` - No description provided.
2316    /// * `driveId` - The ID of the shared drive.
2317    pub fn update(&self, request: Drive, drive_id: &str) -> DriveUpdateCall<'a, S> {
2318        DriveUpdateCall {
2319            hub: self.hub,
2320            _request: request,
2321            _drive_id: drive_id.to_string(),
2322            _use_domain_admin_access: Default::default(),
2323            _delegate: Default::default(),
2324            _additional_params: Default::default(),
2325            _scopes: Default::default(),
2326        }
2327    }
2328}
2329
2330/// A builder providing access to all methods supported on *file* resources.
2331/// It is not used directly, but through the `DriveHub` hub.
2332///
2333/// # Example
2334///
2335/// Instantiate a resource builder
2336///
2337/// ```test_harness,no_run
2338/// extern crate hyper;
2339/// extern crate hyper_rustls;
2340/// extern crate google_drive3 as drive3;
2341///
2342/// # async fn dox() {
2343/// use std::default::Default;
2344/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2345///
2346/// let secret: oauth2::ApplicationSecret = Default::default();
2347/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2348///         secret,
2349///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2350///     ).build().await.unwrap();
2351/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2352/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2353/// // like `copy(...)`, `create(...)`, `delete(...)`, `empty_trash(...)`, `export(...)`, `generate_ids(...)`, `get(...)`, `list(...)`, `update(...)` and `watch(...)`
2354/// // to build up your call.
2355/// let rb = hub.files();
2356/// # }
2357/// ```
2358pub struct FileMethods<'a, S>
2359where
2360    S: 'a,
2361{
2362    hub: &'a DriveHub<S>,
2363}
2364
2365impl<'a, S> client::MethodsBuilder for FileMethods<'a, S> {}
2366
2367impl<'a, S> FileMethods<'a, S> {
2368    /// Create a builder to help you perform the following task:
2369    ///
2370    /// Creates a copy of a file and applies any requested updates with patch semantics. Folders cannot be copied.
2371    ///
2372    /// # Arguments
2373    ///
2374    /// * `request` - No description provided.
2375    /// * `fileId` - The ID of the file.
2376    pub fn copy(&self, request: File, file_id: &str) -> FileCopyCall<'a, S> {
2377        FileCopyCall {
2378            hub: self.hub,
2379            _request: request,
2380            _file_id: file_id.to_string(),
2381            _supports_team_drives: Default::default(),
2382            _supports_all_drives: Default::default(),
2383            _ocr_language: Default::default(),
2384            _keep_revision_forever: Default::default(),
2385            _include_permissions_for_view: Default::default(),
2386            _ignore_default_visibility: Default::default(),
2387            _enforce_single_parent: Default::default(),
2388            _delegate: Default::default(),
2389            _additional_params: Default::default(),
2390            _scopes: Default::default(),
2391        }
2392    }
2393
2394    /// Create a builder to help you perform the following task:
2395    ///
2396    /// Creates a new file.
2397    ///
2398    /// # Arguments
2399    ///
2400    /// * `request` - No description provided.
2401    pub fn create(&self, request: File) -> FileCreateCall<'a, S> {
2402        FileCreateCall {
2403            hub: self.hub,
2404            _request: request,
2405            _use_content_as_indexable_text: Default::default(),
2406            _supports_team_drives: Default::default(),
2407            _supports_all_drives: Default::default(),
2408            _ocr_language: Default::default(),
2409            _keep_revision_forever: Default::default(),
2410            _include_permissions_for_view: Default::default(),
2411            _ignore_default_visibility: Default::default(),
2412            _enforce_single_parent: Default::default(),
2413            _delegate: Default::default(),
2414            _additional_params: Default::default(),
2415            _scopes: Default::default(),
2416        }
2417    }
2418
2419    /// Create a builder to help you perform the following task:
2420    ///
2421    /// Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive the user must be an organizer on the parent. If the target is a folder, all descendants owned by the user are also deleted.
2422    ///
2423    /// # Arguments
2424    ///
2425    /// * `fileId` - The ID of the file.
2426    pub fn delete(&self, file_id: &str) -> FileDeleteCall<'a, S> {
2427        FileDeleteCall {
2428            hub: self.hub,
2429            _file_id: file_id.to_string(),
2430            _supports_team_drives: Default::default(),
2431            _supports_all_drives: Default::default(),
2432            _enforce_single_parent: Default::default(),
2433            _delegate: Default::default(),
2434            _additional_params: Default::default(),
2435            _scopes: Default::default(),
2436        }
2437    }
2438
2439    /// Create a builder to help you perform the following task:
2440    ///
2441    /// Permanently deletes all of the user's trashed files.
2442    pub fn empty_trash(&self) -> FileEmptyTrashCall<'a, S> {
2443        FileEmptyTrashCall {
2444            hub: self.hub,
2445            _enforce_single_parent: Default::default(),
2446            _delegate: Default::default(),
2447            _additional_params: Default::default(),
2448            _scopes: Default::default(),
2449        }
2450    }
2451
2452    /// Create a builder to help you perform the following task:
2453    ///
2454    /// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB.
2455    ///
2456    /// # Arguments
2457    ///
2458    /// * `fileId` - The ID of the file.
2459    /// * `mimeType` - The MIME type of the format requested for this export.
2460    pub fn export(&self, file_id: &str, mime_type: &str) -> FileExportCall<'a, S> {
2461        FileExportCall {
2462            hub: self.hub,
2463            _file_id: file_id.to_string(),
2464            _mime_type: mime_type.to_string(),
2465            _delegate: Default::default(),
2466            _additional_params: Default::default(),
2467            _scopes: Default::default(),
2468        }
2469    }
2470
2471    /// Create a builder to help you perform the following task:
2472    ///
2473    /// Generates a set of file IDs which can be provided in create or copy requests.
2474    pub fn generate_ids(&self) -> FileGenerateIdCall<'a, S> {
2475        FileGenerateIdCall {
2476            hub: self.hub,
2477            _type_: Default::default(),
2478            _space: Default::default(),
2479            _count: Default::default(),
2480            _delegate: Default::default(),
2481            _additional_params: Default::default(),
2482            _scopes: Default::default(),
2483        }
2484    }
2485
2486    /// Create a builder to help you perform the following task:
2487    ///
2488    /// Gets a file's metadata or content by ID.
2489    ///
2490    /// # Arguments
2491    ///
2492    /// * `fileId` - The ID of the file.
2493    pub fn get(&self, file_id: &str) -> FileGetCall<'a, S> {
2494        FileGetCall {
2495            hub: self.hub,
2496            _file_id: file_id.to_string(),
2497            _supports_team_drives: Default::default(),
2498            _supports_all_drives: Default::default(),
2499            _include_permissions_for_view: Default::default(),
2500            _acknowledge_abuse: Default::default(),
2501            _delegate: Default::default(),
2502            _additional_params: Default::default(),
2503            _scopes: Default::default(),
2504            _range: Default::default(),
2505        }
2506    }
2507
2508    /// Create a builder to help you perform the following task:
2509    ///
2510    /// Lists or searches files.
2511    pub fn list(&self) -> FileListCall<'a, S> {
2512        FileListCall {
2513            hub: self.hub,
2514            _team_drive_id: Default::default(),
2515            _supports_team_drives: Default::default(),
2516            _supports_all_drives: Default::default(),
2517            _spaces: Default::default(),
2518            _q: Default::default(),
2519            _page_token: Default::default(),
2520            _page_size: Default::default(),
2521            _order_by: Default::default(),
2522            _include_team_drive_items: Default::default(),
2523            _include_permissions_for_view: Default::default(),
2524            _include_items_from_all_drives: Default::default(),
2525            _drive_id: Default::default(),
2526            _corpus: Default::default(),
2527            _corpora: Default::default(),
2528            _delegate: Default::default(),
2529            _additional_params: Default::default(),
2530            _scopes: Default::default(),
2531        }
2532    }
2533
2534    /// Create a builder to help you perform the following task:
2535    ///
2536    /// Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might change automatically, such as modifiedDate. This method supports patch semantics.
2537    ///
2538    /// # Arguments
2539    ///
2540    /// * `request` - No description provided.
2541    /// * `fileId` - The ID of the file.
2542    pub fn update(&self, request: File, file_id: &str) -> FileUpdateCall<'a, S> {
2543        FileUpdateCall {
2544            hub: self.hub,
2545            _request: request,
2546            _file_id: file_id.to_string(),
2547            _use_content_as_indexable_text: Default::default(),
2548            _supports_team_drives: Default::default(),
2549            _supports_all_drives: Default::default(),
2550            _remove_parents: Default::default(),
2551            _ocr_language: Default::default(),
2552            _keep_revision_forever: Default::default(),
2553            _include_permissions_for_view: Default::default(),
2554            _enforce_single_parent: Default::default(),
2555            _add_parents: Default::default(),
2556            _delegate: Default::default(),
2557            _additional_params: Default::default(),
2558            _scopes: Default::default(),
2559        }
2560    }
2561
2562    /// Create a builder to help you perform the following task:
2563    ///
2564    /// Subscribes to changes to a file. While you can establish a channel forchanges to a file on a shared drive, a change to a shared drive file won't create a notification.
2565    ///
2566    /// # Arguments
2567    ///
2568    /// * `request` - No description provided.
2569    /// * `fileId` - The ID of the file.
2570    pub fn watch(&self, request: Channel, file_id: &str) -> FileWatchCall<'a, S> {
2571        FileWatchCall {
2572            hub: self.hub,
2573            _request: request,
2574            _file_id: file_id.to_string(),
2575            _supports_team_drives: Default::default(),
2576            _supports_all_drives: Default::default(),
2577            _include_permissions_for_view: Default::default(),
2578            _acknowledge_abuse: Default::default(),
2579            _delegate: Default::default(),
2580            _additional_params: Default::default(),
2581            _scopes: Default::default(),
2582        }
2583    }
2584}
2585
2586/// A builder providing access to all methods supported on *permission* resources.
2587/// It is not used directly, but through the `DriveHub` hub.
2588///
2589/// # Example
2590///
2591/// Instantiate a resource builder
2592///
2593/// ```test_harness,no_run
2594/// extern crate hyper;
2595/// extern crate hyper_rustls;
2596/// extern crate google_drive3 as drive3;
2597///
2598/// # async fn dox() {
2599/// use std::default::Default;
2600/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2601///
2602/// let secret: oauth2::ApplicationSecret = Default::default();
2603/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2604///         secret,
2605///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2606///     ).build().await.unwrap();
2607/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2608/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2609/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
2610/// // to build up your call.
2611/// let rb = hub.permissions();
2612/// # }
2613/// ```
2614pub struct PermissionMethods<'a, S>
2615where
2616    S: 'a,
2617{
2618    hub: &'a DriveHub<S>,
2619}
2620
2621impl<'a, S> client::MethodsBuilder for PermissionMethods<'a, S> {}
2622
2623impl<'a, S> PermissionMethods<'a, S> {
2624    /// Create a builder to help you perform the following task:
2625    ///
2626    /// Creates a permission for a file or shared drive.
2627    ///
2628    /// # Arguments
2629    ///
2630    /// * `request` - No description provided.
2631    /// * `fileId` - The ID of the file or shared drive.
2632    pub fn create(&self, request: Permission, file_id: &str) -> PermissionCreateCall<'a, S> {
2633        PermissionCreateCall {
2634            hub: self.hub,
2635            _request: request,
2636            _file_id: file_id.to_string(),
2637            _use_domain_admin_access: Default::default(),
2638            _transfer_ownership: Default::default(),
2639            _supports_team_drives: Default::default(),
2640            _supports_all_drives: Default::default(),
2641            _send_notification_email: Default::default(),
2642            _move_to_new_owners_root: Default::default(),
2643            _enforce_single_parent: Default::default(),
2644            _email_message: Default::default(),
2645            _delegate: Default::default(),
2646            _additional_params: Default::default(),
2647            _scopes: Default::default(),
2648        }
2649    }
2650
2651    /// Create a builder to help you perform the following task:
2652    ///
2653    /// Deletes a permission.
2654    ///
2655    /// # Arguments
2656    ///
2657    /// * `fileId` - The ID of the file or shared drive.
2658    /// * `permissionId` - The ID of the permission.
2659    pub fn delete(&self, file_id: &str, permission_id: &str) -> PermissionDeleteCall<'a, S> {
2660        PermissionDeleteCall {
2661            hub: self.hub,
2662            _file_id: file_id.to_string(),
2663            _permission_id: permission_id.to_string(),
2664            _use_domain_admin_access: Default::default(),
2665            _supports_team_drives: Default::default(),
2666            _supports_all_drives: Default::default(),
2667            _delegate: Default::default(),
2668            _additional_params: Default::default(),
2669            _scopes: Default::default(),
2670        }
2671    }
2672
2673    /// Create a builder to help you perform the following task:
2674    ///
2675    /// Gets a permission by ID.
2676    ///
2677    /// # Arguments
2678    ///
2679    /// * `fileId` - The ID of the file.
2680    /// * `permissionId` - The ID of the permission.
2681    pub fn get(&self, file_id: &str, permission_id: &str) -> PermissionGetCall<'a, S> {
2682        PermissionGetCall {
2683            hub: self.hub,
2684            _file_id: file_id.to_string(),
2685            _permission_id: permission_id.to_string(),
2686            _use_domain_admin_access: Default::default(),
2687            _supports_team_drives: Default::default(),
2688            _supports_all_drives: Default::default(),
2689            _delegate: Default::default(),
2690            _additional_params: Default::default(),
2691            _scopes: Default::default(),
2692        }
2693    }
2694
2695    /// Create a builder to help you perform the following task:
2696    ///
2697    /// Lists a file's or shared drive's permissions.
2698    ///
2699    /// # Arguments
2700    ///
2701    /// * `fileId` - The ID of the file or shared drive.
2702    pub fn list(&self, file_id: &str) -> PermissionListCall<'a, S> {
2703        PermissionListCall {
2704            hub: self.hub,
2705            _file_id: file_id.to_string(),
2706            _use_domain_admin_access: Default::default(),
2707            _supports_team_drives: Default::default(),
2708            _supports_all_drives: Default::default(),
2709            _page_token: Default::default(),
2710            _page_size: Default::default(),
2711            _include_permissions_for_view: Default::default(),
2712            _delegate: Default::default(),
2713            _additional_params: Default::default(),
2714            _scopes: Default::default(),
2715        }
2716    }
2717
2718    /// Create a builder to help you perform the following task:
2719    ///
2720    /// Updates a permission with patch semantics.
2721    ///
2722    /// # Arguments
2723    ///
2724    /// * `request` - No description provided.
2725    /// * `fileId` - The ID of the file or shared drive.
2726    /// * `permissionId` - The ID of the permission.
2727    pub fn update(
2728        &self,
2729        request: Permission,
2730        file_id: &str,
2731        permission_id: &str,
2732    ) -> PermissionUpdateCall<'a, S> {
2733        PermissionUpdateCall {
2734            hub: self.hub,
2735            _request: request,
2736            _file_id: file_id.to_string(),
2737            _permission_id: permission_id.to_string(),
2738            _use_domain_admin_access: Default::default(),
2739            _transfer_ownership: Default::default(),
2740            _supports_team_drives: Default::default(),
2741            _supports_all_drives: Default::default(),
2742            _remove_expiration: Default::default(),
2743            _delegate: Default::default(),
2744            _additional_params: Default::default(),
2745            _scopes: Default::default(),
2746        }
2747    }
2748}
2749
2750/// A builder providing access to all methods supported on *reply* resources.
2751/// It is not used directly, but through the `DriveHub` hub.
2752///
2753/// # Example
2754///
2755/// Instantiate a resource builder
2756///
2757/// ```test_harness,no_run
2758/// extern crate hyper;
2759/// extern crate hyper_rustls;
2760/// extern crate google_drive3 as drive3;
2761///
2762/// # async fn dox() {
2763/// use std::default::Default;
2764/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2765///
2766/// let secret: oauth2::ApplicationSecret = Default::default();
2767/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2768///         secret,
2769///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2770///     ).build().await.unwrap();
2771/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2772/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2773/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
2774/// // to build up your call.
2775/// let rb = hub.replies();
2776/// # }
2777/// ```
2778pub struct ReplyMethods<'a, S>
2779where
2780    S: 'a,
2781{
2782    hub: &'a DriveHub<S>,
2783}
2784
2785impl<'a, S> client::MethodsBuilder for ReplyMethods<'a, S> {}
2786
2787impl<'a, S> ReplyMethods<'a, S> {
2788    /// Create a builder to help you perform the following task:
2789    ///
2790    /// Creates a new reply to a comment.
2791    ///
2792    /// # Arguments
2793    ///
2794    /// * `request` - No description provided.
2795    /// * `fileId` - The ID of the file.
2796    /// * `commentId` - The ID of the comment.
2797    pub fn create(
2798        &self,
2799        request: Reply,
2800        file_id: &str,
2801        comment_id: &str,
2802    ) -> ReplyCreateCall<'a, S> {
2803        ReplyCreateCall {
2804            hub: self.hub,
2805            _request: request,
2806            _file_id: file_id.to_string(),
2807            _comment_id: comment_id.to_string(),
2808            _delegate: Default::default(),
2809            _additional_params: Default::default(),
2810            _scopes: Default::default(),
2811        }
2812    }
2813
2814    /// Create a builder to help you perform the following task:
2815    ///
2816    /// Deletes a reply.
2817    ///
2818    /// # Arguments
2819    ///
2820    /// * `fileId` - The ID of the file.
2821    /// * `commentId` - The ID of the comment.
2822    /// * `replyId` - The ID of the reply.
2823    pub fn delete(
2824        &self,
2825        file_id: &str,
2826        comment_id: &str,
2827        reply_id: &str,
2828    ) -> ReplyDeleteCall<'a, S> {
2829        ReplyDeleteCall {
2830            hub: self.hub,
2831            _file_id: file_id.to_string(),
2832            _comment_id: comment_id.to_string(),
2833            _reply_id: reply_id.to_string(),
2834            _delegate: Default::default(),
2835            _additional_params: Default::default(),
2836            _scopes: Default::default(),
2837        }
2838    }
2839
2840    /// Create a builder to help you perform the following task:
2841    ///
2842    /// Gets a reply by ID.
2843    ///
2844    /// # Arguments
2845    ///
2846    /// * `fileId` - The ID of the file.
2847    /// * `commentId` - The ID of the comment.
2848    /// * `replyId` - The ID of the reply.
2849    pub fn get(&self, file_id: &str, comment_id: &str, reply_id: &str) -> ReplyGetCall<'a, S> {
2850        ReplyGetCall {
2851            hub: self.hub,
2852            _file_id: file_id.to_string(),
2853            _comment_id: comment_id.to_string(),
2854            _reply_id: reply_id.to_string(),
2855            _include_deleted: Default::default(),
2856            _delegate: Default::default(),
2857            _additional_params: Default::default(),
2858            _scopes: Default::default(),
2859        }
2860    }
2861
2862    /// Create a builder to help you perform the following task:
2863    ///
2864    /// Lists a comment's replies.
2865    ///
2866    /// # Arguments
2867    ///
2868    /// * `fileId` - The ID of the file.
2869    /// * `commentId` - The ID of the comment.
2870    pub fn list(&self, file_id: &str, comment_id: &str) -> ReplyListCall<'a, S> {
2871        ReplyListCall {
2872            hub: self.hub,
2873            _file_id: file_id.to_string(),
2874            _comment_id: comment_id.to_string(),
2875            _page_token: Default::default(),
2876            _page_size: Default::default(),
2877            _include_deleted: Default::default(),
2878            _delegate: Default::default(),
2879            _additional_params: Default::default(),
2880            _scopes: Default::default(),
2881        }
2882    }
2883
2884    /// Create a builder to help you perform the following task:
2885    ///
2886    /// Updates a reply with patch semantics.
2887    ///
2888    /// # Arguments
2889    ///
2890    /// * `request` - No description provided.
2891    /// * `fileId` - The ID of the file.
2892    /// * `commentId` - The ID of the comment.
2893    /// * `replyId` - The ID of the reply.
2894    pub fn update(
2895        &self,
2896        request: Reply,
2897        file_id: &str,
2898        comment_id: &str,
2899        reply_id: &str,
2900    ) -> ReplyUpdateCall<'a, S> {
2901        ReplyUpdateCall {
2902            hub: self.hub,
2903            _request: request,
2904            _file_id: file_id.to_string(),
2905            _comment_id: comment_id.to_string(),
2906            _reply_id: reply_id.to_string(),
2907            _delegate: Default::default(),
2908            _additional_params: Default::default(),
2909            _scopes: Default::default(),
2910        }
2911    }
2912}
2913
2914/// A builder providing access to all methods supported on *revision* resources.
2915/// It is not used directly, but through the `DriveHub` hub.
2916///
2917/// # Example
2918///
2919/// Instantiate a resource builder
2920///
2921/// ```test_harness,no_run
2922/// extern crate hyper;
2923/// extern crate hyper_rustls;
2924/// extern crate google_drive3 as drive3;
2925///
2926/// # async fn dox() {
2927/// use std::default::Default;
2928/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
2929///
2930/// let secret: oauth2::ApplicationSecret = Default::default();
2931/// let auth = oauth2::InstalledFlowAuthenticator::builder(
2932///         secret,
2933///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2934///     ).build().await.unwrap();
2935/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
2936/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2937/// // like `delete(...)`, `get(...)`, `list(...)` and `update(...)`
2938/// // to build up your call.
2939/// let rb = hub.revisions();
2940/// # }
2941/// ```
2942pub struct RevisionMethods<'a, S>
2943where
2944    S: 'a,
2945{
2946    hub: &'a DriveHub<S>,
2947}
2948
2949impl<'a, S> client::MethodsBuilder for RevisionMethods<'a, S> {}
2950
2951impl<'a, S> RevisionMethods<'a, S> {
2952    /// Create a builder to help you perform the following task:
2953    ///
2954    /// Permanently deletes a file version. You can only delete revisions for files with binary content in Google Drive, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted.
2955    ///
2956    /// # Arguments
2957    ///
2958    /// * `fileId` - The ID of the file.
2959    /// * `revisionId` - The ID of the revision.
2960    pub fn delete(&self, file_id: &str, revision_id: &str) -> RevisionDeleteCall<'a, S> {
2961        RevisionDeleteCall {
2962            hub: self.hub,
2963            _file_id: file_id.to_string(),
2964            _revision_id: revision_id.to_string(),
2965            _delegate: Default::default(),
2966            _additional_params: Default::default(),
2967            _scopes: Default::default(),
2968        }
2969    }
2970
2971    /// Create a builder to help you perform the following task:
2972    ///
2973    /// Gets a revision's metadata or content by ID.
2974    ///
2975    /// # Arguments
2976    ///
2977    /// * `fileId` - The ID of the file.
2978    /// * `revisionId` - The ID of the revision.
2979    pub fn get(&self, file_id: &str, revision_id: &str) -> RevisionGetCall<'a, S> {
2980        RevisionGetCall {
2981            hub: self.hub,
2982            _file_id: file_id.to_string(),
2983            _revision_id: revision_id.to_string(),
2984            _acknowledge_abuse: Default::default(),
2985            _delegate: Default::default(),
2986            _additional_params: Default::default(),
2987            _scopes: Default::default(),
2988        }
2989    }
2990
2991    /// Create a builder to help you perform the following task:
2992    ///
2993    /// Lists a file's revisions.
2994    ///
2995    /// # Arguments
2996    ///
2997    /// * `fileId` - The ID of the file.
2998    pub fn list(&self, file_id: &str) -> RevisionListCall<'a, S> {
2999        RevisionListCall {
3000            hub: self.hub,
3001            _file_id: file_id.to_string(),
3002            _page_token: Default::default(),
3003            _page_size: Default::default(),
3004            _delegate: Default::default(),
3005            _additional_params: Default::default(),
3006            _scopes: Default::default(),
3007        }
3008    }
3009
3010    /// Create a builder to help you perform the following task:
3011    ///
3012    /// Updates a revision with patch semantics.
3013    ///
3014    /// # Arguments
3015    ///
3016    /// * `request` - No description provided.
3017    /// * `fileId` - The ID of the file.
3018    /// * `revisionId` - The ID of the revision.
3019    pub fn update(
3020        &self,
3021        request: Revision,
3022        file_id: &str,
3023        revision_id: &str,
3024    ) -> RevisionUpdateCall<'a, S> {
3025        RevisionUpdateCall {
3026            hub: self.hub,
3027            _request: request,
3028            _file_id: file_id.to_string(),
3029            _revision_id: revision_id.to_string(),
3030            _delegate: Default::default(),
3031            _additional_params: Default::default(),
3032            _scopes: Default::default(),
3033        }
3034    }
3035}
3036
3037/// A builder providing access to all methods supported on *teamdrive* resources.
3038/// It is not used directly, but through the `DriveHub` hub.
3039///
3040/// # Example
3041///
3042/// Instantiate a resource builder
3043///
3044/// ```test_harness,no_run
3045/// extern crate hyper;
3046/// extern crate hyper_rustls;
3047/// extern crate google_drive3 as drive3;
3048///
3049/// # async fn dox() {
3050/// use std::default::Default;
3051/// use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
3052///
3053/// let secret: oauth2::ApplicationSecret = Default::default();
3054/// let auth = oauth2::InstalledFlowAuthenticator::builder(
3055///         secret,
3056///         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3057///     ).build().await.unwrap();
3058/// let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
3059/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3060/// // like `create(...)`, `delete(...)`, `get(...)`, `list(...)` and `update(...)`
3061/// // to build up your call.
3062/// let rb = hub.teamdrives();
3063/// # }
3064/// ```
3065pub struct TeamdriveMethods<'a, S>
3066where
3067    S: 'a,
3068{
3069    hub: &'a DriveHub<S>,
3070}
3071
3072impl<'a, S> client::MethodsBuilder for TeamdriveMethods<'a, S> {}
3073
3074impl<'a, S> TeamdriveMethods<'a, S> {
3075    /// Create a builder to help you perform the following task:
3076    ///
3077    /// Deprecated use drives.create instead.
3078    ///
3079    /// # Arguments
3080    ///
3081    /// * `request` - No description provided.
3082    /// * `requestId` - An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a Team Drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same Team Drive. If the Team Drive already exists a 409 error will be returned.
3083    pub fn create(&self, request: TeamDrive, request_id: &str) -> TeamdriveCreateCall<'a, S> {
3084        TeamdriveCreateCall {
3085            hub: self.hub,
3086            _request: request,
3087            _request_id: request_id.to_string(),
3088            _delegate: Default::default(),
3089            _additional_params: Default::default(),
3090            _scopes: Default::default(),
3091        }
3092    }
3093
3094    /// Create a builder to help you perform the following task:
3095    ///
3096    /// Deprecated use drives.delete instead.
3097    ///
3098    /// # Arguments
3099    ///
3100    /// * `teamDriveId` - The ID of the Team Drive
3101    pub fn delete(&self, team_drive_id: &str) -> TeamdriveDeleteCall<'a, S> {
3102        TeamdriveDeleteCall {
3103            hub: self.hub,
3104            _team_drive_id: team_drive_id.to_string(),
3105            _delegate: Default::default(),
3106            _additional_params: Default::default(),
3107            _scopes: Default::default(),
3108        }
3109    }
3110
3111    /// Create a builder to help you perform the following task:
3112    ///
3113    /// Deprecated use drives.get instead.
3114    ///
3115    /// # Arguments
3116    ///
3117    /// * `teamDriveId` - The ID of the Team Drive
3118    pub fn get(&self, team_drive_id: &str) -> TeamdriveGetCall<'a, S> {
3119        TeamdriveGetCall {
3120            hub: self.hub,
3121            _team_drive_id: team_drive_id.to_string(),
3122            _use_domain_admin_access: Default::default(),
3123            _delegate: Default::default(),
3124            _additional_params: Default::default(),
3125            _scopes: Default::default(),
3126        }
3127    }
3128
3129    /// Create a builder to help you perform the following task:
3130    ///
3131    /// Deprecated use drives.list instead.
3132    pub fn list(&self) -> TeamdriveListCall<'a, S> {
3133        TeamdriveListCall {
3134            hub: self.hub,
3135            _use_domain_admin_access: Default::default(),
3136            _q: Default::default(),
3137            _page_token: Default::default(),
3138            _page_size: Default::default(),
3139            _delegate: Default::default(),
3140            _additional_params: Default::default(),
3141            _scopes: Default::default(),
3142        }
3143    }
3144
3145    /// Create a builder to help you perform the following task:
3146    ///
3147    /// Deprecated use drives.update instead
3148    ///
3149    /// # Arguments
3150    ///
3151    /// * `request` - No description provided.
3152    /// * `teamDriveId` - The ID of the Team Drive
3153    pub fn update(&self, request: TeamDrive, team_drive_id: &str) -> TeamdriveUpdateCall<'a, S> {
3154        TeamdriveUpdateCall {
3155            hub: self.hub,
3156            _request: request,
3157            _team_drive_id: team_drive_id.to_string(),
3158            _use_domain_admin_access: Default::default(),
3159            _delegate: Default::default(),
3160            _additional_params: Default::default(),
3161            _scopes: Default::default(),
3162        }
3163    }
3164}
3165
3166// ###################
3167// CallBuilders   ###
3168// #################
3169
3170/// Gets information about the user, the user's Drive, and system capabilities.
3171///
3172/// A builder for the *get* method supported by a *about* resource.
3173/// It is not used directly, but through a `AboutMethods` instance.
3174///
3175/// # Example
3176///
3177/// Instantiate a resource method builder
3178///
3179/// ```test_harness,no_run
3180/// # extern crate hyper;
3181/// # extern crate hyper_rustls;
3182/// # extern crate google_drive3 as drive3;
3183/// # async fn dox() {
3184/// # use std::default::Default;
3185/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
3186///
3187/// # let secret: oauth2::ApplicationSecret = Default::default();
3188/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3189/// #         secret,
3190/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3191/// #     ).build().await.unwrap();
3192/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
3193/// // You can configure optional parameters by calling the respective setters at will, and
3194/// // execute the final call using `doit()`.
3195/// // Values shown here are possibly random and not representative !
3196/// let result = hub.about().get()
3197///              .doit().await;
3198/// # }
3199/// ```
3200pub struct AboutGetCall<'a, S>
3201where
3202    S: 'a,
3203{
3204    hub: &'a DriveHub<S>,
3205    _delegate: Option<&'a mut dyn client::Delegate>,
3206    _additional_params: HashMap<String, String>,
3207    _scopes: BTreeMap<String, ()>,
3208}
3209
3210impl<'a, S> client::CallBuilder for AboutGetCall<'a, S> {}
3211
3212impl<'a, S> AboutGetCall<'a, S>
3213where
3214    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
3215    S::Response:
3216        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3217    S::Future: Send + Unpin + 'static,
3218    S::Error: Into<Box<dyn StdError + Send + Sync>>,
3219{
3220    /// Perform the operation you have build so far.
3221    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, About)> {
3222        use client::ToParts;
3223        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3224        use std::io::{Read, Seek};
3225        let mut dd = client::DefaultDelegate;
3226        let mut dlg: &mut dyn client::Delegate = match self._delegate {
3227            Some(d) => d,
3228            None => &mut dd,
3229        };
3230        dlg.begin(client::MethodInfo {
3231            id: "drive.about.get",
3232            http_method: hyper::Method::GET,
3233        });
3234        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
3235        for &field in ["alt"].iter() {
3236            if self._additional_params.contains_key(field) {
3237                dlg.finished(false);
3238                return Err(client::Error::FieldClash(field));
3239            }
3240        }
3241        for (name, value) in self._additional_params.iter() {
3242            params.push((&name, value.clone()));
3243        }
3244
3245        params.push(("alt", "json".to_string()));
3246
3247        let mut url = self.hub._base_url.clone() + "about";
3248        if self._scopes.len() == 0 {
3249            self._scopes
3250                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
3251        }
3252
3253        let url = url::Url::parse_with_params(&url, params).unwrap();
3254
3255        loop {
3256            let token = match self
3257                .hub
3258                .auth
3259                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
3260                .await
3261            {
3262                Ok(token) => token.clone(),
3263                Err(err) => match dlg.token(&err) {
3264                    Some(token) => token,
3265                    None => {
3266                        dlg.finished(false);
3267                        return Err(client::Error::MissingToken(err));
3268                    }
3269                },
3270            };
3271            let mut req_result = {
3272                let client = &self.hub.client;
3273                dlg.pre_request();
3274                let mut req_builder = hyper::Request::builder()
3275                    .method(hyper::Method::GET)
3276                    .uri(url.clone().into_string())
3277                    .header(USER_AGENT, self.hub._user_agent.clone())
3278                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
3279
3280                let request = req_builder.body(hyper::body::Body::empty());
3281
3282                client.request(request.unwrap()).await
3283            };
3284
3285            match req_result {
3286                Err(err) => {
3287                    if let client::Retry::After(d) = dlg.http_error(&err) {
3288                        sleep(d);
3289                        continue;
3290                    }
3291                    dlg.finished(false);
3292                    return Err(client::Error::HttpError(err));
3293                }
3294                Ok(mut res) => {
3295                    if !res.status().is_success() {
3296                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3297                        let (parts, _) = res.into_parts();
3298                        let body = hyper::Body::from(res_body_string.clone());
3299                        let restored_response = hyper::Response::from_parts(parts, body);
3300
3301                        let server_response =
3302                            json::from_str::<serde_json::Value>(&res_body_string).ok();
3303
3304                        if let client::Retry::After(d) =
3305                            dlg.http_failure(&restored_response, server_response.clone())
3306                        {
3307                            sleep(d);
3308                            continue;
3309                        }
3310
3311                        dlg.finished(false);
3312
3313                        return match server_response {
3314                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
3315                            None => Err(client::Error::Failure(restored_response)),
3316                        };
3317                    }
3318                    let result_value = {
3319                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3320
3321                        match json::from_str(&res_body_string) {
3322                            Ok(decoded) => (res, decoded),
3323                            Err(err) => {
3324                                dlg.response_json_decode_error(&res_body_string, &err);
3325                                return Err(client::Error::JsonDecodeError(res_body_string, err));
3326                            }
3327                        }
3328                    };
3329
3330                    dlg.finished(true);
3331                    return Ok(result_value);
3332                }
3333            }
3334        }
3335    }
3336
3337    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3338    /// while executing the actual API request.
3339    ///
3340    /// It should be used to handle progress information, and to implement a certain level of resilience.
3341    ///
3342    /// Sets the *delegate* property to the given value.
3343    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> AboutGetCall<'a, S> {
3344        self._delegate = Some(new_value);
3345        self
3346    }
3347
3348    /// Set any additional parameter of the query string used in the request.
3349    /// It should be used to set parameters which are not yet available through their own
3350    /// setters.
3351    ///
3352    /// Please note that this method must not be used to set any of the known parameters
3353    /// which have their own setter method. If done anyway, the request will fail.
3354    ///
3355    /// # Additional Parameters
3356    ///
3357    /// * *alt* (query-string) - Data format for the response.
3358    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3359    /// * *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.
3360    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3361    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3362    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3363    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3364    pub fn param<T>(mut self, name: T, value: T) -> AboutGetCall<'a, S>
3365    where
3366        T: AsRef<str>,
3367    {
3368        self._additional_params
3369            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3370        self
3371    }
3372
3373    /// Identifies the authorization scope for the method you are building.
3374    ///
3375    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
3376    /// `Scope::MetadataReadonly`.
3377    ///
3378    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3379    /// tokens for more than one scope.
3380    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
3381    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
3382    /// function for details).
3383    ///
3384    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3385    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3386    /// sufficient, a read-write scope will do as well.
3387    pub fn add_scope<T, St>(mut self, scope: T) -> AboutGetCall<'a, S>
3388    where
3389        T: Into<Option<St>>,
3390        St: AsRef<str>,
3391    {
3392        match scope.into() {
3393            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
3394            None => None,
3395        };
3396        self
3397    }
3398}
3399
3400/// Gets the starting pageToken for listing future changes.
3401///
3402/// A builder for the *getStartPageToken* method supported by a *change* resource.
3403/// It is not used directly, but through a `ChangeMethods` instance.
3404///
3405/// # Example
3406///
3407/// Instantiate a resource method builder
3408///
3409/// ```test_harness,no_run
3410/// # extern crate hyper;
3411/// # extern crate hyper_rustls;
3412/// # extern crate google_drive3 as drive3;
3413/// # async fn dox() {
3414/// # use std::default::Default;
3415/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
3416///
3417/// # let secret: oauth2::ApplicationSecret = Default::default();
3418/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3419/// #         secret,
3420/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3421/// #     ).build().await.unwrap();
3422/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
3423/// // You can configure optional parameters by calling the respective setters at will, and
3424/// // execute the final call using `doit()`.
3425/// // Values shown here are possibly random and not representative !
3426/// let result = hub.changes().get_start_page_token()
3427///              .team_drive_id("duo")
3428///              .supports_team_drives(false)
3429///              .supports_all_drives(false)
3430///              .drive_id("dolor")
3431///              .doit().await;
3432/// # }
3433/// ```
3434pub struct ChangeGetStartPageTokenCall<'a, S>
3435where
3436    S: 'a,
3437{
3438    hub: &'a DriveHub<S>,
3439    _team_drive_id: Option<String>,
3440    _supports_team_drives: Option<bool>,
3441    _supports_all_drives: Option<bool>,
3442    _drive_id: Option<String>,
3443    _delegate: Option<&'a mut dyn client::Delegate>,
3444    _additional_params: HashMap<String, String>,
3445    _scopes: BTreeMap<String, ()>,
3446}
3447
3448impl<'a, S> client::CallBuilder for ChangeGetStartPageTokenCall<'a, S> {}
3449
3450impl<'a, S> ChangeGetStartPageTokenCall<'a, S>
3451where
3452    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
3453    S::Response:
3454        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3455    S::Future: Send + Unpin + 'static,
3456    S::Error: Into<Box<dyn StdError + Send + Sync>>,
3457{
3458    /// Perform the operation you have build so far.
3459    pub async fn doit(
3460        mut self,
3461    ) -> client::Result<(hyper::Response<hyper::body::Body>, StartPageToken)> {
3462        use client::ToParts;
3463        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3464        use std::io::{Read, Seek};
3465        let mut dd = client::DefaultDelegate;
3466        let mut dlg: &mut dyn client::Delegate = match self._delegate {
3467            Some(d) => d,
3468            None => &mut dd,
3469        };
3470        dlg.begin(client::MethodInfo {
3471            id: "drive.changes.getStartPageToken",
3472            http_method: hyper::Method::GET,
3473        });
3474        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
3475        if let Some(value) = self._team_drive_id {
3476            params.push(("teamDriveId", value.to_string()));
3477        }
3478        if let Some(value) = self._supports_team_drives {
3479            params.push(("supportsTeamDrives", value.to_string()));
3480        }
3481        if let Some(value) = self._supports_all_drives {
3482            params.push(("supportsAllDrives", value.to_string()));
3483        }
3484        if let Some(value) = self._drive_id {
3485            params.push(("driveId", value.to_string()));
3486        }
3487        for &field in [
3488            "alt",
3489            "teamDriveId",
3490            "supportsTeamDrives",
3491            "supportsAllDrives",
3492            "driveId",
3493        ]
3494        .iter()
3495        {
3496            if self._additional_params.contains_key(field) {
3497                dlg.finished(false);
3498                return Err(client::Error::FieldClash(field));
3499            }
3500        }
3501        for (name, value) in self._additional_params.iter() {
3502            params.push((&name, value.clone()));
3503        }
3504
3505        params.push(("alt", "json".to_string()));
3506
3507        let mut url = self.hub._base_url.clone() + "changes/startPageToken";
3508        if self._scopes.len() == 0 {
3509            self._scopes
3510                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
3511        }
3512
3513        let url = url::Url::parse_with_params(&url, params).unwrap();
3514
3515        loop {
3516            let token = match self
3517                .hub
3518                .auth
3519                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
3520                .await
3521            {
3522                Ok(token) => token.clone(),
3523                Err(err) => match dlg.token(&err) {
3524                    Some(token) => token,
3525                    None => {
3526                        dlg.finished(false);
3527                        return Err(client::Error::MissingToken(err));
3528                    }
3529                },
3530            };
3531            let mut req_result = {
3532                let client = &self.hub.client;
3533                dlg.pre_request();
3534                let mut req_builder = hyper::Request::builder()
3535                    .method(hyper::Method::GET)
3536                    .uri(url.clone().into_string())
3537                    .header(USER_AGENT, self.hub._user_agent.clone())
3538                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
3539
3540                let request = req_builder.body(hyper::body::Body::empty());
3541
3542                client.request(request.unwrap()).await
3543            };
3544
3545            match req_result {
3546                Err(err) => {
3547                    if let client::Retry::After(d) = dlg.http_error(&err) {
3548                        sleep(d);
3549                        continue;
3550                    }
3551                    dlg.finished(false);
3552                    return Err(client::Error::HttpError(err));
3553                }
3554                Ok(mut res) => {
3555                    if !res.status().is_success() {
3556                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3557                        let (parts, _) = res.into_parts();
3558                        let body = hyper::Body::from(res_body_string.clone());
3559                        let restored_response = hyper::Response::from_parts(parts, body);
3560
3561                        let server_response =
3562                            json::from_str::<serde_json::Value>(&res_body_string).ok();
3563
3564                        if let client::Retry::After(d) =
3565                            dlg.http_failure(&restored_response, server_response.clone())
3566                        {
3567                            sleep(d);
3568                            continue;
3569                        }
3570
3571                        dlg.finished(false);
3572
3573                        return match server_response {
3574                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
3575                            None => Err(client::Error::Failure(restored_response)),
3576                        };
3577                    }
3578                    let result_value = {
3579                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3580
3581                        match json::from_str(&res_body_string) {
3582                            Ok(decoded) => (res, decoded),
3583                            Err(err) => {
3584                                dlg.response_json_decode_error(&res_body_string, &err);
3585                                return Err(client::Error::JsonDecodeError(res_body_string, err));
3586                            }
3587                        }
3588                    };
3589
3590                    dlg.finished(true);
3591                    return Ok(result_value);
3592                }
3593            }
3594        }
3595    }
3596
3597    /// Deprecated use driveId instead.
3598    ///
3599    /// Sets the *team drive id* query property to the given value.
3600    pub fn team_drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, S> {
3601        self._team_drive_id = Some(new_value.to_string());
3602        self
3603    }
3604    /// Deprecated use supportsAllDrives instead.
3605    ///
3606    /// Sets the *supports team drives* query property to the given value.
3607    pub fn supports_team_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, S> {
3608        self._supports_team_drives = Some(new_value);
3609        self
3610    }
3611    /// Whether the requesting application supports both My Drives and shared drives.
3612    ///
3613    /// Sets the *supports all drives* query property to the given value.
3614    pub fn supports_all_drives(mut self, new_value: bool) -> ChangeGetStartPageTokenCall<'a, S> {
3615        self._supports_all_drives = Some(new_value);
3616        self
3617    }
3618    /// The ID of the shared drive for which the starting pageToken for listing future changes from that shared drive is returned.
3619    ///
3620    /// Sets the *drive id* query property to the given value.
3621    pub fn drive_id(mut self, new_value: &str) -> ChangeGetStartPageTokenCall<'a, S> {
3622        self._drive_id = Some(new_value.to_string());
3623        self
3624    }
3625    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3626    /// while executing the actual API request.
3627    ///
3628    /// It should be used to handle progress information, and to implement a certain level of resilience.
3629    ///
3630    /// Sets the *delegate* property to the given value.
3631    pub fn delegate(
3632        mut self,
3633        new_value: &'a mut dyn client::Delegate,
3634    ) -> ChangeGetStartPageTokenCall<'a, S> {
3635        self._delegate = Some(new_value);
3636        self
3637    }
3638
3639    /// Set any additional parameter of the query string used in the request.
3640    /// It should be used to set parameters which are not yet available through their own
3641    /// setters.
3642    ///
3643    /// Please note that this method must not be used to set any of the known parameters
3644    /// which have their own setter method. If done anyway, the request will fail.
3645    ///
3646    /// # Additional Parameters
3647    ///
3648    /// * *alt* (query-string) - Data format for the response.
3649    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3650    /// * *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.
3651    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3652    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3653    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3654    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3655    pub fn param<T>(mut self, name: T, value: T) -> ChangeGetStartPageTokenCall<'a, S>
3656    where
3657        T: AsRef<str>,
3658    {
3659        self._additional_params
3660            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3661        self
3662    }
3663
3664    /// Identifies the authorization scope for the method you are building.
3665    ///
3666    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
3667    /// `Scope::MetadataReadonly`.
3668    ///
3669    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3670    /// tokens for more than one scope.
3671    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
3672    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
3673    /// function for details).
3674    ///
3675    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3676    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3677    /// sufficient, a read-write scope will do as well.
3678    pub fn add_scope<T, St>(mut self, scope: T) -> ChangeGetStartPageTokenCall<'a, S>
3679    where
3680        T: Into<Option<St>>,
3681        St: AsRef<str>,
3682    {
3683        match scope.into() {
3684            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
3685            None => None,
3686        };
3687        self
3688    }
3689}
3690
3691/// Lists the changes for a user or shared drive.
3692///
3693/// A builder for the *list* method supported by a *change* resource.
3694/// It is not used directly, but through a `ChangeMethods` instance.
3695///
3696/// # Example
3697///
3698/// Instantiate a resource method builder
3699///
3700/// ```test_harness,no_run
3701/// # extern crate hyper;
3702/// # extern crate hyper_rustls;
3703/// # extern crate google_drive3 as drive3;
3704/// # async fn dox() {
3705/// # use std::default::Default;
3706/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
3707///
3708/// # let secret: oauth2::ApplicationSecret = Default::default();
3709/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3710/// #         secret,
3711/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3712/// #     ).build().await.unwrap();
3713/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
3714/// // You can configure optional parameters by calling the respective setters at will, and
3715/// // execute the final call using `doit()`.
3716/// // Values shown here are possibly random and not representative !
3717/// let result = hub.changes().list("pageToken")
3718///              .team_drive_id("et")
3719///              .supports_team_drives(false)
3720///              .supports_all_drives(false)
3721///              .spaces("duo")
3722///              .restrict_to_my_drive(false)
3723///              .page_size(-76)
3724///              .include_team_drive_items(false)
3725///              .include_removed(true)
3726///              .include_permissions_for_view("vero")
3727///              .include_items_from_all_drives(true)
3728///              .include_corpus_removals(true)
3729///              .drive_id("ipsum")
3730///              .doit().await;
3731/// # }
3732/// ```
3733pub struct ChangeListCall<'a, S>
3734where
3735    S: 'a,
3736{
3737    hub: &'a DriveHub<S>,
3738    _page_token: String,
3739    _team_drive_id: Option<String>,
3740    _supports_team_drives: Option<bool>,
3741    _supports_all_drives: Option<bool>,
3742    _spaces: Option<String>,
3743    _restrict_to_my_drive: Option<bool>,
3744    _page_size: Option<i32>,
3745    _include_team_drive_items: Option<bool>,
3746    _include_removed: Option<bool>,
3747    _include_permissions_for_view: Option<String>,
3748    _include_items_from_all_drives: Option<bool>,
3749    _include_corpus_removals: Option<bool>,
3750    _drive_id: Option<String>,
3751    _delegate: Option<&'a mut dyn client::Delegate>,
3752    _additional_params: HashMap<String, String>,
3753    _scopes: BTreeMap<String, ()>,
3754}
3755
3756impl<'a, S> client::CallBuilder for ChangeListCall<'a, S> {}
3757
3758impl<'a, S> ChangeListCall<'a, S>
3759where
3760    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
3761    S::Response:
3762        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3763    S::Future: Send + Unpin + 'static,
3764    S::Error: Into<Box<dyn StdError + Send + Sync>>,
3765{
3766    /// Perform the operation you have build so far.
3767    pub async fn doit(
3768        mut self,
3769    ) -> client::Result<(hyper::Response<hyper::body::Body>, ChangeList)> {
3770        use client::ToParts;
3771        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3772        use std::io::{Read, Seek};
3773        let mut dd = client::DefaultDelegate;
3774        let mut dlg: &mut dyn client::Delegate = match self._delegate {
3775            Some(d) => d,
3776            None => &mut dd,
3777        };
3778        dlg.begin(client::MethodInfo {
3779            id: "drive.changes.list",
3780            http_method: hyper::Method::GET,
3781        });
3782        let mut params: Vec<(&str, String)> =
3783            Vec::with_capacity(15 + self._additional_params.len());
3784        params.push(("pageToken", self._page_token.to_string()));
3785        if let Some(value) = self._team_drive_id {
3786            params.push(("teamDriveId", value.to_string()));
3787        }
3788        if let Some(value) = self._supports_team_drives {
3789            params.push(("supportsTeamDrives", value.to_string()));
3790        }
3791        if let Some(value) = self._supports_all_drives {
3792            params.push(("supportsAllDrives", value.to_string()));
3793        }
3794        if let Some(value) = self._spaces {
3795            params.push(("spaces", value.to_string()));
3796        }
3797        if let Some(value) = self._restrict_to_my_drive {
3798            params.push(("restrictToMyDrive", value.to_string()));
3799        }
3800        if let Some(value) = self._page_size {
3801            params.push(("pageSize", value.to_string()));
3802        }
3803        if let Some(value) = self._include_team_drive_items {
3804            params.push(("includeTeamDriveItems", value.to_string()));
3805        }
3806        if let Some(value) = self._include_removed {
3807            params.push(("includeRemoved", value.to_string()));
3808        }
3809        if let Some(value) = self._include_permissions_for_view {
3810            params.push(("includePermissionsForView", value.to_string()));
3811        }
3812        if let Some(value) = self._include_items_from_all_drives {
3813            params.push(("includeItemsFromAllDrives", value.to_string()));
3814        }
3815        if let Some(value) = self._include_corpus_removals {
3816            params.push(("includeCorpusRemovals", value.to_string()));
3817        }
3818        if let Some(value) = self._drive_id {
3819            params.push(("driveId", value.to_string()));
3820        }
3821        for &field in [
3822            "alt",
3823            "pageToken",
3824            "teamDriveId",
3825            "supportsTeamDrives",
3826            "supportsAllDrives",
3827            "spaces",
3828            "restrictToMyDrive",
3829            "pageSize",
3830            "includeTeamDriveItems",
3831            "includeRemoved",
3832            "includePermissionsForView",
3833            "includeItemsFromAllDrives",
3834            "includeCorpusRemovals",
3835            "driveId",
3836        ]
3837        .iter()
3838        {
3839            if self._additional_params.contains_key(field) {
3840                dlg.finished(false);
3841                return Err(client::Error::FieldClash(field));
3842            }
3843        }
3844        for (name, value) in self._additional_params.iter() {
3845            params.push((&name, value.clone()));
3846        }
3847
3848        params.push(("alt", "json".to_string()));
3849
3850        let mut url = self.hub._base_url.clone() + "changes";
3851        if self._scopes.len() == 0 {
3852            self._scopes
3853                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
3854        }
3855
3856        let url = url::Url::parse_with_params(&url, params).unwrap();
3857
3858        loop {
3859            let token = match self
3860                .hub
3861                .auth
3862                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
3863                .await
3864            {
3865                Ok(token) => token.clone(),
3866                Err(err) => match dlg.token(&err) {
3867                    Some(token) => token,
3868                    None => {
3869                        dlg.finished(false);
3870                        return Err(client::Error::MissingToken(err));
3871                    }
3872                },
3873            };
3874            let mut req_result = {
3875                let client = &self.hub.client;
3876                dlg.pre_request();
3877                let mut req_builder = hyper::Request::builder()
3878                    .method(hyper::Method::GET)
3879                    .uri(url.clone().into_string())
3880                    .header(USER_AGENT, self.hub._user_agent.clone())
3881                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
3882
3883                let request = req_builder.body(hyper::body::Body::empty());
3884
3885                client.request(request.unwrap()).await
3886            };
3887
3888            match req_result {
3889                Err(err) => {
3890                    if let client::Retry::After(d) = dlg.http_error(&err) {
3891                        sleep(d);
3892                        continue;
3893                    }
3894                    dlg.finished(false);
3895                    return Err(client::Error::HttpError(err));
3896                }
3897                Ok(mut res) => {
3898                    if !res.status().is_success() {
3899                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3900                        let (parts, _) = res.into_parts();
3901                        let body = hyper::Body::from(res_body_string.clone());
3902                        let restored_response = hyper::Response::from_parts(parts, body);
3903
3904                        let server_response =
3905                            json::from_str::<serde_json::Value>(&res_body_string).ok();
3906
3907                        if let client::Retry::After(d) =
3908                            dlg.http_failure(&restored_response, server_response.clone())
3909                        {
3910                            sleep(d);
3911                            continue;
3912                        }
3913
3914                        dlg.finished(false);
3915
3916                        return match server_response {
3917                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
3918                            None => Err(client::Error::Failure(restored_response)),
3919                        };
3920                    }
3921                    let result_value = {
3922                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
3923
3924                        match json::from_str(&res_body_string) {
3925                            Ok(decoded) => (res, decoded),
3926                            Err(err) => {
3927                                dlg.response_json_decode_error(&res_body_string, &err);
3928                                return Err(client::Error::JsonDecodeError(res_body_string, err));
3929                            }
3930                        }
3931                    };
3932
3933                    dlg.finished(true);
3934                    return Ok(result_value);
3935                }
3936            }
3937        }
3938    }
3939
3940    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
3941    ///
3942    /// Sets the *page token* query property to the given value.
3943    ///
3944    /// Even though the property as already been set when instantiating this call,
3945    /// we provide this method for API completeness.
3946    pub fn page_token(mut self, new_value: &str) -> ChangeListCall<'a, S> {
3947        self._page_token = new_value.to_string();
3948        self
3949    }
3950    /// Deprecated use driveId instead.
3951    ///
3952    /// Sets the *team drive id* query property to the given value.
3953    pub fn team_drive_id(mut self, new_value: &str) -> ChangeListCall<'a, S> {
3954        self._team_drive_id = Some(new_value.to_string());
3955        self
3956    }
3957    /// Deprecated use supportsAllDrives instead.
3958    ///
3959    /// Sets the *supports team drives* query property to the given value.
3960    pub fn supports_team_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> {
3961        self._supports_team_drives = Some(new_value);
3962        self
3963    }
3964    /// Whether the requesting application supports both My Drives and shared drives.
3965    ///
3966    /// Sets the *supports all drives* query property to the given value.
3967    pub fn supports_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> {
3968        self._supports_all_drives = Some(new_value);
3969        self
3970    }
3971    /// A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
3972    ///
3973    /// Sets the *spaces* query property to the given value.
3974    pub fn spaces(mut self, new_value: &str) -> ChangeListCall<'a, S> {
3975        self._spaces = Some(new_value.to_string());
3976        self
3977    }
3978    /// Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.
3979    ///
3980    /// Sets the *restrict to my drive* query property to the given value.
3981    pub fn restrict_to_my_drive(mut self, new_value: bool) -> ChangeListCall<'a, S> {
3982        self._restrict_to_my_drive = Some(new_value);
3983        self
3984    }
3985    /// The maximum number of changes to return per page.
3986    ///
3987    /// Sets the *page size* query property to the given value.
3988    pub fn page_size(mut self, new_value: i32) -> ChangeListCall<'a, S> {
3989        self._page_size = Some(new_value);
3990        self
3991    }
3992    /// Deprecated use includeItemsFromAllDrives instead.
3993    ///
3994    /// Sets the *include team drive items* query property to the given value.
3995    pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeListCall<'a, S> {
3996        self._include_team_drive_items = Some(new_value);
3997        self
3998    }
3999    /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
4000    ///
4001    /// Sets the *include removed* query property to the given value.
4002    pub fn include_removed(mut self, new_value: bool) -> ChangeListCall<'a, S> {
4003        self._include_removed = Some(new_value);
4004        self
4005    }
4006    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
4007    ///
4008    /// Sets the *include permissions for view* query property to the given value.
4009    pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeListCall<'a, S> {
4010        self._include_permissions_for_view = Some(new_value.to_string());
4011        self
4012    }
4013    /// Whether both My Drive and shared drive items should be included in results.
4014    ///
4015    /// Sets the *include items from all drives* query property to the given value.
4016    pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeListCall<'a, S> {
4017        self._include_items_from_all_drives = Some(new_value);
4018        self
4019    }
4020    /// Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.
4021    ///
4022    /// Sets the *include corpus removals* query property to the given value.
4023    pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeListCall<'a, S> {
4024        self._include_corpus_removals = Some(new_value);
4025        self
4026    }
4027    /// The shared drive from which changes are returned. If specified the change IDs will be reflective of the shared drive; use the combined drive ID and change ID as an identifier.
4028    ///
4029    /// Sets the *drive id* query property to the given value.
4030    pub fn drive_id(mut self, new_value: &str) -> ChangeListCall<'a, S> {
4031        self._drive_id = Some(new_value.to_string());
4032        self
4033    }
4034    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4035    /// while executing the actual API request.
4036    ///
4037    /// It should be used to handle progress information, and to implement a certain level of resilience.
4038    ///
4039    /// Sets the *delegate* property to the given value.
4040    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeListCall<'a, S> {
4041        self._delegate = Some(new_value);
4042        self
4043    }
4044
4045    /// Set any additional parameter of the query string used in the request.
4046    /// It should be used to set parameters which are not yet available through their own
4047    /// setters.
4048    ///
4049    /// Please note that this method must not be used to set any of the known parameters
4050    /// which have their own setter method. If done anyway, the request will fail.
4051    ///
4052    /// # Additional Parameters
4053    ///
4054    /// * *alt* (query-string) - Data format for the response.
4055    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4056    /// * *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.
4057    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4058    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4059    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4060    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4061    pub fn param<T>(mut self, name: T, value: T) -> ChangeListCall<'a, S>
4062    where
4063        T: AsRef<str>,
4064    {
4065        self._additional_params
4066            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4067        self
4068    }
4069
4070    /// Identifies the authorization scope for the method you are building.
4071    ///
4072    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
4073    /// `Scope::MetadataReadonly`.
4074    ///
4075    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4076    /// tokens for more than one scope.
4077    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
4078    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
4079    /// function for details).
4080    ///
4081    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4082    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4083    /// sufficient, a read-write scope will do as well.
4084    pub fn add_scope<T, St>(mut self, scope: T) -> ChangeListCall<'a, S>
4085    where
4086        T: Into<Option<St>>,
4087        St: AsRef<str>,
4088    {
4089        match scope.into() {
4090            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
4091            None => None,
4092        };
4093        self
4094    }
4095}
4096
4097/// Subscribes to changes for a user.
4098///
4099/// A builder for the *watch* method supported by a *change* resource.
4100/// It is not used directly, but through a `ChangeMethods` instance.
4101///
4102/// # Example
4103///
4104/// Instantiate a resource method builder
4105///
4106/// ```test_harness,no_run
4107/// # extern crate hyper;
4108/// # extern crate hyper_rustls;
4109/// # extern crate google_drive3 as drive3;
4110/// use drive3::api::Channel;
4111/// # async fn dox() {
4112/// # use std::default::Default;
4113/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
4114///
4115/// # let secret: oauth2::ApplicationSecret = Default::default();
4116/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4117/// #         secret,
4118/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4119/// #     ).build().await.unwrap();
4120/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
4121/// // As the method needs a request, you would usually fill it with the desired information
4122/// // into the respective structure. Some of the parts shown here might not be applicable !
4123/// // Values shown here are possibly random and not representative !
4124/// let mut req = Channel::default();
4125///
4126/// // You can configure optional parameters by calling the respective setters at will, and
4127/// // execute the final call using `doit()`.
4128/// // Values shown here are possibly random and not representative !
4129/// let result = hub.changes().watch(req, "pageToken")
4130///              .team_drive_id("takimata")
4131///              .supports_team_drives(true)
4132///              .supports_all_drives(false)
4133///              .spaces("erat")
4134///              .restrict_to_my_drive(false)
4135///              .page_size(-2)
4136///              .include_team_drive_items(true)
4137///              .include_removed(false)
4138///              .include_permissions_for_view("accusam")
4139///              .include_items_from_all_drives(false)
4140///              .include_corpus_removals(false)
4141///              .drive_id("amet.")
4142///              .doit().await;
4143/// # }
4144/// ```
4145pub struct ChangeWatchCall<'a, S>
4146where
4147    S: 'a,
4148{
4149    hub: &'a DriveHub<S>,
4150    _request: Channel,
4151    _page_token: String,
4152    _team_drive_id: Option<String>,
4153    _supports_team_drives: Option<bool>,
4154    _supports_all_drives: Option<bool>,
4155    _spaces: Option<String>,
4156    _restrict_to_my_drive: Option<bool>,
4157    _page_size: Option<i32>,
4158    _include_team_drive_items: Option<bool>,
4159    _include_removed: Option<bool>,
4160    _include_permissions_for_view: Option<String>,
4161    _include_items_from_all_drives: Option<bool>,
4162    _include_corpus_removals: Option<bool>,
4163    _drive_id: Option<String>,
4164    _delegate: Option<&'a mut dyn client::Delegate>,
4165    _additional_params: HashMap<String, String>,
4166    _scopes: BTreeMap<String, ()>,
4167}
4168
4169impl<'a, S> client::CallBuilder for ChangeWatchCall<'a, S> {}
4170
4171impl<'a, S> ChangeWatchCall<'a, S>
4172where
4173    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
4174    S::Response:
4175        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4176    S::Future: Send + Unpin + 'static,
4177    S::Error: Into<Box<dyn StdError + Send + Sync>>,
4178{
4179    /// Perform the operation you have build so far.
4180    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Channel)> {
4181        use client::ToParts;
4182        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4183        use std::io::{Read, Seek};
4184        let mut dd = client::DefaultDelegate;
4185        let mut dlg: &mut dyn client::Delegate = match self._delegate {
4186            Some(d) => d,
4187            None => &mut dd,
4188        };
4189        dlg.begin(client::MethodInfo {
4190            id: "drive.changes.watch",
4191            http_method: hyper::Method::POST,
4192        });
4193        let mut params: Vec<(&str, String)> =
4194            Vec::with_capacity(16 + self._additional_params.len());
4195        params.push(("pageToken", self._page_token.to_string()));
4196        if let Some(value) = self._team_drive_id {
4197            params.push(("teamDriveId", value.to_string()));
4198        }
4199        if let Some(value) = self._supports_team_drives {
4200            params.push(("supportsTeamDrives", value.to_string()));
4201        }
4202        if let Some(value) = self._supports_all_drives {
4203            params.push(("supportsAllDrives", value.to_string()));
4204        }
4205        if let Some(value) = self._spaces {
4206            params.push(("spaces", value.to_string()));
4207        }
4208        if let Some(value) = self._restrict_to_my_drive {
4209            params.push(("restrictToMyDrive", value.to_string()));
4210        }
4211        if let Some(value) = self._page_size {
4212            params.push(("pageSize", value.to_string()));
4213        }
4214        if let Some(value) = self._include_team_drive_items {
4215            params.push(("includeTeamDriveItems", value.to_string()));
4216        }
4217        if let Some(value) = self._include_removed {
4218            params.push(("includeRemoved", value.to_string()));
4219        }
4220        if let Some(value) = self._include_permissions_for_view {
4221            params.push(("includePermissionsForView", value.to_string()));
4222        }
4223        if let Some(value) = self._include_items_from_all_drives {
4224            params.push(("includeItemsFromAllDrives", value.to_string()));
4225        }
4226        if let Some(value) = self._include_corpus_removals {
4227            params.push(("includeCorpusRemovals", value.to_string()));
4228        }
4229        if let Some(value) = self._drive_id {
4230            params.push(("driveId", value.to_string()));
4231        }
4232        for &field in [
4233            "alt",
4234            "pageToken",
4235            "teamDriveId",
4236            "supportsTeamDrives",
4237            "supportsAllDrives",
4238            "spaces",
4239            "restrictToMyDrive",
4240            "pageSize",
4241            "includeTeamDriveItems",
4242            "includeRemoved",
4243            "includePermissionsForView",
4244            "includeItemsFromAllDrives",
4245            "includeCorpusRemovals",
4246            "driveId",
4247        ]
4248        .iter()
4249        {
4250            if self._additional_params.contains_key(field) {
4251                dlg.finished(false);
4252                return Err(client::Error::FieldClash(field));
4253            }
4254        }
4255        for (name, value) in self._additional_params.iter() {
4256            params.push((&name, value.clone()));
4257        }
4258
4259        params.push(("alt", "json".to_string()));
4260
4261        let mut url = self.hub._base_url.clone() + "changes/watch";
4262        if self._scopes.len() == 0 {
4263            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
4264        }
4265
4266        let url = url::Url::parse_with_params(&url, params).unwrap();
4267
4268        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
4269        let mut request_value_reader = {
4270            let mut value = json::value::to_value(&self._request).expect("serde to work");
4271            client::remove_json_null_values(&mut value);
4272            let mut dst = io::Cursor::new(Vec::with_capacity(128));
4273            json::to_writer(&mut dst, &value).unwrap();
4274            dst
4275        };
4276        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
4277        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4278
4279        loop {
4280            let token = match self
4281                .hub
4282                .auth
4283                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
4284                .await
4285            {
4286                Ok(token) => token.clone(),
4287                Err(err) => match dlg.token(&err) {
4288                    Some(token) => token,
4289                    None => {
4290                        dlg.finished(false);
4291                        return Err(client::Error::MissingToken(err));
4292                    }
4293                },
4294            };
4295            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4296            let mut req_result = {
4297                let client = &self.hub.client;
4298                dlg.pre_request();
4299                let mut req_builder = hyper::Request::builder()
4300                    .method(hyper::Method::POST)
4301                    .uri(url.clone().into_string())
4302                    .header(USER_AGENT, self.hub._user_agent.clone())
4303                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
4304
4305                let request = req_builder
4306                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
4307                    .header(CONTENT_LENGTH, request_size as u64)
4308                    .body(hyper::body::Body::from(
4309                        request_value_reader.get_ref().clone(),
4310                    ));
4311
4312                client.request(request.unwrap()).await
4313            };
4314
4315            match req_result {
4316                Err(err) => {
4317                    if let client::Retry::After(d) = dlg.http_error(&err) {
4318                        sleep(d);
4319                        continue;
4320                    }
4321                    dlg.finished(false);
4322                    return Err(client::Error::HttpError(err));
4323                }
4324                Ok(mut res) => {
4325                    if !res.status().is_success() {
4326                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
4327                        let (parts, _) = res.into_parts();
4328                        let body = hyper::Body::from(res_body_string.clone());
4329                        let restored_response = hyper::Response::from_parts(parts, body);
4330
4331                        let server_response =
4332                            json::from_str::<serde_json::Value>(&res_body_string).ok();
4333
4334                        if let client::Retry::After(d) =
4335                            dlg.http_failure(&restored_response, server_response.clone())
4336                        {
4337                            sleep(d);
4338                            continue;
4339                        }
4340
4341                        dlg.finished(false);
4342
4343                        return match server_response {
4344                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
4345                            None => Err(client::Error::Failure(restored_response)),
4346                        };
4347                    }
4348                    let result_value = {
4349                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
4350
4351                        match json::from_str(&res_body_string) {
4352                            Ok(decoded) => (res, decoded),
4353                            Err(err) => {
4354                                dlg.response_json_decode_error(&res_body_string, &err);
4355                                return Err(client::Error::JsonDecodeError(res_body_string, err));
4356                            }
4357                        }
4358                    };
4359
4360                    dlg.finished(true);
4361                    return Ok(result_value);
4362                }
4363            }
4364        }
4365    }
4366
4367    ///
4368    /// Sets the *request* property to the given value.
4369    ///
4370    /// Even though the property as already been set when instantiating this call,
4371    /// we provide this method for API completeness.
4372    pub fn request(mut self, new_value: Channel) -> ChangeWatchCall<'a, S> {
4373        self._request = new_value;
4374        self
4375    }
4376    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.
4377    ///
4378    /// Sets the *page token* query property to the given value.
4379    ///
4380    /// Even though the property as already been set when instantiating this call,
4381    /// we provide this method for API completeness.
4382    pub fn page_token(mut self, new_value: &str) -> ChangeWatchCall<'a, S> {
4383        self._page_token = new_value.to_string();
4384        self
4385    }
4386    /// Deprecated use driveId instead.
4387    ///
4388    /// Sets the *team drive id* query property to the given value.
4389    pub fn team_drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, S> {
4390        self._team_drive_id = Some(new_value.to_string());
4391        self
4392    }
4393    /// Deprecated use supportsAllDrives instead.
4394    ///
4395    /// Sets the *supports team drives* query property to the given value.
4396    pub fn supports_team_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4397        self._supports_team_drives = Some(new_value);
4398        self
4399    }
4400    /// Whether the requesting application supports both My Drives and shared drives.
4401    ///
4402    /// Sets the *supports all drives* query property to the given value.
4403    pub fn supports_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4404        self._supports_all_drives = Some(new_value);
4405        self
4406    }
4407    /// A comma-separated list of spaces to query within the user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
4408    ///
4409    /// Sets the *spaces* query property to the given value.
4410    pub fn spaces(mut self, new_value: &str) -> ChangeWatchCall<'a, S> {
4411        self._spaces = Some(new_value.to_string());
4412        self
4413    }
4414    /// Whether to restrict the results to changes inside the My Drive hierarchy. This omits changes to files such as those in the Application Data folder or shared files which have not been added to My Drive.
4415    ///
4416    /// Sets the *restrict to my drive* query property to the given value.
4417    pub fn restrict_to_my_drive(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4418        self._restrict_to_my_drive = Some(new_value);
4419        self
4420    }
4421    /// The maximum number of changes to return per page.
4422    ///
4423    /// Sets the *page size* query property to the given value.
4424    pub fn page_size(mut self, new_value: i32) -> ChangeWatchCall<'a, S> {
4425        self._page_size = Some(new_value);
4426        self
4427    }
4428    /// Deprecated use includeItemsFromAllDrives instead.
4429    ///
4430    /// Sets the *include team drive items* query property to the given value.
4431    pub fn include_team_drive_items(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4432        self._include_team_drive_items = Some(new_value);
4433        self
4434    }
4435    /// Whether to include changes indicating that items have been removed from the list of changes, for example by deletion or loss of access.
4436    ///
4437    /// Sets the *include removed* query property to the given value.
4438    pub fn include_removed(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4439        self._include_removed = Some(new_value);
4440        self
4441    }
4442    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
4443    ///
4444    /// Sets the *include permissions for view* query property to the given value.
4445    pub fn include_permissions_for_view(mut self, new_value: &str) -> ChangeWatchCall<'a, S> {
4446        self._include_permissions_for_view = Some(new_value.to_string());
4447        self
4448    }
4449    /// Whether both My Drive and shared drive items should be included in results.
4450    ///
4451    /// Sets the *include items from all drives* query property to the given value.
4452    pub fn include_items_from_all_drives(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4453        self._include_items_from_all_drives = Some(new_value);
4454        self
4455    }
4456    /// Whether changes should include the file resource if the file is still accessible by the user at the time of the request, even when a file was removed from the list of changes and there will be no further change entries for this file.
4457    ///
4458    /// Sets the *include corpus removals* query property to the given value.
4459    pub fn include_corpus_removals(mut self, new_value: bool) -> ChangeWatchCall<'a, S> {
4460        self._include_corpus_removals = Some(new_value);
4461        self
4462    }
4463    /// The shared drive from which changes are returned. If specified the change IDs will be reflective of the shared drive; use the combined drive ID and change ID as an identifier.
4464    ///
4465    /// Sets the *drive id* query property to the given value.
4466    pub fn drive_id(mut self, new_value: &str) -> ChangeWatchCall<'a, S> {
4467        self._drive_id = Some(new_value.to_string());
4468        self
4469    }
4470    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4471    /// while executing the actual API request.
4472    ///
4473    /// It should be used to handle progress information, and to implement a certain level of resilience.
4474    ///
4475    /// Sets the *delegate* property to the given value.
4476    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChangeWatchCall<'a, S> {
4477        self._delegate = Some(new_value);
4478        self
4479    }
4480
4481    /// Set any additional parameter of the query string used in the request.
4482    /// It should be used to set parameters which are not yet available through their own
4483    /// setters.
4484    ///
4485    /// Please note that this method must not be used to set any of the known parameters
4486    /// which have their own setter method. If done anyway, the request will fail.
4487    ///
4488    /// # Additional Parameters
4489    ///
4490    /// * *alt* (query-string) - Data format for the response.
4491    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4492    /// * *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.
4493    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4494    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4495    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4496    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4497    pub fn param<T>(mut self, name: T, value: T) -> ChangeWatchCall<'a, S>
4498    where
4499        T: AsRef<str>,
4500    {
4501        self._additional_params
4502            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4503        self
4504    }
4505
4506    /// Identifies the authorization scope for the method you are building.
4507    ///
4508    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
4509    /// `Scope::Full`.
4510    ///
4511    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4512    /// tokens for more than one scope.
4513    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
4514    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
4515    /// function for details).
4516    ///
4517    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4518    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4519    /// sufficient, a read-write scope will do as well.
4520    pub fn add_scope<T, St>(mut self, scope: T) -> ChangeWatchCall<'a, S>
4521    where
4522        T: Into<Option<St>>,
4523        St: AsRef<str>,
4524    {
4525        match scope.into() {
4526            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
4527            None => None,
4528        };
4529        self
4530    }
4531}
4532
4533/// Stop watching resources through this channel
4534///
4535/// A builder for the *stop* method supported by a *channel* resource.
4536/// It is not used directly, but through a `ChannelMethods` instance.
4537///
4538/// # Example
4539///
4540/// Instantiate a resource method builder
4541///
4542/// ```test_harness,no_run
4543/// # extern crate hyper;
4544/// # extern crate hyper_rustls;
4545/// # extern crate google_drive3 as drive3;
4546/// use drive3::api::Channel;
4547/// # async fn dox() {
4548/// # use std::default::Default;
4549/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
4550///
4551/// # let secret: oauth2::ApplicationSecret = Default::default();
4552/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4553/// #         secret,
4554/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4555/// #     ).build().await.unwrap();
4556/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
4557/// // As the method needs a request, you would usually fill it with the desired information
4558/// // into the respective structure. Some of the parts shown here might not be applicable !
4559/// // Values shown here are possibly random and not representative !
4560/// let mut req = Channel::default();
4561///
4562/// // You can configure optional parameters by calling the respective setters at will, and
4563/// // execute the final call using `doit()`.
4564/// // Values shown here are possibly random and not representative !
4565/// let result = hub.channels().stop(req)
4566///              .doit().await;
4567/// # }
4568/// ```
4569pub struct ChannelStopCall<'a, S>
4570where
4571    S: 'a,
4572{
4573    hub: &'a DriveHub<S>,
4574    _request: Channel,
4575    _delegate: Option<&'a mut dyn client::Delegate>,
4576    _additional_params: HashMap<String, String>,
4577    _scopes: BTreeMap<String, ()>,
4578}
4579
4580impl<'a, S> client::CallBuilder for ChannelStopCall<'a, S> {}
4581
4582impl<'a, S> ChannelStopCall<'a, S>
4583where
4584    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
4585    S::Response:
4586        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4587    S::Future: Send + Unpin + 'static,
4588    S::Error: Into<Box<dyn StdError + Send + Sync>>,
4589{
4590    /// Perform the operation you have build so far.
4591    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
4592        use client::ToParts;
4593        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4594        use std::io::{Read, Seek};
4595        let mut dd = client::DefaultDelegate;
4596        let mut dlg: &mut dyn client::Delegate = match self._delegate {
4597            Some(d) => d,
4598            None => &mut dd,
4599        };
4600        dlg.begin(client::MethodInfo {
4601            id: "drive.channels.stop",
4602            http_method: hyper::Method::POST,
4603        });
4604        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
4605        for &field in [].iter() {
4606            if self._additional_params.contains_key(field) {
4607                dlg.finished(false);
4608                return Err(client::Error::FieldClash(field));
4609            }
4610        }
4611        for (name, value) in self._additional_params.iter() {
4612            params.push((&name, value.clone()));
4613        }
4614
4615        let mut url = self.hub._base_url.clone() + "channels/stop";
4616        if self._scopes.len() == 0 {
4617            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
4618        }
4619
4620        let url = url::Url::parse_with_params(&url, params).unwrap();
4621
4622        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
4623        let mut request_value_reader = {
4624            let mut value = json::value::to_value(&self._request).expect("serde to work");
4625            client::remove_json_null_values(&mut value);
4626            let mut dst = io::Cursor::new(Vec::with_capacity(128));
4627            json::to_writer(&mut dst, &value).unwrap();
4628            dst
4629        };
4630        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
4631        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4632
4633        loop {
4634            let token = match self
4635                .hub
4636                .auth
4637                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
4638                .await
4639            {
4640                Ok(token) => token.clone(),
4641                Err(err) => match dlg.token(&err) {
4642                    Some(token) => token,
4643                    None => {
4644                        dlg.finished(false);
4645                        return Err(client::Error::MissingToken(err));
4646                    }
4647                },
4648            };
4649            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4650            let mut req_result = {
4651                let client = &self.hub.client;
4652                dlg.pre_request();
4653                let mut req_builder = hyper::Request::builder()
4654                    .method(hyper::Method::POST)
4655                    .uri(url.clone().into_string())
4656                    .header(USER_AGENT, self.hub._user_agent.clone())
4657                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
4658
4659                let request = req_builder
4660                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
4661                    .header(CONTENT_LENGTH, request_size as u64)
4662                    .body(hyper::body::Body::from(
4663                        request_value_reader.get_ref().clone(),
4664                    ));
4665
4666                client.request(request.unwrap()).await
4667            };
4668
4669            match req_result {
4670                Err(err) => {
4671                    if let client::Retry::After(d) = dlg.http_error(&err) {
4672                        sleep(d);
4673                        continue;
4674                    }
4675                    dlg.finished(false);
4676                    return Err(client::Error::HttpError(err));
4677                }
4678                Ok(mut res) => {
4679                    if !res.status().is_success() {
4680                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
4681                        let (parts, _) = res.into_parts();
4682                        let body = hyper::Body::from(res_body_string.clone());
4683                        let restored_response = hyper::Response::from_parts(parts, body);
4684
4685                        let server_response =
4686                            json::from_str::<serde_json::Value>(&res_body_string).ok();
4687
4688                        if let client::Retry::After(d) =
4689                            dlg.http_failure(&restored_response, server_response.clone())
4690                        {
4691                            sleep(d);
4692                            continue;
4693                        }
4694
4695                        dlg.finished(false);
4696
4697                        return match server_response {
4698                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
4699                            None => Err(client::Error::Failure(restored_response)),
4700                        };
4701                    }
4702                    let result_value = res;
4703
4704                    dlg.finished(true);
4705                    return Ok(result_value);
4706                }
4707            }
4708        }
4709    }
4710
4711    ///
4712    /// Sets the *request* property to the given value.
4713    ///
4714    /// Even though the property as already been set when instantiating this call,
4715    /// we provide this method for API completeness.
4716    pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, S> {
4717        self._request = new_value;
4718        self
4719    }
4720    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4721    /// while executing the actual API request.
4722    ///
4723    /// It should be used to handle progress information, and to implement a certain level of resilience.
4724    ///
4725    /// Sets the *delegate* property to the given value.
4726    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ChannelStopCall<'a, S> {
4727        self._delegate = Some(new_value);
4728        self
4729    }
4730
4731    /// Set any additional parameter of the query string used in the request.
4732    /// It should be used to set parameters which are not yet available through their own
4733    /// setters.
4734    ///
4735    /// Please note that this method must not be used to set any of the known parameters
4736    /// which have their own setter method. If done anyway, the request will fail.
4737    ///
4738    /// # Additional Parameters
4739    ///
4740    /// * *alt* (query-string) - Data format for the response.
4741    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4742    /// * *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.
4743    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4744    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4745    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4746    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4747    pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, S>
4748    where
4749        T: AsRef<str>,
4750    {
4751        self._additional_params
4752            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4753        self
4754    }
4755
4756    /// Identifies the authorization scope for the method you are building.
4757    ///
4758    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
4759    /// `Scope::Full`.
4760    ///
4761    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4762    /// tokens for more than one scope.
4763    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
4764    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
4765    /// function for details).
4766    ///
4767    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4768    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4769    /// sufficient, a read-write scope will do as well.
4770    pub fn add_scope<T, St>(mut self, scope: T) -> ChannelStopCall<'a, S>
4771    where
4772        T: Into<Option<St>>,
4773        St: AsRef<str>,
4774    {
4775        match scope.into() {
4776            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
4777            None => None,
4778        };
4779        self
4780    }
4781}
4782
4783/// Creates a new comment on a file.
4784///
4785/// A builder for the *create* method supported by a *comment* resource.
4786/// It is not used directly, but through a `CommentMethods` instance.
4787///
4788/// # Example
4789///
4790/// Instantiate a resource method builder
4791///
4792/// ```test_harness,no_run
4793/// # extern crate hyper;
4794/// # extern crate hyper_rustls;
4795/// # extern crate google_drive3 as drive3;
4796/// use drive3::api::Comment;
4797/// # async fn dox() {
4798/// # use std::default::Default;
4799/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
4800///
4801/// # let secret: oauth2::ApplicationSecret = Default::default();
4802/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4803/// #         secret,
4804/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4805/// #     ).build().await.unwrap();
4806/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
4807/// // As the method needs a request, you would usually fill it with the desired information
4808/// // into the respective structure. Some of the parts shown here might not be applicable !
4809/// // Values shown here are possibly random and not representative !
4810/// let mut req = Comment::default();
4811///
4812/// // You can configure optional parameters by calling the respective setters at will, and
4813/// // execute the final call using `doit()`.
4814/// // Values shown here are possibly random and not representative !
4815/// let result = hub.comments().create(req, "fileId")
4816///              .doit().await;
4817/// # }
4818/// ```
4819pub struct CommentCreateCall<'a, S>
4820where
4821    S: 'a,
4822{
4823    hub: &'a DriveHub<S>,
4824    _request: Comment,
4825    _file_id: String,
4826    _delegate: Option<&'a mut dyn client::Delegate>,
4827    _additional_params: HashMap<String, String>,
4828    _scopes: BTreeMap<String, ()>,
4829}
4830
4831impl<'a, S> client::CallBuilder for CommentCreateCall<'a, S> {}
4832
4833impl<'a, S> CommentCreateCall<'a, S>
4834where
4835    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
4836    S::Response:
4837        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4838    S::Future: Send + Unpin + 'static,
4839    S::Error: Into<Box<dyn StdError + Send + Sync>>,
4840{
4841    /// Perform the operation you have build so far.
4842    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Comment)> {
4843        use client::ToParts;
4844        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4845        use std::io::{Read, Seek};
4846        let mut dd = client::DefaultDelegate;
4847        let mut dlg: &mut dyn client::Delegate = match self._delegate {
4848            Some(d) => d,
4849            None => &mut dd,
4850        };
4851        dlg.begin(client::MethodInfo {
4852            id: "drive.comments.create",
4853            http_method: hyper::Method::POST,
4854        });
4855        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
4856        params.push(("fileId", self._file_id.to_string()));
4857        for &field in ["alt", "fileId"].iter() {
4858            if self._additional_params.contains_key(field) {
4859                dlg.finished(false);
4860                return Err(client::Error::FieldClash(field));
4861            }
4862        }
4863        for (name, value) in self._additional_params.iter() {
4864            params.push((&name, value.clone()));
4865        }
4866
4867        params.push(("alt", "json".to_string()));
4868
4869        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
4870        if self._scopes.len() == 0 {
4871            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
4872        }
4873
4874        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
4875            let mut replace_with: Option<&str> = None;
4876            for &(name, ref value) in params.iter() {
4877                if name == param_name {
4878                    replace_with = Some(value);
4879                    break;
4880                }
4881            }
4882            url = url.replace(
4883                find_this,
4884                replace_with.expect("to find substitution value in params"),
4885            );
4886        }
4887        {
4888            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
4889            for param_name in ["fileId"].iter() {
4890                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
4891                    indices_for_removal.push(index);
4892                }
4893            }
4894            for &index in indices_for_removal.iter() {
4895                params.remove(index);
4896            }
4897        }
4898
4899        let url = url::Url::parse_with_params(&url, params).unwrap();
4900
4901        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
4902        let mut request_value_reader = {
4903            let mut value = json::value::to_value(&self._request).expect("serde to work");
4904            client::remove_json_null_values(&mut value);
4905            let mut dst = io::Cursor::new(Vec::with_capacity(128));
4906            json::to_writer(&mut dst, &value).unwrap();
4907            dst
4908        };
4909        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
4910        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4911
4912        loop {
4913            let token = match self
4914                .hub
4915                .auth
4916                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
4917                .await
4918            {
4919                Ok(token) => token.clone(),
4920                Err(err) => match dlg.token(&err) {
4921                    Some(token) => token,
4922                    None => {
4923                        dlg.finished(false);
4924                        return Err(client::Error::MissingToken(err));
4925                    }
4926                },
4927            };
4928            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4929            let mut req_result = {
4930                let client = &self.hub.client;
4931                dlg.pre_request();
4932                let mut req_builder = hyper::Request::builder()
4933                    .method(hyper::Method::POST)
4934                    .uri(url.clone().into_string())
4935                    .header(USER_AGENT, self.hub._user_agent.clone())
4936                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
4937
4938                let request = req_builder
4939                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
4940                    .header(CONTENT_LENGTH, request_size as u64)
4941                    .body(hyper::body::Body::from(
4942                        request_value_reader.get_ref().clone(),
4943                    ));
4944
4945                client.request(request.unwrap()).await
4946            };
4947
4948            match req_result {
4949                Err(err) => {
4950                    if let client::Retry::After(d) = dlg.http_error(&err) {
4951                        sleep(d);
4952                        continue;
4953                    }
4954                    dlg.finished(false);
4955                    return Err(client::Error::HttpError(err));
4956                }
4957                Ok(mut res) => {
4958                    if !res.status().is_success() {
4959                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
4960                        let (parts, _) = res.into_parts();
4961                        let body = hyper::Body::from(res_body_string.clone());
4962                        let restored_response = hyper::Response::from_parts(parts, body);
4963
4964                        let server_response =
4965                            json::from_str::<serde_json::Value>(&res_body_string).ok();
4966
4967                        if let client::Retry::After(d) =
4968                            dlg.http_failure(&restored_response, server_response.clone())
4969                        {
4970                            sleep(d);
4971                            continue;
4972                        }
4973
4974                        dlg.finished(false);
4975
4976                        return match server_response {
4977                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
4978                            None => Err(client::Error::Failure(restored_response)),
4979                        };
4980                    }
4981                    let result_value = {
4982                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
4983
4984                        match json::from_str(&res_body_string) {
4985                            Ok(decoded) => (res, decoded),
4986                            Err(err) => {
4987                                dlg.response_json_decode_error(&res_body_string, &err);
4988                                return Err(client::Error::JsonDecodeError(res_body_string, err));
4989                            }
4990                        }
4991                    };
4992
4993                    dlg.finished(true);
4994                    return Ok(result_value);
4995                }
4996            }
4997        }
4998    }
4999
5000    ///
5001    /// Sets the *request* property to the given value.
5002    ///
5003    /// Even though the property as already been set when instantiating this call,
5004    /// we provide this method for API completeness.
5005    pub fn request(mut self, new_value: Comment) -> CommentCreateCall<'a, S> {
5006        self._request = new_value;
5007        self
5008    }
5009    /// The ID of the file.
5010    ///
5011    /// Sets the *file id* path property to the given value.
5012    ///
5013    /// Even though the property as already been set when instantiating this call,
5014    /// we provide this method for API completeness.
5015    pub fn file_id(mut self, new_value: &str) -> CommentCreateCall<'a, S> {
5016        self._file_id = new_value.to_string();
5017        self
5018    }
5019    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5020    /// while executing the actual API request.
5021    ///
5022    /// It should be used to handle progress information, and to implement a certain level of resilience.
5023    ///
5024    /// Sets the *delegate* property to the given value.
5025    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentCreateCall<'a, S> {
5026        self._delegate = Some(new_value);
5027        self
5028    }
5029
5030    /// Set any additional parameter of the query string used in the request.
5031    /// It should be used to set parameters which are not yet available through their own
5032    /// setters.
5033    ///
5034    /// Please note that this method must not be used to set any of the known parameters
5035    /// which have their own setter method. If done anyway, the request will fail.
5036    ///
5037    /// # Additional Parameters
5038    ///
5039    /// * *alt* (query-string) - Data format for the response.
5040    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5041    /// * *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.
5042    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5043    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5044    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5045    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5046    pub fn param<T>(mut self, name: T, value: T) -> CommentCreateCall<'a, S>
5047    where
5048        T: AsRef<str>,
5049    {
5050        self._additional_params
5051            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5052        self
5053    }
5054
5055    /// Identifies the authorization scope for the method you are building.
5056    ///
5057    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
5058    /// `Scope::Full`.
5059    ///
5060    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5061    /// tokens for more than one scope.
5062    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
5063    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
5064    /// function for details).
5065    ///
5066    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5067    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5068    /// sufficient, a read-write scope will do as well.
5069    pub fn add_scope<T, St>(mut self, scope: T) -> CommentCreateCall<'a, S>
5070    where
5071        T: Into<Option<St>>,
5072        St: AsRef<str>,
5073    {
5074        match scope.into() {
5075            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
5076            None => None,
5077        };
5078        self
5079    }
5080}
5081
5082/// Deletes a comment.
5083///
5084/// A builder for the *delete* method supported by a *comment* resource.
5085/// It is not used directly, but through a `CommentMethods` instance.
5086///
5087/// # Example
5088///
5089/// Instantiate a resource method builder
5090///
5091/// ```test_harness,no_run
5092/// # extern crate hyper;
5093/// # extern crate hyper_rustls;
5094/// # extern crate google_drive3 as drive3;
5095/// # async fn dox() {
5096/// # use std::default::Default;
5097/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
5098///
5099/// # let secret: oauth2::ApplicationSecret = Default::default();
5100/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
5101/// #         secret,
5102/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5103/// #     ).build().await.unwrap();
5104/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
5105/// // You can configure optional parameters by calling the respective setters at will, and
5106/// // execute the final call using `doit()`.
5107/// // Values shown here are possibly random and not representative !
5108/// let result = hub.comments().delete("fileId", "commentId")
5109///              .doit().await;
5110/// # }
5111/// ```
5112pub struct CommentDeleteCall<'a, S>
5113where
5114    S: 'a,
5115{
5116    hub: &'a DriveHub<S>,
5117    _file_id: String,
5118    _comment_id: String,
5119    _delegate: Option<&'a mut dyn client::Delegate>,
5120    _additional_params: HashMap<String, String>,
5121    _scopes: BTreeMap<String, ()>,
5122}
5123
5124impl<'a, S> client::CallBuilder for CommentDeleteCall<'a, S> {}
5125
5126impl<'a, S> CommentDeleteCall<'a, S>
5127where
5128    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
5129    S::Response:
5130        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
5131    S::Future: Send + Unpin + 'static,
5132    S::Error: Into<Box<dyn StdError + Send + Sync>>,
5133{
5134    /// Perform the operation you have build so far.
5135    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
5136        use client::ToParts;
5137        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5138        use std::io::{Read, Seek};
5139        let mut dd = client::DefaultDelegate;
5140        let mut dlg: &mut dyn client::Delegate = match self._delegate {
5141            Some(d) => d,
5142            None => &mut dd,
5143        };
5144        dlg.begin(client::MethodInfo {
5145            id: "drive.comments.delete",
5146            http_method: hyper::Method::DELETE,
5147        });
5148        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
5149        params.push(("fileId", self._file_id.to_string()));
5150        params.push(("commentId", self._comment_id.to_string()));
5151        for &field in ["fileId", "commentId"].iter() {
5152            if self._additional_params.contains_key(field) {
5153                dlg.finished(false);
5154                return Err(client::Error::FieldClash(field));
5155            }
5156        }
5157        for (name, value) in self._additional_params.iter() {
5158            params.push((&name, value.clone()));
5159        }
5160
5161        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
5162        if self._scopes.len() == 0 {
5163            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
5164        }
5165
5166        for &(find_this, param_name) in
5167            [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
5168        {
5169            let mut replace_with: Option<&str> = None;
5170            for &(name, ref value) in params.iter() {
5171                if name == param_name {
5172                    replace_with = Some(value);
5173                    break;
5174                }
5175            }
5176            url = url.replace(
5177                find_this,
5178                replace_with.expect("to find substitution value in params"),
5179            );
5180        }
5181        {
5182            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
5183            for param_name in ["commentId", "fileId"].iter() {
5184                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
5185                    indices_for_removal.push(index);
5186                }
5187            }
5188            for &index in indices_for_removal.iter() {
5189                params.remove(index);
5190            }
5191        }
5192
5193        let url = url::Url::parse_with_params(&url, params).unwrap();
5194
5195        loop {
5196            let token = match self
5197                .hub
5198                .auth
5199                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
5200                .await
5201            {
5202                Ok(token) => token.clone(),
5203                Err(err) => match dlg.token(&err) {
5204                    Some(token) => token,
5205                    None => {
5206                        dlg.finished(false);
5207                        return Err(client::Error::MissingToken(err));
5208                    }
5209                },
5210            };
5211            let mut req_result = {
5212                let client = &self.hub.client;
5213                dlg.pre_request();
5214                let mut req_builder = hyper::Request::builder()
5215                    .method(hyper::Method::DELETE)
5216                    .uri(url.clone().into_string())
5217                    .header(USER_AGENT, self.hub._user_agent.clone())
5218                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
5219
5220                let request = req_builder.body(hyper::body::Body::empty());
5221
5222                client.request(request.unwrap()).await
5223            };
5224
5225            match req_result {
5226                Err(err) => {
5227                    if let client::Retry::After(d) = dlg.http_error(&err) {
5228                        sleep(d);
5229                        continue;
5230                    }
5231                    dlg.finished(false);
5232                    return Err(client::Error::HttpError(err));
5233                }
5234                Ok(mut res) => {
5235                    if !res.status().is_success() {
5236                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
5237                        let (parts, _) = res.into_parts();
5238                        let body = hyper::Body::from(res_body_string.clone());
5239                        let restored_response = hyper::Response::from_parts(parts, body);
5240
5241                        let server_response =
5242                            json::from_str::<serde_json::Value>(&res_body_string).ok();
5243
5244                        if let client::Retry::After(d) =
5245                            dlg.http_failure(&restored_response, server_response.clone())
5246                        {
5247                            sleep(d);
5248                            continue;
5249                        }
5250
5251                        dlg.finished(false);
5252
5253                        return match server_response {
5254                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
5255                            None => Err(client::Error::Failure(restored_response)),
5256                        };
5257                    }
5258                    let result_value = res;
5259
5260                    dlg.finished(true);
5261                    return Ok(result_value);
5262                }
5263            }
5264        }
5265    }
5266
5267    /// The ID of the file.
5268    ///
5269    /// Sets the *file id* path property to the given value.
5270    ///
5271    /// Even though the property as already been set when instantiating this call,
5272    /// we provide this method for API completeness.
5273    pub fn file_id(mut self, new_value: &str) -> CommentDeleteCall<'a, S> {
5274        self._file_id = new_value.to_string();
5275        self
5276    }
5277    /// The ID of the comment.
5278    ///
5279    /// Sets the *comment id* path property to the given value.
5280    ///
5281    /// Even though the property as already been set when instantiating this call,
5282    /// we provide this method for API completeness.
5283    pub fn comment_id(mut self, new_value: &str) -> CommentDeleteCall<'a, S> {
5284        self._comment_id = new_value.to_string();
5285        self
5286    }
5287    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5288    /// while executing the actual API request.
5289    ///
5290    /// It should be used to handle progress information, and to implement a certain level of resilience.
5291    ///
5292    /// Sets the *delegate* property to the given value.
5293    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentDeleteCall<'a, S> {
5294        self._delegate = Some(new_value);
5295        self
5296    }
5297
5298    /// Set any additional parameter of the query string used in the request.
5299    /// It should be used to set parameters which are not yet available through their own
5300    /// setters.
5301    ///
5302    /// Please note that this method must not be used to set any of the known parameters
5303    /// which have their own setter method. If done anyway, the request will fail.
5304    ///
5305    /// # Additional Parameters
5306    ///
5307    /// * *alt* (query-string) - Data format for the response.
5308    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5309    /// * *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.
5310    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5311    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5312    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5313    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5314    pub fn param<T>(mut self, name: T, value: T) -> CommentDeleteCall<'a, S>
5315    where
5316        T: AsRef<str>,
5317    {
5318        self._additional_params
5319            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5320        self
5321    }
5322
5323    /// Identifies the authorization scope for the method you are building.
5324    ///
5325    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
5326    /// `Scope::Full`.
5327    ///
5328    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5329    /// tokens for more than one scope.
5330    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
5331    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
5332    /// function for details).
5333    ///
5334    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5335    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5336    /// sufficient, a read-write scope will do as well.
5337    pub fn add_scope<T, St>(mut self, scope: T) -> CommentDeleteCall<'a, S>
5338    where
5339        T: Into<Option<St>>,
5340        St: AsRef<str>,
5341    {
5342        match scope.into() {
5343            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
5344            None => None,
5345        };
5346        self
5347    }
5348}
5349
5350/// Gets a comment by ID.
5351///
5352/// A builder for the *get* method supported by a *comment* resource.
5353/// It is not used directly, but through a `CommentMethods` instance.
5354///
5355/// # Example
5356///
5357/// Instantiate a resource method builder
5358///
5359/// ```test_harness,no_run
5360/// # extern crate hyper;
5361/// # extern crate hyper_rustls;
5362/// # extern crate google_drive3 as drive3;
5363/// # async fn dox() {
5364/// # use std::default::Default;
5365/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
5366///
5367/// # let secret: oauth2::ApplicationSecret = Default::default();
5368/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
5369/// #         secret,
5370/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5371/// #     ).build().await.unwrap();
5372/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
5373/// // You can configure optional parameters by calling the respective setters at will, and
5374/// // execute the final call using `doit()`.
5375/// // Values shown here are possibly random and not representative !
5376/// let result = hub.comments().get("fileId", "commentId")
5377///              .include_deleted(true)
5378///              .doit().await;
5379/// # }
5380/// ```
5381pub struct CommentGetCall<'a, S>
5382where
5383    S: 'a,
5384{
5385    hub: &'a DriveHub<S>,
5386    _file_id: String,
5387    _comment_id: String,
5388    _include_deleted: Option<bool>,
5389    _delegate: Option<&'a mut dyn client::Delegate>,
5390    _additional_params: HashMap<String, String>,
5391    _scopes: BTreeMap<String, ()>,
5392}
5393
5394impl<'a, S> client::CallBuilder for CommentGetCall<'a, S> {}
5395
5396impl<'a, S> CommentGetCall<'a, S>
5397where
5398    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
5399    S::Response:
5400        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
5401    S::Future: Send + Unpin + 'static,
5402    S::Error: Into<Box<dyn StdError + Send + Sync>>,
5403{
5404    /// Perform the operation you have build so far.
5405    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Comment)> {
5406        use client::ToParts;
5407        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5408        use std::io::{Read, Seek};
5409        let mut dd = client::DefaultDelegate;
5410        let mut dlg: &mut dyn client::Delegate = match self._delegate {
5411            Some(d) => d,
5412            None => &mut dd,
5413        };
5414        dlg.begin(client::MethodInfo {
5415            id: "drive.comments.get",
5416            http_method: hyper::Method::GET,
5417        });
5418        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
5419        params.push(("fileId", self._file_id.to_string()));
5420        params.push(("commentId", self._comment_id.to_string()));
5421        if let Some(value) = self._include_deleted {
5422            params.push(("includeDeleted", value.to_string()));
5423        }
5424        for &field in ["alt", "fileId", "commentId", "includeDeleted"].iter() {
5425            if self._additional_params.contains_key(field) {
5426                dlg.finished(false);
5427                return Err(client::Error::FieldClash(field));
5428            }
5429        }
5430        for (name, value) in self._additional_params.iter() {
5431            params.push((&name, value.clone()));
5432        }
5433
5434        params.push(("alt", "json".to_string()));
5435
5436        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
5437        if self._scopes.len() == 0 {
5438            self._scopes
5439                .insert(Scope::Readonly.as_ref().to_string(), ());
5440        }
5441
5442        for &(find_this, param_name) in
5443            [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
5444        {
5445            let mut replace_with: Option<&str> = None;
5446            for &(name, ref value) in params.iter() {
5447                if name == param_name {
5448                    replace_with = Some(value);
5449                    break;
5450                }
5451            }
5452            url = url.replace(
5453                find_this,
5454                replace_with.expect("to find substitution value in params"),
5455            );
5456        }
5457        {
5458            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
5459            for param_name in ["commentId", "fileId"].iter() {
5460                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
5461                    indices_for_removal.push(index);
5462                }
5463            }
5464            for &index in indices_for_removal.iter() {
5465                params.remove(index);
5466            }
5467        }
5468
5469        let url = url::Url::parse_with_params(&url, params).unwrap();
5470
5471        loop {
5472            let token = match self
5473                .hub
5474                .auth
5475                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
5476                .await
5477            {
5478                Ok(token) => token.clone(),
5479                Err(err) => match dlg.token(&err) {
5480                    Some(token) => token,
5481                    None => {
5482                        dlg.finished(false);
5483                        return Err(client::Error::MissingToken(err));
5484                    }
5485                },
5486            };
5487            let mut req_result = {
5488                let client = &self.hub.client;
5489                dlg.pre_request();
5490                let mut req_builder = hyper::Request::builder()
5491                    .method(hyper::Method::GET)
5492                    .uri(url.clone().into_string())
5493                    .header(USER_AGENT, self.hub._user_agent.clone())
5494                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
5495
5496                let request = req_builder.body(hyper::body::Body::empty());
5497
5498                client.request(request.unwrap()).await
5499            };
5500
5501            match req_result {
5502                Err(err) => {
5503                    if let client::Retry::After(d) = dlg.http_error(&err) {
5504                        sleep(d);
5505                        continue;
5506                    }
5507                    dlg.finished(false);
5508                    return Err(client::Error::HttpError(err));
5509                }
5510                Ok(mut res) => {
5511                    if !res.status().is_success() {
5512                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
5513                        let (parts, _) = res.into_parts();
5514                        let body = hyper::Body::from(res_body_string.clone());
5515                        let restored_response = hyper::Response::from_parts(parts, body);
5516
5517                        let server_response =
5518                            json::from_str::<serde_json::Value>(&res_body_string).ok();
5519
5520                        if let client::Retry::After(d) =
5521                            dlg.http_failure(&restored_response, server_response.clone())
5522                        {
5523                            sleep(d);
5524                            continue;
5525                        }
5526
5527                        dlg.finished(false);
5528
5529                        return match server_response {
5530                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
5531                            None => Err(client::Error::Failure(restored_response)),
5532                        };
5533                    }
5534                    let result_value = {
5535                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
5536
5537                        match json::from_str(&res_body_string) {
5538                            Ok(decoded) => (res, decoded),
5539                            Err(err) => {
5540                                dlg.response_json_decode_error(&res_body_string, &err);
5541                                return Err(client::Error::JsonDecodeError(res_body_string, err));
5542                            }
5543                        }
5544                    };
5545
5546                    dlg.finished(true);
5547                    return Ok(result_value);
5548                }
5549            }
5550        }
5551    }
5552
5553    /// The ID of the file.
5554    ///
5555    /// Sets the *file id* path property to the given value.
5556    ///
5557    /// Even though the property as already been set when instantiating this call,
5558    /// we provide this method for API completeness.
5559    pub fn file_id(mut self, new_value: &str) -> CommentGetCall<'a, S> {
5560        self._file_id = new_value.to_string();
5561        self
5562    }
5563    /// The ID of the comment.
5564    ///
5565    /// Sets the *comment id* path property to the given value.
5566    ///
5567    /// Even though the property as already been set when instantiating this call,
5568    /// we provide this method for API completeness.
5569    pub fn comment_id(mut self, new_value: &str) -> CommentGetCall<'a, S> {
5570        self._comment_id = new_value.to_string();
5571        self
5572    }
5573    /// Whether to return deleted comments. Deleted comments will not include their original content.
5574    ///
5575    /// Sets the *include deleted* query property to the given value.
5576    pub fn include_deleted(mut self, new_value: bool) -> CommentGetCall<'a, S> {
5577        self._include_deleted = Some(new_value);
5578        self
5579    }
5580    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5581    /// while executing the actual API request.
5582    ///
5583    /// It should be used to handle progress information, and to implement a certain level of resilience.
5584    ///
5585    /// Sets the *delegate* property to the given value.
5586    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentGetCall<'a, S> {
5587        self._delegate = Some(new_value);
5588        self
5589    }
5590
5591    /// Set any additional parameter of the query string used in the request.
5592    /// It should be used to set parameters which are not yet available through their own
5593    /// setters.
5594    ///
5595    /// Please note that this method must not be used to set any of the known parameters
5596    /// which have their own setter method. If done anyway, the request will fail.
5597    ///
5598    /// # Additional Parameters
5599    ///
5600    /// * *alt* (query-string) - Data format for the response.
5601    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5602    /// * *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.
5603    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5604    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5605    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5606    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5607    pub fn param<T>(mut self, name: T, value: T) -> CommentGetCall<'a, S>
5608    where
5609        T: AsRef<str>,
5610    {
5611        self._additional_params
5612            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5613        self
5614    }
5615
5616    /// Identifies the authorization scope for the method you are building.
5617    ///
5618    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
5619    /// `Scope::Readonly`.
5620    ///
5621    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5622    /// tokens for more than one scope.
5623    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
5624    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
5625    /// function for details).
5626    ///
5627    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5628    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5629    /// sufficient, a read-write scope will do as well.
5630    pub fn add_scope<T, St>(mut self, scope: T) -> CommentGetCall<'a, S>
5631    where
5632        T: Into<Option<St>>,
5633        St: AsRef<str>,
5634    {
5635        match scope.into() {
5636            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
5637            None => None,
5638        };
5639        self
5640    }
5641}
5642
5643/// Lists a file's comments.
5644///
5645/// A builder for the *list* method supported by a *comment* resource.
5646/// It is not used directly, but through a `CommentMethods` instance.
5647///
5648/// # Example
5649///
5650/// Instantiate a resource method builder
5651///
5652/// ```test_harness,no_run
5653/// # extern crate hyper;
5654/// # extern crate hyper_rustls;
5655/// # extern crate google_drive3 as drive3;
5656/// # async fn dox() {
5657/// # use std::default::Default;
5658/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
5659///
5660/// # let secret: oauth2::ApplicationSecret = Default::default();
5661/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
5662/// #         secret,
5663/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5664/// #     ).build().await.unwrap();
5665/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
5666/// // You can configure optional parameters by calling the respective setters at will, and
5667/// // execute the final call using `doit()`.
5668/// // Values shown here are possibly random and not representative !
5669/// let result = hub.comments().list("fileId")
5670///              .start_modified_time("et")
5671///              .page_token("tempor")
5672///              .page_size(-32)
5673///              .include_deleted(true)
5674///              .doit().await;
5675/// # }
5676/// ```
5677pub struct CommentListCall<'a, S>
5678where
5679    S: 'a,
5680{
5681    hub: &'a DriveHub<S>,
5682    _file_id: String,
5683    _start_modified_time: Option<String>,
5684    _page_token: Option<String>,
5685    _page_size: Option<i32>,
5686    _include_deleted: Option<bool>,
5687    _delegate: Option<&'a mut dyn client::Delegate>,
5688    _additional_params: HashMap<String, String>,
5689    _scopes: BTreeMap<String, ()>,
5690}
5691
5692impl<'a, S> client::CallBuilder for CommentListCall<'a, S> {}
5693
5694impl<'a, S> CommentListCall<'a, S>
5695where
5696    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
5697    S::Response:
5698        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
5699    S::Future: Send + Unpin + 'static,
5700    S::Error: Into<Box<dyn StdError + Send + Sync>>,
5701{
5702    /// Perform the operation you have build so far.
5703    pub async fn doit(
5704        mut self,
5705    ) -> client::Result<(hyper::Response<hyper::body::Body>, CommentList)> {
5706        use client::ToParts;
5707        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5708        use std::io::{Read, Seek};
5709        let mut dd = client::DefaultDelegate;
5710        let mut dlg: &mut dyn client::Delegate = match self._delegate {
5711            Some(d) => d,
5712            None => &mut dd,
5713        };
5714        dlg.begin(client::MethodInfo {
5715            id: "drive.comments.list",
5716            http_method: hyper::Method::GET,
5717        });
5718        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
5719        params.push(("fileId", self._file_id.to_string()));
5720        if let Some(value) = self._start_modified_time {
5721            params.push(("startModifiedTime", value.to_string()));
5722        }
5723        if let Some(value) = self._page_token {
5724            params.push(("pageToken", value.to_string()));
5725        }
5726        if let Some(value) = self._page_size {
5727            params.push(("pageSize", value.to_string()));
5728        }
5729        if let Some(value) = self._include_deleted {
5730            params.push(("includeDeleted", value.to_string()));
5731        }
5732        for &field in [
5733            "alt",
5734            "fileId",
5735            "startModifiedTime",
5736            "pageToken",
5737            "pageSize",
5738            "includeDeleted",
5739        ]
5740        .iter()
5741        {
5742            if self._additional_params.contains_key(field) {
5743                dlg.finished(false);
5744                return Err(client::Error::FieldClash(field));
5745            }
5746        }
5747        for (name, value) in self._additional_params.iter() {
5748            params.push((&name, value.clone()));
5749        }
5750
5751        params.push(("alt", "json".to_string()));
5752
5753        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments";
5754        if self._scopes.len() == 0 {
5755            self._scopes
5756                .insert(Scope::Readonly.as_ref().to_string(), ());
5757        }
5758
5759        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
5760            let mut replace_with: Option<&str> = None;
5761            for &(name, ref value) in params.iter() {
5762                if name == param_name {
5763                    replace_with = Some(value);
5764                    break;
5765                }
5766            }
5767            url = url.replace(
5768                find_this,
5769                replace_with.expect("to find substitution value in params"),
5770            );
5771        }
5772        {
5773            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
5774            for param_name in ["fileId"].iter() {
5775                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
5776                    indices_for_removal.push(index);
5777                }
5778            }
5779            for &index in indices_for_removal.iter() {
5780                params.remove(index);
5781            }
5782        }
5783
5784        let url = url::Url::parse_with_params(&url, params).unwrap();
5785
5786        loop {
5787            let token = match self
5788                .hub
5789                .auth
5790                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
5791                .await
5792            {
5793                Ok(token) => token.clone(),
5794                Err(err) => match dlg.token(&err) {
5795                    Some(token) => token,
5796                    None => {
5797                        dlg.finished(false);
5798                        return Err(client::Error::MissingToken(err));
5799                    }
5800                },
5801            };
5802            let mut req_result = {
5803                let client = &self.hub.client;
5804                dlg.pre_request();
5805                let mut req_builder = hyper::Request::builder()
5806                    .method(hyper::Method::GET)
5807                    .uri(url.clone().into_string())
5808                    .header(USER_AGENT, self.hub._user_agent.clone())
5809                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
5810
5811                let request = req_builder.body(hyper::body::Body::empty());
5812
5813                client.request(request.unwrap()).await
5814            };
5815
5816            match req_result {
5817                Err(err) => {
5818                    if let client::Retry::After(d) = dlg.http_error(&err) {
5819                        sleep(d);
5820                        continue;
5821                    }
5822                    dlg.finished(false);
5823                    return Err(client::Error::HttpError(err));
5824                }
5825                Ok(mut res) => {
5826                    if !res.status().is_success() {
5827                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
5828                        let (parts, _) = res.into_parts();
5829                        let body = hyper::Body::from(res_body_string.clone());
5830                        let restored_response = hyper::Response::from_parts(parts, body);
5831
5832                        let server_response =
5833                            json::from_str::<serde_json::Value>(&res_body_string).ok();
5834
5835                        if let client::Retry::After(d) =
5836                            dlg.http_failure(&restored_response, server_response.clone())
5837                        {
5838                            sleep(d);
5839                            continue;
5840                        }
5841
5842                        dlg.finished(false);
5843
5844                        return match server_response {
5845                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
5846                            None => Err(client::Error::Failure(restored_response)),
5847                        };
5848                    }
5849                    let result_value = {
5850                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
5851
5852                        match json::from_str(&res_body_string) {
5853                            Ok(decoded) => (res, decoded),
5854                            Err(err) => {
5855                                dlg.response_json_decode_error(&res_body_string, &err);
5856                                return Err(client::Error::JsonDecodeError(res_body_string, err));
5857                            }
5858                        }
5859                    };
5860
5861                    dlg.finished(true);
5862                    return Ok(result_value);
5863                }
5864            }
5865        }
5866    }
5867
5868    /// The ID of the file.
5869    ///
5870    /// Sets the *file id* path property to the given value.
5871    ///
5872    /// Even though the property as already been set when instantiating this call,
5873    /// we provide this method for API completeness.
5874    pub fn file_id(mut self, new_value: &str) -> CommentListCall<'a, S> {
5875        self._file_id = new_value.to_string();
5876        self
5877    }
5878    /// The minimum value of 'modifiedTime' for the result comments (RFC 3339 date-time).
5879    ///
5880    /// Sets the *start modified time* query property to the given value.
5881    pub fn start_modified_time(mut self, new_value: &str) -> CommentListCall<'a, S> {
5882        self._start_modified_time = Some(new_value.to_string());
5883        self
5884    }
5885    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
5886    ///
5887    /// Sets the *page token* query property to the given value.
5888    pub fn page_token(mut self, new_value: &str) -> CommentListCall<'a, S> {
5889        self._page_token = Some(new_value.to_string());
5890        self
5891    }
5892    /// The maximum number of comments to return per page.
5893    ///
5894    /// Sets the *page size* query property to the given value.
5895    pub fn page_size(mut self, new_value: i32) -> CommentListCall<'a, S> {
5896        self._page_size = Some(new_value);
5897        self
5898    }
5899    /// Whether to include deleted comments. Deleted comments will not include their original content.
5900    ///
5901    /// Sets the *include deleted* query property to the given value.
5902    pub fn include_deleted(mut self, new_value: bool) -> CommentListCall<'a, S> {
5903        self._include_deleted = Some(new_value);
5904        self
5905    }
5906    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5907    /// while executing the actual API request.
5908    ///
5909    /// It should be used to handle progress information, and to implement a certain level of resilience.
5910    ///
5911    /// Sets the *delegate* property to the given value.
5912    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentListCall<'a, S> {
5913        self._delegate = Some(new_value);
5914        self
5915    }
5916
5917    /// Set any additional parameter of the query string used in the request.
5918    /// It should be used to set parameters which are not yet available through their own
5919    /// setters.
5920    ///
5921    /// Please note that this method must not be used to set any of the known parameters
5922    /// which have their own setter method. If done anyway, the request will fail.
5923    ///
5924    /// # Additional Parameters
5925    ///
5926    /// * *alt* (query-string) - Data format for the response.
5927    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5928    /// * *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.
5929    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5930    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5931    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5932    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5933    pub fn param<T>(mut self, name: T, value: T) -> CommentListCall<'a, S>
5934    where
5935        T: AsRef<str>,
5936    {
5937        self._additional_params
5938            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5939        self
5940    }
5941
5942    /// Identifies the authorization scope for the method you are building.
5943    ///
5944    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
5945    /// `Scope::Readonly`.
5946    ///
5947    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5948    /// tokens for more than one scope.
5949    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
5950    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
5951    /// function for details).
5952    ///
5953    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5954    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5955    /// sufficient, a read-write scope will do as well.
5956    pub fn add_scope<T, St>(mut self, scope: T) -> CommentListCall<'a, S>
5957    where
5958        T: Into<Option<St>>,
5959        St: AsRef<str>,
5960    {
5961        match scope.into() {
5962            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
5963            None => None,
5964        };
5965        self
5966    }
5967}
5968
5969/// Updates a comment with patch semantics.
5970///
5971/// A builder for the *update* method supported by a *comment* resource.
5972/// It is not used directly, but through a `CommentMethods` instance.
5973///
5974/// # Example
5975///
5976/// Instantiate a resource method builder
5977///
5978/// ```test_harness,no_run
5979/// # extern crate hyper;
5980/// # extern crate hyper_rustls;
5981/// # extern crate google_drive3 as drive3;
5982/// use drive3::api::Comment;
5983/// # async fn dox() {
5984/// # use std::default::Default;
5985/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
5986///
5987/// # let secret: oauth2::ApplicationSecret = Default::default();
5988/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
5989/// #         secret,
5990/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5991/// #     ).build().await.unwrap();
5992/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
5993/// // As the method needs a request, you would usually fill it with the desired information
5994/// // into the respective structure. Some of the parts shown here might not be applicable !
5995/// // Values shown here are possibly random and not representative !
5996/// let mut req = Comment::default();
5997///
5998/// // You can configure optional parameters by calling the respective setters at will, and
5999/// // execute the final call using `doit()`.
6000/// // Values shown here are possibly random and not representative !
6001/// let result = hub.comments().update(req, "fileId", "commentId")
6002///              .doit().await;
6003/// # }
6004/// ```
6005pub struct CommentUpdateCall<'a, S>
6006where
6007    S: 'a,
6008{
6009    hub: &'a DriveHub<S>,
6010    _request: Comment,
6011    _file_id: String,
6012    _comment_id: String,
6013    _delegate: Option<&'a mut dyn client::Delegate>,
6014    _additional_params: HashMap<String, String>,
6015    _scopes: BTreeMap<String, ()>,
6016}
6017
6018impl<'a, S> client::CallBuilder for CommentUpdateCall<'a, S> {}
6019
6020impl<'a, S> CommentUpdateCall<'a, S>
6021where
6022    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
6023    S::Response:
6024        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
6025    S::Future: Send + Unpin + 'static,
6026    S::Error: Into<Box<dyn StdError + Send + Sync>>,
6027{
6028    /// Perform the operation you have build so far.
6029    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Comment)> {
6030        use client::ToParts;
6031        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6032        use std::io::{Read, Seek};
6033        let mut dd = client::DefaultDelegate;
6034        let mut dlg: &mut dyn client::Delegate = match self._delegate {
6035            Some(d) => d,
6036            None => &mut dd,
6037        };
6038        dlg.begin(client::MethodInfo {
6039            id: "drive.comments.update",
6040            http_method: hyper::Method::PATCH,
6041        });
6042        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
6043        params.push(("fileId", self._file_id.to_string()));
6044        params.push(("commentId", self._comment_id.to_string()));
6045        for &field in ["alt", "fileId", "commentId"].iter() {
6046            if self._additional_params.contains_key(field) {
6047                dlg.finished(false);
6048                return Err(client::Error::FieldClash(field));
6049            }
6050        }
6051        for (name, value) in self._additional_params.iter() {
6052            params.push((&name, value.clone()));
6053        }
6054
6055        params.push(("alt", "json".to_string()));
6056
6057        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}";
6058        if self._scopes.len() == 0 {
6059            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
6060        }
6061
6062        for &(find_this, param_name) in
6063            [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
6064        {
6065            let mut replace_with: Option<&str> = None;
6066            for &(name, ref value) in params.iter() {
6067                if name == param_name {
6068                    replace_with = Some(value);
6069                    break;
6070                }
6071            }
6072            url = url.replace(
6073                find_this,
6074                replace_with.expect("to find substitution value in params"),
6075            );
6076        }
6077        {
6078            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
6079            for param_name in ["commentId", "fileId"].iter() {
6080                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6081                    indices_for_removal.push(index);
6082                }
6083            }
6084            for &index in indices_for_removal.iter() {
6085                params.remove(index);
6086            }
6087        }
6088
6089        let url = url::Url::parse_with_params(&url, params).unwrap();
6090
6091        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
6092        let mut request_value_reader = {
6093            let mut value = json::value::to_value(&self._request).expect("serde to work");
6094            client::remove_json_null_values(&mut value);
6095            let mut dst = io::Cursor::new(Vec::with_capacity(128));
6096            json::to_writer(&mut dst, &value).unwrap();
6097            dst
6098        };
6099        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
6100        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6101
6102        loop {
6103            let token = match self
6104                .hub
6105                .auth
6106                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
6107                .await
6108            {
6109                Ok(token) => token.clone(),
6110                Err(err) => match dlg.token(&err) {
6111                    Some(token) => token,
6112                    None => {
6113                        dlg.finished(false);
6114                        return Err(client::Error::MissingToken(err));
6115                    }
6116                },
6117            };
6118            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6119            let mut req_result = {
6120                let client = &self.hub.client;
6121                dlg.pre_request();
6122                let mut req_builder = hyper::Request::builder()
6123                    .method(hyper::Method::PATCH)
6124                    .uri(url.clone().into_string())
6125                    .header(USER_AGENT, self.hub._user_agent.clone())
6126                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
6127
6128                let request = req_builder
6129                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
6130                    .header(CONTENT_LENGTH, request_size as u64)
6131                    .body(hyper::body::Body::from(
6132                        request_value_reader.get_ref().clone(),
6133                    ));
6134
6135                client.request(request.unwrap()).await
6136            };
6137
6138            match req_result {
6139                Err(err) => {
6140                    if let client::Retry::After(d) = dlg.http_error(&err) {
6141                        sleep(d);
6142                        continue;
6143                    }
6144                    dlg.finished(false);
6145                    return Err(client::Error::HttpError(err));
6146                }
6147                Ok(mut res) => {
6148                    if !res.status().is_success() {
6149                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6150                        let (parts, _) = res.into_parts();
6151                        let body = hyper::Body::from(res_body_string.clone());
6152                        let restored_response = hyper::Response::from_parts(parts, body);
6153
6154                        let server_response =
6155                            json::from_str::<serde_json::Value>(&res_body_string).ok();
6156
6157                        if let client::Retry::After(d) =
6158                            dlg.http_failure(&restored_response, server_response.clone())
6159                        {
6160                            sleep(d);
6161                            continue;
6162                        }
6163
6164                        dlg.finished(false);
6165
6166                        return match server_response {
6167                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
6168                            None => Err(client::Error::Failure(restored_response)),
6169                        };
6170                    }
6171                    let result_value = {
6172                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6173
6174                        match json::from_str(&res_body_string) {
6175                            Ok(decoded) => (res, decoded),
6176                            Err(err) => {
6177                                dlg.response_json_decode_error(&res_body_string, &err);
6178                                return Err(client::Error::JsonDecodeError(res_body_string, err));
6179                            }
6180                        }
6181                    };
6182
6183                    dlg.finished(true);
6184                    return Ok(result_value);
6185                }
6186            }
6187        }
6188    }
6189
6190    ///
6191    /// Sets the *request* property to the given value.
6192    ///
6193    /// Even though the property as already been set when instantiating this call,
6194    /// we provide this method for API completeness.
6195    pub fn request(mut self, new_value: Comment) -> CommentUpdateCall<'a, S> {
6196        self._request = new_value;
6197        self
6198    }
6199    /// The ID of the file.
6200    ///
6201    /// Sets the *file id* path property to the given value.
6202    ///
6203    /// Even though the property as already been set when instantiating this call,
6204    /// we provide this method for API completeness.
6205    pub fn file_id(mut self, new_value: &str) -> CommentUpdateCall<'a, S> {
6206        self._file_id = new_value.to_string();
6207        self
6208    }
6209    /// The ID of the comment.
6210    ///
6211    /// Sets the *comment id* path property to the given value.
6212    ///
6213    /// Even though the property as already been set when instantiating this call,
6214    /// we provide this method for API completeness.
6215    pub fn comment_id(mut self, new_value: &str) -> CommentUpdateCall<'a, S> {
6216        self._comment_id = new_value.to_string();
6217        self
6218    }
6219    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6220    /// while executing the actual API request.
6221    ///
6222    /// It should be used to handle progress information, and to implement a certain level of resilience.
6223    ///
6224    /// Sets the *delegate* property to the given value.
6225    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> CommentUpdateCall<'a, S> {
6226        self._delegate = Some(new_value);
6227        self
6228    }
6229
6230    /// Set any additional parameter of the query string used in the request.
6231    /// It should be used to set parameters which are not yet available through their own
6232    /// setters.
6233    ///
6234    /// Please note that this method must not be used to set any of the known parameters
6235    /// which have their own setter method. If done anyway, the request will fail.
6236    ///
6237    /// # Additional Parameters
6238    ///
6239    /// * *alt* (query-string) - Data format for the response.
6240    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6241    /// * *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.
6242    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6243    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6244    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6245    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6246    pub fn param<T>(mut self, name: T, value: T) -> CommentUpdateCall<'a, S>
6247    where
6248        T: AsRef<str>,
6249    {
6250        self._additional_params
6251            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6252        self
6253    }
6254
6255    /// Identifies the authorization scope for the method you are building.
6256    ///
6257    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6258    /// `Scope::Full`.
6259    ///
6260    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6261    /// tokens for more than one scope.
6262    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6263    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6264    /// function for details).
6265    ///
6266    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6267    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6268    /// sufficient, a read-write scope will do as well.
6269    pub fn add_scope<T, St>(mut self, scope: T) -> CommentUpdateCall<'a, S>
6270    where
6271        T: Into<Option<St>>,
6272        St: AsRef<str>,
6273    {
6274        match scope.into() {
6275            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6276            None => None,
6277        };
6278        self
6279    }
6280}
6281
6282/// Creates a new shared drive.
6283///
6284/// A builder for the *create* method supported by a *drive* resource.
6285/// It is not used directly, but through a `DriveMethods` instance.
6286///
6287/// # Example
6288///
6289/// Instantiate a resource method builder
6290///
6291/// ```test_harness,no_run
6292/// # extern crate hyper;
6293/// # extern crate hyper_rustls;
6294/// # extern crate google_drive3 as drive3;
6295/// use drive3::api::Drive;
6296/// # async fn dox() {
6297/// # use std::default::Default;
6298/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
6299///
6300/// # let secret: oauth2::ApplicationSecret = Default::default();
6301/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
6302/// #         secret,
6303/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6304/// #     ).build().await.unwrap();
6305/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
6306/// // As the method needs a request, you would usually fill it with the desired information
6307/// // into the respective structure. Some of the parts shown here might not be applicable !
6308/// // Values shown here are possibly random and not representative !
6309/// let mut req = Drive::default();
6310///
6311/// // You can configure optional parameters by calling the respective setters at will, and
6312/// // execute the final call using `doit()`.
6313/// // Values shown here are possibly random and not representative !
6314/// let result = hub.drives().create(req, "requestId")
6315///              .doit().await;
6316/// # }
6317/// ```
6318pub struct DriveCreateCall<'a, S>
6319where
6320    S: 'a,
6321{
6322    hub: &'a DriveHub<S>,
6323    _request: Drive,
6324    _request_id: String,
6325    _delegate: Option<&'a mut dyn client::Delegate>,
6326    _additional_params: HashMap<String, String>,
6327    _scopes: BTreeMap<String, ()>,
6328}
6329
6330impl<'a, S> client::CallBuilder for DriveCreateCall<'a, S> {}
6331
6332impl<'a, S> DriveCreateCall<'a, S>
6333where
6334    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
6335    S::Response:
6336        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
6337    S::Future: Send + Unpin + 'static,
6338    S::Error: Into<Box<dyn StdError + Send + Sync>>,
6339{
6340    /// Perform the operation you have build so far.
6341    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Drive)> {
6342        use client::ToParts;
6343        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6344        use std::io::{Read, Seek};
6345        let mut dd = client::DefaultDelegate;
6346        let mut dlg: &mut dyn client::Delegate = match self._delegate {
6347            Some(d) => d,
6348            None => &mut dd,
6349        };
6350        dlg.begin(client::MethodInfo {
6351            id: "drive.drives.create",
6352            http_method: hyper::Method::POST,
6353        });
6354        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
6355        params.push(("requestId", self._request_id.to_string()));
6356        for &field in ["alt", "requestId"].iter() {
6357            if self._additional_params.contains_key(field) {
6358                dlg.finished(false);
6359                return Err(client::Error::FieldClash(field));
6360            }
6361        }
6362        for (name, value) in self._additional_params.iter() {
6363            params.push((&name, value.clone()));
6364        }
6365
6366        params.push(("alt", "json".to_string()));
6367
6368        let mut url = self.hub._base_url.clone() + "drives";
6369        if self._scopes.len() == 0 {
6370            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
6371        }
6372
6373        let url = url::Url::parse_with_params(&url, params).unwrap();
6374
6375        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
6376        let mut request_value_reader = {
6377            let mut value = json::value::to_value(&self._request).expect("serde to work");
6378            client::remove_json_null_values(&mut value);
6379            let mut dst = io::Cursor::new(Vec::with_capacity(128));
6380            json::to_writer(&mut dst, &value).unwrap();
6381            dst
6382        };
6383        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
6384        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6385
6386        loop {
6387            let token = match self
6388                .hub
6389                .auth
6390                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
6391                .await
6392            {
6393                Ok(token) => token.clone(),
6394                Err(err) => match dlg.token(&err) {
6395                    Some(token) => token,
6396                    None => {
6397                        dlg.finished(false);
6398                        return Err(client::Error::MissingToken(err));
6399                    }
6400                },
6401            };
6402            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
6403            let mut req_result = {
6404                let client = &self.hub.client;
6405                dlg.pre_request();
6406                let mut req_builder = hyper::Request::builder()
6407                    .method(hyper::Method::POST)
6408                    .uri(url.clone().into_string())
6409                    .header(USER_AGENT, self.hub._user_agent.clone())
6410                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
6411
6412                let request = req_builder
6413                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
6414                    .header(CONTENT_LENGTH, request_size as u64)
6415                    .body(hyper::body::Body::from(
6416                        request_value_reader.get_ref().clone(),
6417                    ));
6418
6419                client.request(request.unwrap()).await
6420            };
6421
6422            match req_result {
6423                Err(err) => {
6424                    if let client::Retry::After(d) = dlg.http_error(&err) {
6425                        sleep(d);
6426                        continue;
6427                    }
6428                    dlg.finished(false);
6429                    return Err(client::Error::HttpError(err));
6430                }
6431                Ok(mut res) => {
6432                    if !res.status().is_success() {
6433                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6434                        let (parts, _) = res.into_parts();
6435                        let body = hyper::Body::from(res_body_string.clone());
6436                        let restored_response = hyper::Response::from_parts(parts, body);
6437
6438                        let server_response =
6439                            json::from_str::<serde_json::Value>(&res_body_string).ok();
6440
6441                        if let client::Retry::After(d) =
6442                            dlg.http_failure(&restored_response, server_response.clone())
6443                        {
6444                            sleep(d);
6445                            continue;
6446                        }
6447
6448                        dlg.finished(false);
6449
6450                        return match server_response {
6451                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
6452                            None => Err(client::Error::Failure(restored_response)),
6453                        };
6454                    }
6455                    let result_value = {
6456                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6457
6458                        match json::from_str(&res_body_string) {
6459                            Ok(decoded) => (res, decoded),
6460                            Err(err) => {
6461                                dlg.response_json_decode_error(&res_body_string, &err);
6462                                return Err(client::Error::JsonDecodeError(res_body_string, err));
6463                            }
6464                        }
6465                    };
6466
6467                    dlg.finished(true);
6468                    return Ok(result_value);
6469                }
6470            }
6471        }
6472    }
6473
6474    ///
6475    /// Sets the *request* property to the given value.
6476    ///
6477    /// Even though the property as already been set when instantiating this call,
6478    /// we provide this method for API completeness.
6479    pub fn request(mut self, new_value: Drive) -> DriveCreateCall<'a, S> {
6480        self._request = new_value;
6481        self
6482    }
6483    /// An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a shared drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same shared drive. If the shared drive already exists a 409 error will be returned.
6484    ///
6485    /// Sets the *request id* query property to the given value.
6486    ///
6487    /// Even though the property as already been set when instantiating this call,
6488    /// we provide this method for API completeness.
6489    pub fn request_id(mut self, new_value: &str) -> DriveCreateCall<'a, S> {
6490        self._request_id = new_value.to_string();
6491        self
6492    }
6493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6494    /// while executing the actual API request.
6495    ///
6496    /// It should be used to handle progress information, and to implement a certain level of resilience.
6497    ///
6498    /// Sets the *delegate* property to the given value.
6499    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveCreateCall<'a, S> {
6500        self._delegate = Some(new_value);
6501        self
6502    }
6503
6504    /// Set any additional parameter of the query string used in the request.
6505    /// It should be used to set parameters which are not yet available through their own
6506    /// setters.
6507    ///
6508    /// Please note that this method must not be used to set any of the known parameters
6509    /// which have their own setter method. If done anyway, the request will fail.
6510    ///
6511    /// # Additional Parameters
6512    ///
6513    /// * *alt* (query-string) - Data format for the response.
6514    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6515    /// * *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.
6516    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6517    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6518    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6519    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6520    pub fn param<T>(mut self, name: T, value: T) -> DriveCreateCall<'a, S>
6521    where
6522        T: AsRef<str>,
6523    {
6524        self._additional_params
6525            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6526        self
6527    }
6528
6529    /// Identifies the authorization scope for the method you are building.
6530    ///
6531    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6532    /// `Scope::Full`.
6533    ///
6534    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6535    /// tokens for more than one scope.
6536    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6537    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6538    /// function for details).
6539    ///
6540    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6541    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6542    /// sufficient, a read-write scope will do as well.
6543    pub fn add_scope<T, St>(mut self, scope: T) -> DriveCreateCall<'a, S>
6544    where
6545        T: Into<Option<St>>,
6546        St: AsRef<str>,
6547    {
6548        match scope.into() {
6549            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6550            None => None,
6551        };
6552        self
6553    }
6554}
6555
6556/// Permanently deletes a shared drive for which the user is an organizer. The shared drive cannot contain any untrashed items.
6557///
6558/// A builder for the *delete* method supported by a *drive* resource.
6559/// It is not used directly, but through a `DriveMethods` instance.
6560///
6561/// # Example
6562///
6563/// Instantiate a resource method builder
6564///
6565/// ```test_harness,no_run
6566/// # extern crate hyper;
6567/// # extern crate hyper_rustls;
6568/// # extern crate google_drive3 as drive3;
6569/// # async fn dox() {
6570/// # use std::default::Default;
6571/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
6572///
6573/// # let secret: oauth2::ApplicationSecret = Default::default();
6574/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
6575/// #         secret,
6576/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6577/// #     ).build().await.unwrap();
6578/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
6579/// // You can configure optional parameters by calling the respective setters at will, and
6580/// // execute the final call using `doit()`.
6581/// // Values shown here are possibly random and not representative !
6582/// let result = hub.drives().delete("driveId")
6583///              .doit().await;
6584/// # }
6585/// ```
6586pub struct DriveDeleteCall<'a, S>
6587where
6588    S: 'a,
6589{
6590    hub: &'a DriveHub<S>,
6591    _drive_id: String,
6592    _delegate: Option<&'a mut dyn client::Delegate>,
6593    _additional_params: HashMap<String, String>,
6594    _scopes: BTreeMap<String, ()>,
6595}
6596
6597impl<'a, S> client::CallBuilder for DriveDeleteCall<'a, S> {}
6598
6599impl<'a, S> DriveDeleteCall<'a, S>
6600where
6601    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
6602    S::Response:
6603        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
6604    S::Future: Send + Unpin + 'static,
6605    S::Error: Into<Box<dyn StdError + Send + Sync>>,
6606{
6607    /// Perform the operation you have build so far.
6608    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
6609        use client::ToParts;
6610        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6611        use std::io::{Read, Seek};
6612        let mut dd = client::DefaultDelegate;
6613        let mut dlg: &mut dyn client::Delegate = match self._delegate {
6614            Some(d) => d,
6615            None => &mut dd,
6616        };
6617        dlg.begin(client::MethodInfo {
6618            id: "drive.drives.delete",
6619            http_method: hyper::Method::DELETE,
6620        });
6621        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
6622        params.push(("driveId", self._drive_id.to_string()));
6623        for &field in ["driveId"].iter() {
6624            if self._additional_params.contains_key(field) {
6625                dlg.finished(false);
6626                return Err(client::Error::FieldClash(field));
6627            }
6628        }
6629        for (name, value) in self._additional_params.iter() {
6630            params.push((&name, value.clone()));
6631        }
6632
6633        let mut url = self.hub._base_url.clone() + "drives/{driveId}";
6634        if self._scopes.len() == 0 {
6635            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
6636        }
6637
6638        for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
6639            let mut replace_with: Option<&str> = None;
6640            for &(name, ref value) in params.iter() {
6641                if name == param_name {
6642                    replace_with = Some(value);
6643                    break;
6644                }
6645            }
6646            url = url.replace(
6647                find_this,
6648                replace_with.expect("to find substitution value in params"),
6649            );
6650        }
6651        {
6652            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6653            for param_name in ["driveId"].iter() {
6654                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6655                    indices_for_removal.push(index);
6656                }
6657            }
6658            for &index in indices_for_removal.iter() {
6659                params.remove(index);
6660            }
6661        }
6662
6663        let url = url::Url::parse_with_params(&url, params).unwrap();
6664
6665        loop {
6666            let token = match self
6667                .hub
6668                .auth
6669                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
6670                .await
6671            {
6672                Ok(token) => token.clone(),
6673                Err(err) => match dlg.token(&err) {
6674                    Some(token) => token,
6675                    None => {
6676                        dlg.finished(false);
6677                        return Err(client::Error::MissingToken(err));
6678                    }
6679                },
6680            };
6681            let mut req_result = {
6682                let client = &self.hub.client;
6683                dlg.pre_request();
6684                let mut req_builder = hyper::Request::builder()
6685                    .method(hyper::Method::DELETE)
6686                    .uri(url.clone().into_string())
6687                    .header(USER_AGENT, self.hub._user_agent.clone())
6688                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
6689
6690                let request = req_builder.body(hyper::body::Body::empty());
6691
6692                client.request(request.unwrap()).await
6693            };
6694
6695            match req_result {
6696                Err(err) => {
6697                    if let client::Retry::After(d) = dlg.http_error(&err) {
6698                        sleep(d);
6699                        continue;
6700                    }
6701                    dlg.finished(false);
6702                    return Err(client::Error::HttpError(err));
6703                }
6704                Ok(mut res) => {
6705                    if !res.status().is_success() {
6706                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6707                        let (parts, _) = res.into_parts();
6708                        let body = hyper::Body::from(res_body_string.clone());
6709                        let restored_response = hyper::Response::from_parts(parts, body);
6710
6711                        let server_response =
6712                            json::from_str::<serde_json::Value>(&res_body_string).ok();
6713
6714                        if let client::Retry::After(d) =
6715                            dlg.http_failure(&restored_response, server_response.clone())
6716                        {
6717                            sleep(d);
6718                            continue;
6719                        }
6720
6721                        dlg.finished(false);
6722
6723                        return match server_response {
6724                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
6725                            None => Err(client::Error::Failure(restored_response)),
6726                        };
6727                    }
6728                    let result_value = res;
6729
6730                    dlg.finished(true);
6731                    return Ok(result_value);
6732                }
6733            }
6734        }
6735    }
6736
6737    /// The ID of the shared drive.
6738    ///
6739    /// Sets the *drive id* path property to the given value.
6740    ///
6741    /// Even though the property as already been set when instantiating this call,
6742    /// we provide this method for API completeness.
6743    pub fn drive_id(mut self, new_value: &str) -> DriveDeleteCall<'a, S> {
6744        self._drive_id = new_value.to_string();
6745        self
6746    }
6747    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6748    /// while executing the actual API request.
6749    ///
6750    /// It should be used to handle progress information, and to implement a certain level of resilience.
6751    ///
6752    /// Sets the *delegate* property to the given value.
6753    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveDeleteCall<'a, S> {
6754        self._delegate = Some(new_value);
6755        self
6756    }
6757
6758    /// Set any additional parameter of the query string used in the request.
6759    /// It should be used to set parameters which are not yet available through their own
6760    /// setters.
6761    ///
6762    /// Please note that this method must not be used to set any of the known parameters
6763    /// which have their own setter method. If done anyway, the request will fail.
6764    ///
6765    /// # Additional Parameters
6766    ///
6767    /// * *alt* (query-string) - Data format for the response.
6768    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6769    /// * *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.
6770    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6771    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6772    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6773    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6774    pub fn param<T>(mut self, name: T, value: T) -> DriveDeleteCall<'a, S>
6775    where
6776        T: AsRef<str>,
6777    {
6778        self._additional_params
6779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6780        self
6781    }
6782
6783    /// Identifies the authorization scope for the method you are building.
6784    ///
6785    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
6786    /// `Scope::Full`.
6787    ///
6788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6789    /// tokens for more than one scope.
6790    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
6791    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
6792    /// function for details).
6793    ///
6794    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6795    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6796    /// sufficient, a read-write scope will do as well.
6797    pub fn add_scope<T, St>(mut self, scope: T) -> DriveDeleteCall<'a, S>
6798    where
6799        T: Into<Option<St>>,
6800        St: AsRef<str>,
6801    {
6802        match scope.into() {
6803            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
6804            None => None,
6805        };
6806        self
6807    }
6808}
6809
6810/// Gets a shared drive's metadata by ID.
6811///
6812/// A builder for the *get* method supported by a *drive* resource.
6813/// It is not used directly, but through a `DriveMethods` instance.
6814///
6815/// # Example
6816///
6817/// Instantiate a resource method builder
6818///
6819/// ```test_harness,no_run
6820/// # extern crate hyper;
6821/// # extern crate hyper_rustls;
6822/// # extern crate google_drive3 as drive3;
6823/// # async fn dox() {
6824/// # use std::default::Default;
6825/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
6826///
6827/// # let secret: oauth2::ApplicationSecret = Default::default();
6828/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
6829/// #         secret,
6830/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6831/// #     ).build().await.unwrap();
6832/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
6833/// // You can configure optional parameters by calling the respective setters at will, and
6834/// // execute the final call using `doit()`.
6835/// // Values shown here are possibly random and not representative !
6836/// let result = hub.drives().get("driveId")
6837///              .use_domain_admin_access(true)
6838///              .doit().await;
6839/// # }
6840/// ```
6841pub struct DriveGetCall<'a, S>
6842where
6843    S: 'a,
6844{
6845    hub: &'a DriveHub<S>,
6846    _drive_id: String,
6847    _use_domain_admin_access: Option<bool>,
6848    _delegate: Option<&'a mut dyn client::Delegate>,
6849    _additional_params: HashMap<String, String>,
6850    _scopes: BTreeMap<String, ()>,
6851}
6852
6853impl<'a, S> client::CallBuilder for DriveGetCall<'a, S> {}
6854
6855impl<'a, S> DriveGetCall<'a, S>
6856where
6857    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
6858    S::Response:
6859        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
6860    S::Future: Send + Unpin + 'static,
6861    S::Error: Into<Box<dyn StdError + Send + Sync>>,
6862{
6863    /// Perform the operation you have build so far.
6864    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Drive)> {
6865        use client::ToParts;
6866        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6867        use std::io::{Read, Seek};
6868        let mut dd = client::DefaultDelegate;
6869        let mut dlg: &mut dyn client::Delegate = match self._delegate {
6870            Some(d) => d,
6871            None => &mut dd,
6872        };
6873        dlg.begin(client::MethodInfo {
6874            id: "drive.drives.get",
6875            http_method: hyper::Method::GET,
6876        });
6877        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
6878        params.push(("driveId", self._drive_id.to_string()));
6879        if let Some(value) = self._use_domain_admin_access {
6880            params.push(("useDomainAdminAccess", value.to_string()));
6881        }
6882        for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
6883            if self._additional_params.contains_key(field) {
6884                dlg.finished(false);
6885                return Err(client::Error::FieldClash(field));
6886            }
6887        }
6888        for (name, value) in self._additional_params.iter() {
6889            params.push((&name, value.clone()));
6890        }
6891
6892        params.push(("alt", "json".to_string()));
6893
6894        let mut url = self.hub._base_url.clone() + "drives/{driveId}";
6895        if self._scopes.len() == 0 {
6896            self._scopes
6897                .insert(Scope::Readonly.as_ref().to_string(), ());
6898        }
6899
6900        for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
6901            let mut replace_with: Option<&str> = None;
6902            for &(name, ref value) in params.iter() {
6903                if name == param_name {
6904                    replace_with = Some(value);
6905                    break;
6906                }
6907            }
6908            url = url.replace(
6909                find_this,
6910                replace_with.expect("to find substitution value in params"),
6911            );
6912        }
6913        {
6914            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
6915            for param_name in ["driveId"].iter() {
6916                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
6917                    indices_for_removal.push(index);
6918                }
6919            }
6920            for &index in indices_for_removal.iter() {
6921                params.remove(index);
6922            }
6923        }
6924
6925        let url = url::Url::parse_with_params(&url, params).unwrap();
6926
6927        loop {
6928            let token = match self
6929                .hub
6930                .auth
6931                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
6932                .await
6933            {
6934                Ok(token) => token.clone(),
6935                Err(err) => match dlg.token(&err) {
6936                    Some(token) => token,
6937                    None => {
6938                        dlg.finished(false);
6939                        return Err(client::Error::MissingToken(err));
6940                    }
6941                },
6942            };
6943            let mut req_result = {
6944                let client = &self.hub.client;
6945                dlg.pre_request();
6946                let mut req_builder = hyper::Request::builder()
6947                    .method(hyper::Method::GET)
6948                    .uri(url.clone().into_string())
6949                    .header(USER_AGENT, self.hub._user_agent.clone())
6950                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
6951
6952                let request = req_builder.body(hyper::body::Body::empty());
6953
6954                client.request(request.unwrap()).await
6955            };
6956
6957            match req_result {
6958                Err(err) => {
6959                    if let client::Retry::After(d) = dlg.http_error(&err) {
6960                        sleep(d);
6961                        continue;
6962                    }
6963                    dlg.finished(false);
6964                    return Err(client::Error::HttpError(err));
6965                }
6966                Ok(mut res) => {
6967                    if !res.status().is_success() {
6968                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6969                        let (parts, _) = res.into_parts();
6970                        let body = hyper::Body::from(res_body_string.clone());
6971                        let restored_response = hyper::Response::from_parts(parts, body);
6972
6973                        let server_response =
6974                            json::from_str::<serde_json::Value>(&res_body_string).ok();
6975
6976                        if let client::Retry::After(d) =
6977                            dlg.http_failure(&restored_response, server_response.clone())
6978                        {
6979                            sleep(d);
6980                            continue;
6981                        }
6982
6983                        dlg.finished(false);
6984
6985                        return match server_response {
6986                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
6987                            None => Err(client::Error::Failure(restored_response)),
6988                        };
6989                    }
6990                    let result_value = {
6991                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
6992
6993                        match json::from_str(&res_body_string) {
6994                            Ok(decoded) => (res, decoded),
6995                            Err(err) => {
6996                                dlg.response_json_decode_error(&res_body_string, &err);
6997                                return Err(client::Error::JsonDecodeError(res_body_string, err));
6998                            }
6999                        }
7000                    };
7001
7002                    dlg.finished(true);
7003                    return Ok(result_value);
7004                }
7005            }
7006        }
7007    }
7008
7009    /// The ID of the shared drive.
7010    ///
7011    /// Sets the *drive id* path property to the given value.
7012    ///
7013    /// Even though the property as already been set when instantiating this call,
7014    /// we provide this method for API completeness.
7015    pub fn drive_id(mut self, new_value: &str) -> DriveGetCall<'a, S> {
7016        self._drive_id = new_value.to_string();
7017        self
7018    }
7019    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs.
7020    ///
7021    /// Sets the *use domain admin access* query property to the given value.
7022    pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveGetCall<'a, S> {
7023        self._use_domain_admin_access = Some(new_value);
7024        self
7025    }
7026    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7027    /// while executing the actual API request.
7028    ///
7029    /// It should be used to handle progress information, and to implement a certain level of resilience.
7030    ///
7031    /// Sets the *delegate* property to the given value.
7032    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveGetCall<'a, S> {
7033        self._delegate = Some(new_value);
7034        self
7035    }
7036
7037    /// Set any additional parameter of the query string used in the request.
7038    /// It should be used to set parameters which are not yet available through their own
7039    /// setters.
7040    ///
7041    /// Please note that this method must not be used to set any of the known parameters
7042    /// which have their own setter method. If done anyway, the request will fail.
7043    ///
7044    /// # Additional Parameters
7045    ///
7046    /// * *alt* (query-string) - Data format for the response.
7047    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7048    /// * *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.
7049    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7050    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7051    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7052    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7053    pub fn param<T>(mut self, name: T, value: T) -> DriveGetCall<'a, S>
7054    where
7055        T: AsRef<str>,
7056    {
7057        self._additional_params
7058            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7059        self
7060    }
7061
7062    /// Identifies the authorization scope for the method you are building.
7063    ///
7064    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7065    /// `Scope::Readonly`.
7066    ///
7067    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7068    /// tokens for more than one scope.
7069    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7070    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7071    /// function for details).
7072    ///
7073    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7074    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7075    /// sufficient, a read-write scope will do as well.
7076    pub fn add_scope<T, St>(mut self, scope: T) -> DriveGetCall<'a, S>
7077    where
7078        T: Into<Option<St>>,
7079        St: AsRef<str>,
7080    {
7081        match scope.into() {
7082            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7083            None => None,
7084        };
7085        self
7086    }
7087}
7088
7089/// Hides a shared drive from the default view.
7090///
7091/// A builder for the *hide* method supported by a *drive* resource.
7092/// It is not used directly, but through a `DriveMethods` instance.
7093///
7094/// # Example
7095///
7096/// Instantiate a resource method builder
7097///
7098/// ```test_harness,no_run
7099/// # extern crate hyper;
7100/// # extern crate hyper_rustls;
7101/// # extern crate google_drive3 as drive3;
7102/// # async fn dox() {
7103/// # use std::default::Default;
7104/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
7105///
7106/// # let secret: oauth2::ApplicationSecret = Default::default();
7107/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
7108/// #         secret,
7109/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7110/// #     ).build().await.unwrap();
7111/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
7112/// // You can configure optional parameters by calling the respective setters at will, and
7113/// // execute the final call using `doit()`.
7114/// // Values shown here are possibly random and not representative !
7115/// let result = hub.drives().hide("driveId")
7116///              .doit().await;
7117/// # }
7118/// ```
7119pub struct DriveHideCall<'a, S>
7120where
7121    S: 'a,
7122{
7123    hub: &'a DriveHub<S>,
7124    _drive_id: String,
7125    _delegate: Option<&'a mut dyn client::Delegate>,
7126    _additional_params: HashMap<String, String>,
7127    _scopes: BTreeMap<String, ()>,
7128}
7129
7130impl<'a, S> client::CallBuilder for DriveHideCall<'a, S> {}
7131
7132impl<'a, S> DriveHideCall<'a, S>
7133where
7134    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
7135    S::Response:
7136        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
7137    S::Future: Send + Unpin + 'static,
7138    S::Error: Into<Box<dyn StdError + Send + Sync>>,
7139{
7140    /// Perform the operation you have build so far.
7141    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Drive)> {
7142        use client::ToParts;
7143        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7144        use std::io::{Read, Seek};
7145        let mut dd = client::DefaultDelegate;
7146        let mut dlg: &mut dyn client::Delegate = match self._delegate {
7147            Some(d) => d,
7148            None => &mut dd,
7149        };
7150        dlg.begin(client::MethodInfo {
7151            id: "drive.drives.hide",
7152            http_method: hyper::Method::POST,
7153        });
7154        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
7155        params.push(("driveId", self._drive_id.to_string()));
7156        for &field in ["alt", "driveId"].iter() {
7157            if self._additional_params.contains_key(field) {
7158                dlg.finished(false);
7159                return Err(client::Error::FieldClash(field));
7160            }
7161        }
7162        for (name, value) in self._additional_params.iter() {
7163            params.push((&name, value.clone()));
7164        }
7165
7166        params.push(("alt", "json".to_string()));
7167
7168        let mut url = self.hub._base_url.clone() + "drives/{driveId}/hide";
7169        if self._scopes.len() == 0 {
7170            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
7171        }
7172
7173        for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
7174            let mut replace_with: Option<&str> = None;
7175            for &(name, ref value) in params.iter() {
7176                if name == param_name {
7177                    replace_with = Some(value);
7178                    break;
7179                }
7180            }
7181            url = url.replace(
7182                find_this,
7183                replace_with.expect("to find substitution value in params"),
7184            );
7185        }
7186        {
7187            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
7188            for param_name in ["driveId"].iter() {
7189                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7190                    indices_for_removal.push(index);
7191                }
7192            }
7193            for &index in indices_for_removal.iter() {
7194                params.remove(index);
7195            }
7196        }
7197
7198        let url = url::Url::parse_with_params(&url, params).unwrap();
7199
7200        loop {
7201            let token = match self
7202                .hub
7203                .auth
7204                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
7205                .await
7206            {
7207                Ok(token) => token.clone(),
7208                Err(err) => match dlg.token(&err) {
7209                    Some(token) => token,
7210                    None => {
7211                        dlg.finished(false);
7212                        return Err(client::Error::MissingToken(err));
7213                    }
7214                },
7215            };
7216            let mut req_result = {
7217                let client = &self.hub.client;
7218                dlg.pre_request();
7219                let mut req_builder = hyper::Request::builder()
7220                    .method(hyper::Method::POST)
7221                    .uri(url.clone().into_string())
7222                    .header(USER_AGENT, self.hub._user_agent.clone())
7223                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
7224
7225                let request = req_builder.body(hyper::body::Body::empty());
7226
7227                client.request(request.unwrap()).await
7228            };
7229
7230            match req_result {
7231                Err(err) => {
7232                    if let client::Retry::After(d) = dlg.http_error(&err) {
7233                        sleep(d);
7234                        continue;
7235                    }
7236                    dlg.finished(false);
7237                    return Err(client::Error::HttpError(err));
7238                }
7239                Ok(mut res) => {
7240                    if !res.status().is_success() {
7241                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7242                        let (parts, _) = res.into_parts();
7243                        let body = hyper::Body::from(res_body_string.clone());
7244                        let restored_response = hyper::Response::from_parts(parts, body);
7245
7246                        let server_response =
7247                            json::from_str::<serde_json::Value>(&res_body_string).ok();
7248
7249                        if let client::Retry::After(d) =
7250                            dlg.http_failure(&restored_response, server_response.clone())
7251                        {
7252                            sleep(d);
7253                            continue;
7254                        }
7255
7256                        dlg.finished(false);
7257
7258                        return match server_response {
7259                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
7260                            None => Err(client::Error::Failure(restored_response)),
7261                        };
7262                    }
7263                    let result_value = {
7264                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7265
7266                        match json::from_str(&res_body_string) {
7267                            Ok(decoded) => (res, decoded),
7268                            Err(err) => {
7269                                dlg.response_json_decode_error(&res_body_string, &err);
7270                                return Err(client::Error::JsonDecodeError(res_body_string, err));
7271                            }
7272                        }
7273                    };
7274
7275                    dlg.finished(true);
7276                    return Ok(result_value);
7277                }
7278            }
7279        }
7280    }
7281
7282    /// The ID of the shared drive.
7283    ///
7284    /// Sets the *drive id* path property to the given value.
7285    ///
7286    /// Even though the property as already been set when instantiating this call,
7287    /// we provide this method for API completeness.
7288    pub fn drive_id(mut self, new_value: &str) -> DriveHideCall<'a, S> {
7289        self._drive_id = new_value.to_string();
7290        self
7291    }
7292    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7293    /// while executing the actual API request.
7294    ///
7295    /// It should be used to handle progress information, and to implement a certain level of resilience.
7296    ///
7297    /// Sets the *delegate* property to the given value.
7298    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveHideCall<'a, S> {
7299        self._delegate = Some(new_value);
7300        self
7301    }
7302
7303    /// Set any additional parameter of the query string used in the request.
7304    /// It should be used to set parameters which are not yet available through their own
7305    /// setters.
7306    ///
7307    /// Please note that this method must not be used to set any of the known parameters
7308    /// which have their own setter method. If done anyway, the request will fail.
7309    ///
7310    /// # Additional Parameters
7311    ///
7312    /// * *alt* (query-string) - Data format for the response.
7313    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7314    /// * *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.
7315    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7316    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7317    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7318    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7319    pub fn param<T>(mut self, name: T, value: T) -> DriveHideCall<'a, S>
7320    where
7321        T: AsRef<str>,
7322    {
7323        self._additional_params
7324            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7325        self
7326    }
7327
7328    /// Identifies the authorization scope for the method you are building.
7329    ///
7330    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7331    /// `Scope::Full`.
7332    ///
7333    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7334    /// tokens for more than one scope.
7335    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7336    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7337    /// function for details).
7338    ///
7339    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7340    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7341    /// sufficient, a read-write scope will do as well.
7342    pub fn add_scope<T, St>(mut self, scope: T) -> DriveHideCall<'a, S>
7343    where
7344        T: Into<Option<St>>,
7345        St: AsRef<str>,
7346    {
7347        match scope.into() {
7348            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7349            None => None,
7350        };
7351        self
7352    }
7353}
7354
7355/// Lists the user's shared drives.
7356///
7357/// A builder for the *list* method supported by a *drive* resource.
7358/// It is not used directly, but through a `DriveMethods` instance.
7359///
7360/// # Example
7361///
7362/// Instantiate a resource method builder
7363///
7364/// ```test_harness,no_run
7365/// # extern crate hyper;
7366/// # extern crate hyper_rustls;
7367/// # extern crate google_drive3 as drive3;
7368/// # async fn dox() {
7369/// # use std::default::Default;
7370/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
7371///
7372/// # let secret: oauth2::ApplicationSecret = Default::default();
7373/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
7374/// #         secret,
7375/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7376/// #     ).build().await.unwrap();
7377/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
7378/// // You can configure optional parameters by calling the respective setters at will, and
7379/// // execute the final call using `doit()`.
7380/// // Values shown here are possibly random and not representative !
7381/// let result = hub.drives().list()
7382///              .use_domain_admin_access(false)
7383///              .q("elitr")
7384///              .page_token("sed")
7385///              .page_size(-61)
7386///              .doit().await;
7387/// # }
7388/// ```
7389pub struct DriveListCall<'a, S>
7390where
7391    S: 'a,
7392{
7393    hub: &'a DriveHub<S>,
7394    _use_domain_admin_access: Option<bool>,
7395    _q: Option<String>,
7396    _page_token: Option<String>,
7397    _page_size: Option<i32>,
7398    _delegate: Option<&'a mut dyn client::Delegate>,
7399    _additional_params: HashMap<String, String>,
7400    _scopes: BTreeMap<String, ()>,
7401}
7402
7403impl<'a, S> client::CallBuilder for DriveListCall<'a, S> {}
7404
7405impl<'a, S> DriveListCall<'a, S>
7406where
7407    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
7408    S::Response:
7409        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
7410    S::Future: Send + Unpin + 'static,
7411    S::Error: Into<Box<dyn StdError + Send + Sync>>,
7412{
7413    /// Perform the operation you have build so far.
7414    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, DriveList)> {
7415        use client::ToParts;
7416        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7417        use std::io::{Read, Seek};
7418        let mut dd = client::DefaultDelegate;
7419        let mut dlg: &mut dyn client::Delegate = match self._delegate {
7420            Some(d) => d,
7421            None => &mut dd,
7422        };
7423        dlg.begin(client::MethodInfo {
7424            id: "drive.drives.list",
7425            http_method: hyper::Method::GET,
7426        });
7427        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
7428        if let Some(value) = self._use_domain_admin_access {
7429            params.push(("useDomainAdminAccess", value.to_string()));
7430        }
7431        if let Some(value) = self._q {
7432            params.push(("q", value.to_string()));
7433        }
7434        if let Some(value) = self._page_token {
7435            params.push(("pageToken", value.to_string()));
7436        }
7437        if let Some(value) = self._page_size {
7438            params.push(("pageSize", value.to_string()));
7439        }
7440        for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "pageSize"].iter() {
7441            if self._additional_params.contains_key(field) {
7442                dlg.finished(false);
7443                return Err(client::Error::FieldClash(field));
7444            }
7445        }
7446        for (name, value) in self._additional_params.iter() {
7447            params.push((&name, value.clone()));
7448        }
7449
7450        params.push(("alt", "json".to_string()));
7451
7452        let mut url = self.hub._base_url.clone() + "drives";
7453        if self._scopes.len() == 0 {
7454            self._scopes
7455                .insert(Scope::Readonly.as_ref().to_string(), ());
7456        }
7457
7458        let url = url::Url::parse_with_params(&url, params).unwrap();
7459
7460        loop {
7461            let token = match self
7462                .hub
7463                .auth
7464                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
7465                .await
7466            {
7467                Ok(token) => token.clone(),
7468                Err(err) => match dlg.token(&err) {
7469                    Some(token) => token,
7470                    None => {
7471                        dlg.finished(false);
7472                        return Err(client::Error::MissingToken(err));
7473                    }
7474                },
7475            };
7476            let mut req_result = {
7477                let client = &self.hub.client;
7478                dlg.pre_request();
7479                let mut req_builder = hyper::Request::builder()
7480                    .method(hyper::Method::GET)
7481                    .uri(url.clone().into_string())
7482                    .header(USER_AGENT, self.hub._user_agent.clone())
7483                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
7484
7485                let request = req_builder.body(hyper::body::Body::empty());
7486
7487                client.request(request.unwrap()).await
7488            };
7489
7490            match req_result {
7491                Err(err) => {
7492                    if let client::Retry::After(d) = dlg.http_error(&err) {
7493                        sleep(d);
7494                        continue;
7495                    }
7496                    dlg.finished(false);
7497                    return Err(client::Error::HttpError(err));
7498                }
7499                Ok(mut res) => {
7500                    if !res.status().is_success() {
7501                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7502                        let (parts, _) = res.into_parts();
7503                        let body = hyper::Body::from(res_body_string.clone());
7504                        let restored_response = hyper::Response::from_parts(parts, body);
7505
7506                        let server_response =
7507                            json::from_str::<serde_json::Value>(&res_body_string).ok();
7508
7509                        if let client::Retry::After(d) =
7510                            dlg.http_failure(&restored_response, server_response.clone())
7511                        {
7512                            sleep(d);
7513                            continue;
7514                        }
7515
7516                        dlg.finished(false);
7517
7518                        return match server_response {
7519                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
7520                            None => Err(client::Error::Failure(restored_response)),
7521                        };
7522                    }
7523                    let result_value = {
7524                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7525
7526                        match json::from_str(&res_body_string) {
7527                            Ok(decoded) => (res, decoded),
7528                            Err(err) => {
7529                                dlg.response_json_decode_error(&res_body_string, &err);
7530                                return Err(client::Error::JsonDecodeError(res_body_string, err));
7531                            }
7532                        }
7533                    };
7534
7535                    dlg.finished(true);
7536                    return Ok(result_value);
7537                }
7538            }
7539        }
7540    }
7541
7542    /// Issue the request as a domain administrator; if set to true, then all shared drives of the domain in which the requester is an administrator are returned.
7543    ///
7544    /// Sets the *use domain admin access* query property to the given value.
7545    pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveListCall<'a, S> {
7546        self._use_domain_admin_access = Some(new_value);
7547        self
7548    }
7549    /// Query string for searching shared drives.
7550    ///
7551    /// Sets the *q* query property to the given value.
7552    pub fn q(mut self, new_value: &str) -> DriveListCall<'a, S> {
7553        self._q = Some(new_value.to_string());
7554        self
7555    }
7556    /// Page token for shared drives.
7557    ///
7558    /// Sets the *page token* query property to the given value.
7559    pub fn page_token(mut self, new_value: &str) -> DriveListCall<'a, S> {
7560        self._page_token = Some(new_value.to_string());
7561        self
7562    }
7563    /// Maximum number of shared drives to return per page.
7564    ///
7565    /// Sets the *page size* query property to the given value.
7566    pub fn page_size(mut self, new_value: i32) -> DriveListCall<'a, S> {
7567        self._page_size = Some(new_value);
7568        self
7569    }
7570    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7571    /// while executing the actual API request.
7572    ///
7573    /// It should be used to handle progress information, and to implement a certain level of resilience.
7574    ///
7575    /// Sets the *delegate* property to the given value.
7576    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveListCall<'a, S> {
7577        self._delegate = Some(new_value);
7578        self
7579    }
7580
7581    /// Set any additional parameter of the query string used in the request.
7582    /// It should be used to set parameters which are not yet available through their own
7583    /// setters.
7584    ///
7585    /// Please note that this method must not be used to set any of the known parameters
7586    /// which have their own setter method. If done anyway, the request will fail.
7587    ///
7588    /// # Additional Parameters
7589    ///
7590    /// * *alt* (query-string) - Data format for the response.
7591    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7592    /// * *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.
7593    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7594    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7595    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7596    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7597    pub fn param<T>(mut self, name: T, value: T) -> DriveListCall<'a, S>
7598    where
7599        T: AsRef<str>,
7600    {
7601        self._additional_params
7602            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7603        self
7604    }
7605
7606    /// Identifies the authorization scope for the method you are building.
7607    ///
7608    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7609    /// `Scope::Readonly`.
7610    ///
7611    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7612    /// tokens for more than one scope.
7613    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7614    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7615    /// function for details).
7616    ///
7617    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7618    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7619    /// sufficient, a read-write scope will do as well.
7620    pub fn add_scope<T, St>(mut self, scope: T) -> DriveListCall<'a, S>
7621    where
7622        T: Into<Option<St>>,
7623        St: AsRef<str>,
7624    {
7625        match scope.into() {
7626            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7627            None => None,
7628        };
7629        self
7630    }
7631}
7632
7633/// Restores a shared drive to the default view.
7634///
7635/// A builder for the *unhide* method supported by a *drive* resource.
7636/// It is not used directly, but through a `DriveMethods` instance.
7637///
7638/// # Example
7639///
7640/// Instantiate a resource method builder
7641///
7642/// ```test_harness,no_run
7643/// # extern crate hyper;
7644/// # extern crate hyper_rustls;
7645/// # extern crate google_drive3 as drive3;
7646/// # async fn dox() {
7647/// # use std::default::Default;
7648/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
7649///
7650/// # let secret: oauth2::ApplicationSecret = Default::default();
7651/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
7652/// #         secret,
7653/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7654/// #     ).build().await.unwrap();
7655/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
7656/// // You can configure optional parameters by calling the respective setters at will, and
7657/// // execute the final call using `doit()`.
7658/// // Values shown here are possibly random and not representative !
7659/// let result = hub.drives().unhide("driveId")
7660///              .doit().await;
7661/// # }
7662/// ```
7663pub struct DriveUnhideCall<'a, S>
7664where
7665    S: 'a,
7666{
7667    hub: &'a DriveHub<S>,
7668    _drive_id: String,
7669    _delegate: Option<&'a mut dyn client::Delegate>,
7670    _additional_params: HashMap<String, String>,
7671    _scopes: BTreeMap<String, ()>,
7672}
7673
7674impl<'a, S> client::CallBuilder for DriveUnhideCall<'a, S> {}
7675
7676impl<'a, S> DriveUnhideCall<'a, S>
7677where
7678    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
7679    S::Response:
7680        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
7681    S::Future: Send + Unpin + 'static,
7682    S::Error: Into<Box<dyn StdError + Send + Sync>>,
7683{
7684    /// Perform the operation you have build so far.
7685    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Drive)> {
7686        use client::ToParts;
7687        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7688        use std::io::{Read, Seek};
7689        let mut dd = client::DefaultDelegate;
7690        let mut dlg: &mut dyn client::Delegate = match self._delegate {
7691            Some(d) => d,
7692            None => &mut dd,
7693        };
7694        dlg.begin(client::MethodInfo {
7695            id: "drive.drives.unhide",
7696            http_method: hyper::Method::POST,
7697        });
7698        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
7699        params.push(("driveId", self._drive_id.to_string()));
7700        for &field in ["alt", "driveId"].iter() {
7701            if self._additional_params.contains_key(field) {
7702                dlg.finished(false);
7703                return Err(client::Error::FieldClash(field));
7704            }
7705        }
7706        for (name, value) in self._additional_params.iter() {
7707            params.push((&name, value.clone()));
7708        }
7709
7710        params.push(("alt", "json".to_string()));
7711
7712        let mut url = self.hub._base_url.clone() + "drives/{driveId}/unhide";
7713        if self._scopes.len() == 0 {
7714            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
7715        }
7716
7717        for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
7718            let mut replace_with: Option<&str> = None;
7719            for &(name, ref value) in params.iter() {
7720                if name == param_name {
7721                    replace_with = Some(value);
7722                    break;
7723                }
7724            }
7725            url = url.replace(
7726                find_this,
7727                replace_with.expect("to find substitution value in params"),
7728            );
7729        }
7730        {
7731            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
7732            for param_name in ["driveId"].iter() {
7733                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
7734                    indices_for_removal.push(index);
7735                }
7736            }
7737            for &index in indices_for_removal.iter() {
7738                params.remove(index);
7739            }
7740        }
7741
7742        let url = url::Url::parse_with_params(&url, params).unwrap();
7743
7744        loop {
7745            let token = match self
7746                .hub
7747                .auth
7748                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
7749                .await
7750            {
7751                Ok(token) => token.clone(),
7752                Err(err) => match dlg.token(&err) {
7753                    Some(token) => token,
7754                    None => {
7755                        dlg.finished(false);
7756                        return Err(client::Error::MissingToken(err));
7757                    }
7758                },
7759            };
7760            let mut req_result = {
7761                let client = &self.hub.client;
7762                dlg.pre_request();
7763                let mut req_builder = hyper::Request::builder()
7764                    .method(hyper::Method::POST)
7765                    .uri(url.clone().into_string())
7766                    .header(USER_AGENT, self.hub._user_agent.clone())
7767                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
7768
7769                let request = req_builder.body(hyper::body::Body::empty());
7770
7771                client.request(request.unwrap()).await
7772            };
7773
7774            match req_result {
7775                Err(err) => {
7776                    if let client::Retry::After(d) = dlg.http_error(&err) {
7777                        sleep(d);
7778                        continue;
7779                    }
7780                    dlg.finished(false);
7781                    return Err(client::Error::HttpError(err));
7782                }
7783                Ok(mut res) => {
7784                    if !res.status().is_success() {
7785                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7786                        let (parts, _) = res.into_parts();
7787                        let body = hyper::Body::from(res_body_string.clone());
7788                        let restored_response = hyper::Response::from_parts(parts, body);
7789
7790                        let server_response =
7791                            json::from_str::<serde_json::Value>(&res_body_string).ok();
7792
7793                        if let client::Retry::After(d) =
7794                            dlg.http_failure(&restored_response, server_response.clone())
7795                        {
7796                            sleep(d);
7797                            continue;
7798                        }
7799
7800                        dlg.finished(false);
7801
7802                        return match server_response {
7803                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
7804                            None => Err(client::Error::Failure(restored_response)),
7805                        };
7806                    }
7807                    let result_value = {
7808                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
7809
7810                        match json::from_str(&res_body_string) {
7811                            Ok(decoded) => (res, decoded),
7812                            Err(err) => {
7813                                dlg.response_json_decode_error(&res_body_string, &err);
7814                                return Err(client::Error::JsonDecodeError(res_body_string, err));
7815                            }
7816                        }
7817                    };
7818
7819                    dlg.finished(true);
7820                    return Ok(result_value);
7821                }
7822            }
7823        }
7824    }
7825
7826    /// The ID of the shared drive.
7827    ///
7828    /// Sets the *drive id* path property to the given value.
7829    ///
7830    /// Even though the property as already been set when instantiating this call,
7831    /// we provide this method for API completeness.
7832    pub fn drive_id(mut self, new_value: &str) -> DriveUnhideCall<'a, S> {
7833        self._drive_id = new_value.to_string();
7834        self
7835    }
7836    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7837    /// while executing the actual API request.
7838    ///
7839    /// It should be used to handle progress information, and to implement a certain level of resilience.
7840    ///
7841    /// Sets the *delegate* property to the given value.
7842    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveUnhideCall<'a, S> {
7843        self._delegate = Some(new_value);
7844        self
7845    }
7846
7847    /// Set any additional parameter of the query string used in the request.
7848    /// It should be used to set parameters which are not yet available through their own
7849    /// setters.
7850    ///
7851    /// Please note that this method must not be used to set any of the known parameters
7852    /// which have their own setter method. If done anyway, the request will fail.
7853    ///
7854    /// # Additional Parameters
7855    ///
7856    /// * *alt* (query-string) - Data format for the response.
7857    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7858    /// * *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.
7859    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7860    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7861    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7862    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7863    pub fn param<T>(mut self, name: T, value: T) -> DriveUnhideCall<'a, S>
7864    where
7865        T: AsRef<str>,
7866    {
7867        self._additional_params
7868            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7869        self
7870    }
7871
7872    /// Identifies the authorization scope for the method you are building.
7873    ///
7874    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
7875    /// `Scope::Full`.
7876    ///
7877    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7878    /// tokens for more than one scope.
7879    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
7880    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
7881    /// function for details).
7882    ///
7883    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7884    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7885    /// sufficient, a read-write scope will do as well.
7886    pub fn add_scope<T, St>(mut self, scope: T) -> DriveUnhideCall<'a, S>
7887    where
7888        T: Into<Option<St>>,
7889        St: AsRef<str>,
7890    {
7891        match scope.into() {
7892            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
7893            None => None,
7894        };
7895        self
7896    }
7897}
7898
7899/// Updates the metadate for a shared drive.
7900///
7901/// A builder for the *update* method supported by a *drive* resource.
7902/// It is not used directly, but through a `DriveMethods` instance.
7903///
7904/// # Example
7905///
7906/// Instantiate a resource method builder
7907///
7908/// ```test_harness,no_run
7909/// # extern crate hyper;
7910/// # extern crate hyper_rustls;
7911/// # extern crate google_drive3 as drive3;
7912/// use drive3::api::Drive;
7913/// # async fn dox() {
7914/// # use std::default::Default;
7915/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
7916///
7917/// # let secret: oauth2::ApplicationSecret = Default::default();
7918/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
7919/// #         secret,
7920/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7921/// #     ).build().await.unwrap();
7922/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
7923/// // As the method needs a request, you would usually fill it with the desired information
7924/// // into the respective structure. Some of the parts shown here might not be applicable !
7925/// // Values shown here are possibly random and not representative !
7926/// let mut req = Drive::default();
7927///
7928/// // You can configure optional parameters by calling the respective setters at will, and
7929/// // execute the final call using `doit()`.
7930/// // Values shown here are possibly random and not representative !
7931/// let result = hub.drives().update(req, "driveId")
7932///              .use_domain_admin_access(true)
7933///              .doit().await;
7934/// # }
7935/// ```
7936pub struct DriveUpdateCall<'a, S>
7937where
7938    S: 'a,
7939{
7940    hub: &'a DriveHub<S>,
7941    _request: Drive,
7942    _drive_id: String,
7943    _use_domain_admin_access: Option<bool>,
7944    _delegate: Option<&'a mut dyn client::Delegate>,
7945    _additional_params: HashMap<String, String>,
7946    _scopes: BTreeMap<String, ()>,
7947}
7948
7949impl<'a, S> client::CallBuilder for DriveUpdateCall<'a, S> {}
7950
7951impl<'a, S> DriveUpdateCall<'a, S>
7952where
7953    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
7954    S::Response:
7955        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
7956    S::Future: Send + Unpin + 'static,
7957    S::Error: Into<Box<dyn StdError + Send + Sync>>,
7958{
7959    /// Perform the operation you have build so far.
7960    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Drive)> {
7961        use client::ToParts;
7962        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7963        use std::io::{Read, Seek};
7964        let mut dd = client::DefaultDelegate;
7965        let mut dlg: &mut dyn client::Delegate = match self._delegate {
7966            Some(d) => d,
7967            None => &mut dd,
7968        };
7969        dlg.begin(client::MethodInfo {
7970            id: "drive.drives.update",
7971            http_method: hyper::Method::PATCH,
7972        });
7973        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
7974        params.push(("driveId", self._drive_id.to_string()));
7975        if let Some(value) = self._use_domain_admin_access {
7976            params.push(("useDomainAdminAccess", value.to_string()));
7977        }
7978        for &field in ["alt", "driveId", "useDomainAdminAccess"].iter() {
7979            if self._additional_params.contains_key(field) {
7980                dlg.finished(false);
7981                return Err(client::Error::FieldClash(field));
7982            }
7983        }
7984        for (name, value) in self._additional_params.iter() {
7985            params.push((&name, value.clone()));
7986        }
7987
7988        params.push(("alt", "json".to_string()));
7989
7990        let mut url = self.hub._base_url.clone() + "drives/{driveId}";
7991        if self._scopes.len() == 0 {
7992            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
7993        }
7994
7995        for &(find_this, param_name) in [("{driveId}", "driveId")].iter() {
7996            let mut replace_with: Option<&str> = None;
7997            for &(name, ref value) in params.iter() {
7998                if name == param_name {
7999                    replace_with = Some(value);
8000                    break;
8001                }
8002            }
8003            url = url.replace(
8004                find_this,
8005                replace_with.expect("to find substitution value in params"),
8006            );
8007        }
8008        {
8009            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
8010            for param_name in ["driveId"].iter() {
8011                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8012                    indices_for_removal.push(index);
8013                }
8014            }
8015            for &index in indices_for_removal.iter() {
8016                params.remove(index);
8017            }
8018        }
8019
8020        let url = url::Url::parse_with_params(&url, params).unwrap();
8021
8022        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
8023        let mut request_value_reader = {
8024            let mut value = json::value::to_value(&self._request).expect("serde to work");
8025            client::remove_json_null_values(&mut value);
8026            let mut dst = io::Cursor::new(Vec::with_capacity(128));
8027            json::to_writer(&mut dst, &value).unwrap();
8028            dst
8029        };
8030        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
8031        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8032
8033        loop {
8034            let token = match self
8035                .hub
8036                .auth
8037                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
8038                .await
8039            {
8040                Ok(token) => token.clone(),
8041                Err(err) => match dlg.token(&err) {
8042                    Some(token) => token,
8043                    None => {
8044                        dlg.finished(false);
8045                        return Err(client::Error::MissingToken(err));
8046                    }
8047                },
8048            };
8049            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8050            let mut req_result = {
8051                let client = &self.hub.client;
8052                dlg.pre_request();
8053                let mut req_builder = hyper::Request::builder()
8054                    .method(hyper::Method::PATCH)
8055                    .uri(url.clone().into_string())
8056                    .header(USER_AGENT, self.hub._user_agent.clone())
8057                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
8058
8059                let request = req_builder
8060                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
8061                    .header(CONTENT_LENGTH, request_size as u64)
8062                    .body(hyper::body::Body::from(
8063                        request_value_reader.get_ref().clone(),
8064                    ));
8065
8066                client.request(request.unwrap()).await
8067            };
8068
8069            match req_result {
8070                Err(err) => {
8071                    if let client::Retry::After(d) = dlg.http_error(&err) {
8072                        sleep(d);
8073                        continue;
8074                    }
8075                    dlg.finished(false);
8076                    return Err(client::Error::HttpError(err));
8077                }
8078                Ok(mut res) => {
8079                    if !res.status().is_success() {
8080                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8081                        let (parts, _) = res.into_parts();
8082                        let body = hyper::Body::from(res_body_string.clone());
8083                        let restored_response = hyper::Response::from_parts(parts, body);
8084
8085                        let server_response =
8086                            json::from_str::<serde_json::Value>(&res_body_string).ok();
8087
8088                        if let client::Retry::After(d) =
8089                            dlg.http_failure(&restored_response, server_response.clone())
8090                        {
8091                            sleep(d);
8092                            continue;
8093                        }
8094
8095                        dlg.finished(false);
8096
8097                        return match server_response {
8098                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
8099                            None => Err(client::Error::Failure(restored_response)),
8100                        };
8101                    }
8102                    let result_value = {
8103                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8104
8105                        match json::from_str(&res_body_string) {
8106                            Ok(decoded) => (res, decoded),
8107                            Err(err) => {
8108                                dlg.response_json_decode_error(&res_body_string, &err);
8109                                return Err(client::Error::JsonDecodeError(res_body_string, err));
8110                            }
8111                        }
8112                    };
8113
8114                    dlg.finished(true);
8115                    return Ok(result_value);
8116                }
8117            }
8118        }
8119    }
8120
8121    ///
8122    /// Sets the *request* property to the given value.
8123    ///
8124    /// Even though the property as already been set when instantiating this call,
8125    /// we provide this method for API completeness.
8126    pub fn request(mut self, new_value: Drive) -> DriveUpdateCall<'a, S> {
8127        self._request = new_value;
8128        self
8129    }
8130    /// The ID of the shared drive.
8131    ///
8132    /// Sets the *drive id* path property to the given value.
8133    ///
8134    /// Even though the property as already been set when instantiating this call,
8135    /// we provide this method for API completeness.
8136    pub fn drive_id(mut self, new_value: &str) -> DriveUpdateCall<'a, S> {
8137        self._drive_id = new_value.to_string();
8138        self
8139    }
8140    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs.
8141    ///
8142    /// Sets the *use domain admin access* query property to the given value.
8143    pub fn use_domain_admin_access(mut self, new_value: bool) -> DriveUpdateCall<'a, S> {
8144        self._use_domain_admin_access = Some(new_value);
8145        self
8146    }
8147    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8148    /// while executing the actual API request.
8149    ///
8150    /// It should be used to handle progress information, and to implement a certain level of resilience.
8151    ///
8152    /// Sets the *delegate* property to the given value.
8153    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> DriveUpdateCall<'a, S> {
8154        self._delegate = Some(new_value);
8155        self
8156    }
8157
8158    /// Set any additional parameter of the query string used in the request.
8159    /// It should be used to set parameters which are not yet available through their own
8160    /// setters.
8161    ///
8162    /// Please note that this method must not be used to set any of the known parameters
8163    /// which have their own setter method. If done anyway, the request will fail.
8164    ///
8165    /// # Additional Parameters
8166    ///
8167    /// * *alt* (query-string) - Data format for the response.
8168    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8169    /// * *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.
8170    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8171    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8172    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8173    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8174    pub fn param<T>(mut self, name: T, value: T) -> DriveUpdateCall<'a, S>
8175    where
8176        T: AsRef<str>,
8177    {
8178        self._additional_params
8179            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8180        self
8181    }
8182
8183    /// Identifies the authorization scope for the method you are building.
8184    ///
8185    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8186    /// `Scope::Full`.
8187    ///
8188    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8189    /// tokens for more than one scope.
8190    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8191    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8192    /// function for details).
8193    ///
8194    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8195    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8196    /// sufficient, a read-write scope will do as well.
8197    pub fn add_scope<T, St>(mut self, scope: T) -> DriveUpdateCall<'a, S>
8198    where
8199        T: Into<Option<St>>,
8200        St: AsRef<str>,
8201    {
8202        match scope.into() {
8203            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8204            None => None,
8205        };
8206        self
8207    }
8208}
8209
8210/// Creates a copy of a file and applies any requested updates with patch semantics. Folders cannot be copied.
8211///
8212/// A builder for the *copy* method supported by a *file* resource.
8213/// It is not used directly, but through a `FileMethods` instance.
8214///
8215/// # Example
8216///
8217/// Instantiate a resource method builder
8218///
8219/// ```test_harness,no_run
8220/// # extern crate hyper;
8221/// # extern crate hyper_rustls;
8222/// # extern crate google_drive3 as drive3;
8223/// use drive3::api::File;
8224/// # async fn dox() {
8225/// # use std::default::Default;
8226/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
8227///
8228/// # let secret: oauth2::ApplicationSecret = Default::default();
8229/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
8230/// #         secret,
8231/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8232/// #     ).build().await.unwrap();
8233/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
8234/// // As the method needs a request, you would usually fill it with the desired information
8235/// // into the respective structure. Some of the parts shown here might not be applicable !
8236/// // Values shown here are possibly random and not representative !
8237/// let mut req = File::default();
8238///
8239/// // You can configure optional parameters by calling the respective setters at will, and
8240/// // execute the final call using `doit()`.
8241/// // Values shown here are possibly random and not representative !
8242/// let result = hub.files().copy(req, "fileId")
8243///              .supports_team_drives(true)
8244///              .supports_all_drives(false)
8245///              .ocr_language("erat")
8246///              .keep_revision_forever(false)
8247///              .include_permissions_for_view("amet")
8248///              .ignore_default_visibility(true)
8249///              .enforce_single_parent(false)
8250///              .doit().await;
8251/// # }
8252/// ```
8253pub struct FileCopyCall<'a, S>
8254where
8255    S: 'a,
8256{
8257    hub: &'a DriveHub<S>,
8258    _request: File,
8259    _file_id: String,
8260    _supports_team_drives: Option<bool>,
8261    _supports_all_drives: Option<bool>,
8262    _ocr_language: Option<String>,
8263    _keep_revision_forever: Option<bool>,
8264    _include_permissions_for_view: Option<String>,
8265    _ignore_default_visibility: Option<bool>,
8266    _enforce_single_parent: Option<bool>,
8267    _delegate: Option<&'a mut dyn client::Delegate>,
8268    _additional_params: HashMap<String, String>,
8269    _scopes: BTreeMap<String, ()>,
8270}
8271
8272impl<'a, S> client::CallBuilder for FileCopyCall<'a, S> {}
8273
8274impl<'a, S> FileCopyCall<'a, S>
8275where
8276    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
8277    S::Response:
8278        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
8279    S::Future: Send + Unpin + 'static,
8280    S::Error: Into<Box<dyn StdError + Send + Sync>>,
8281{
8282    /// Perform the operation you have build so far.
8283    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, File)> {
8284        use client::ToParts;
8285        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8286        use std::io::{Read, Seek};
8287        let mut dd = client::DefaultDelegate;
8288        let mut dlg: &mut dyn client::Delegate = match self._delegate {
8289            Some(d) => d,
8290            None => &mut dd,
8291        };
8292        dlg.begin(client::MethodInfo {
8293            id: "drive.files.copy",
8294            http_method: hyper::Method::POST,
8295        });
8296        let mut params: Vec<(&str, String)> =
8297            Vec::with_capacity(11 + self._additional_params.len());
8298        params.push(("fileId", self._file_id.to_string()));
8299        if let Some(value) = self._supports_team_drives {
8300            params.push(("supportsTeamDrives", value.to_string()));
8301        }
8302        if let Some(value) = self._supports_all_drives {
8303            params.push(("supportsAllDrives", value.to_string()));
8304        }
8305        if let Some(value) = self._ocr_language {
8306            params.push(("ocrLanguage", value.to_string()));
8307        }
8308        if let Some(value) = self._keep_revision_forever {
8309            params.push(("keepRevisionForever", value.to_string()));
8310        }
8311        if let Some(value) = self._include_permissions_for_view {
8312            params.push(("includePermissionsForView", value.to_string()));
8313        }
8314        if let Some(value) = self._ignore_default_visibility {
8315            params.push(("ignoreDefaultVisibility", value.to_string()));
8316        }
8317        if let Some(value) = self._enforce_single_parent {
8318            params.push(("enforceSingleParent", value.to_string()));
8319        }
8320        for &field in [
8321            "alt",
8322            "fileId",
8323            "supportsTeamDrives",
8324            "supportsAllDrives",
8325            "ocrLanguage",
8326            "keepRevisionForever",
8327            "includePermissionsForView",
8328            "ignoreDefaultVisibility",
8329            "enforceSingleParent",
8330        ]
8331        .iter()
8332        {
8333            if self._additional_params.contains_key(field) {
8334                dlg.finished(false);
8335                return Err(client::Error::FieldClash(field));
8336            }
8337        }
8338        for (name, value) in self._additional_params.iter() {
8339            params.push((&name, value.clone()));
8340        }
8341
8342        params.push(("alt", "json".to_string()));
8343
8344        let mut url = self.hub._base_url.clone() + "files/{fileId}/copy";
8345        if self._scopes.len() == 0 {
8346            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
8347        }
8348
8349        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
8350            let mut replace_with: Option<&str> = None;
8351            for &(name, ref value) in params.iter() {
8352                if name == param_name {
8353                    replace_with = Some(value);
8354                    break;
8355                }
8356            }
8357            url = url.replace(
8358                find_this,
8359                replace_with.expect("to find substitution value in params"),
8360            );
8361        }
8362        {
8363            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
8364            for param_name in ["fileId"].iter() {
8365                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
8366                    indices_for_removal.push(index);
8367                }
8368            }
8369            for &index in indices_for_removal.iter() {
8370                params.remove(index);
8371            }
8372        }
8373
8374        let url = url::Url::parse_with_params(&url, params).unwrap();
8375
8376        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
8377        let mut request_value_reader = {
8378            let mut value = json::value::to_value(&self._request).expect("serde to work");
8379            client::remove_json_null_values(&mut value);
8380            let mut dst = io::Cursor::new(Vec::with_capacity(128));
8381            json::to_writer(&mut dst, &value).unwrap();
8382            dst
8383        };
8384        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
8385        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8386
8387        loop {
8388            let token = match self
8389                .hub
8390                .auth
8391                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
8392                .await
8393            {
8394                Ok(token) => token.clone(),
8395                Err(err) => match dlg.token(&err) {
8396                    Some(token) => token,
8397                    None => {
8398                        dlg.finished(false);
8399                        return Err(client::Error::MissingToken(err));
8400                    }
8401                },
8402            };
8403            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8404            let mut req_result = {
8405                let client = &self.hub.client;
8406                dlg.pre_request();
8407                let mut req_builder = hyper::Request::builder()
8408                    .method(hyper::Method::POST)
8409                    .uri(url.clone().into_string())
8410                    .header(USER_AGENT, self.hub._user_agent.clone())
8411                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
8412
8413                let request = req_builder
8414                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
8415                    .header(CONTENT_LENGTH, request_size as u64)
8416                    .body(hyper::body::Body::from(
8417                        request_value_reader.get_ref().clone(),
8418                    ));
8419
8420                client.request(request.unwrap()).await
8421            };
8422
8423            match req_result {
8424                Err(err) => {
8425                    if let client::Retry::After(d) = dlg.http_error(&err) {
8426                        sleep(d);
8427                        continue;
8428                    }
8429                    dlg.finished(false);
8430                    return Err(client::Error::HttpError(err));
8431                }
8432                Ok(mut res) => {
8433                    if !res.status().is_success() {
8434                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8435                        let (parts, _) = res.into_parts();
8436                        let body = hyper::Body::from(res_body_string.clone());
8437                        let restored_response = hyper::Response::from_parts(parts, body);
8438
8439                        let server_response =
8440                            json::from_str::<serde_json::Value>(&res_body_string).ok();
8441
8442                        if let client::Retry::After(d) =
8443                            dlg.http_failure(&restored_response, server_response.clone())
8444                        {
8445                            sleep(d);
8446                            continue;
8447                        }
8448
8449                        dlg.finished(false);
8450
8451                        return match server_response {
8452                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
8453                            None => Err(client::Error::Failure(restored_response)),
8454                        };
8455                    }
8456                    let result_value = {
8457                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8458
8459                        match json::from_str(&res_body_string) {
8460                            Ok(decoded) => (res, decoded),
8461                            Err(err) => {
8462                                dlg.response_json_decode_error(&res_body_string, &err);
8463                                return Err(client::Error::JsonDecodeError(res_body_string, err));
8464                            }
8465                        }
8466                    };
8467
8468                    dlg.finished(true);
8469                    return Ok(result_value);
8470                }
8471            }
8472        }
8473    }
8474
8475    ///
8476    /// Sets the *request* property to the given value.
8477    ///
8478    /// Even though the property as already been set when instantiating this call,
8479    /// we provide this method for API completeness.
8480    pub fn request(mut self, new_value: File) -> FileCopyCall<'a, S> {
8481        self._request = new_value;
8482        self
8483    }
8484    /// The ID of the file.
8485    ///
8486    /// Sets the *file id* path property to the given value.
8487    ///
8488    /// Even though the property as already been set when instantiating this call,
8489    /// we provide this method for API completeness.
8490    pub fn file_id(mut self, new_value: &str) -> FileCopyCall<'a, S> {
8491        self._file_id = new_value.to_string();
8492        self
8493    }
8494    /// Deprecated use supportsAllDrives instead.
8495    ///
8496    /// Sets the *supports team drives* query property to the given value.
8497    pub fn supports_team_drives(mut self, new_value: bool) -> FileCopyCall<'a, S> {
8498        self._supports_team_drives = Some(new_value);
8499        self
8500    }
8501    /// Whether the requesting application supports both My Drives and shared drives.
8502    ///
8503    /// Sets the *supports all drives* query property to the given value.
8504    pub fn supports_all_drives(mut self, new_value: bool) -> FileCopyCall<'a, S> {
8505        self._supports_all_drives = Some(new_value);
8506        self
8507    }
8508    /// A language hint for OCR processing during image import (ISO 639-1 code).
8509    ///
8510    /// Sets the *ocr language* query property to the given value.
8511    pub fn ocr_language(mut self, new_value: &str) -> FileCopyCall<'a, S> {
8512        self._ocr_language = Some(new_value.to_string());
8513        self
8514    }
8515    /// Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
8516    ///
8517    /// Sets the *keep revision forever* query property to the given value.
8518    pub fn keep_revision_forever(mut self, new_value: bool) -> FileCopyCall<'a, S> {
8519        self._keep_revision_forever = Some(new_value);
8520        self
8521    }
8522    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
8523    ///
8524    /// Sets the *include permissions for view* query property to the given value.
8525    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCopyCall<'a, S> {
8526        self._include_permissions_for_view = Some(new_value.to_string());
8527        self
8528    }
8529    /// Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.
8530    ///
8531    /// Sets the *ignore default visibility* query property to the given value.
8532    pub fn ignore_default_visibility(mut self, new_value: bool) -> FileCopyCall<'a, S> {
8533        self._ignore_default_visibility = Some(new_value);
8534        self
8535    }
8536    /// Deprecated. Copying files into multiple folders is no longer supported. Use shortcuts instead.
8537    ///
8538    /// Sets the *enforce single parent* query property to the given value.
8539    pub fn enforce_single_parent(mut self, new_value: bool) -> FileCopyCall<'a, S> {
8540        self._enforce_single_parent = Some(new_value);
8541        self
8542    }
8543    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8544    /// while executing the actual API request.
8545    ///
8546    /// It should be used to handle progress information, and to implement a certain level of resilience.
8547    ///
8548    /// Sets the *delegate* property to the given value.
8549    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileCopyCall<'a, S> {
8550        self._delegate = Some(new_value);
8551        self
8552    }
8553
8554    /// Set any additional parameter of the query string used in the request.
8555    /// It should be used to set parameters which are not yet available through their own
8556    /// setters.
8557    ///
8558    /// Please note that this method must not be used to set any of the known parameters
8559    /// which have their own setter method. If done anyway, the request will fail.
8560    ///
8561    /// # Additional Parameters
8562    ///
8563    /// * *alt* (query-string) - Data format for the response.
8564    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8565    /// * *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.
8566    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8567    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8568    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8569    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8570    pub fn param<T>(mut self, name: T, value: T) -> FileCopyCall<'a, S>
8571    where
8572        T: AsRef<str>,
8573    {
8574        self._additional_params
8575            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8576        self
8577    }
8578
8579    /// Identifies the authorization scope for the method you are building.
8580    ///
8581    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
8582    /// `Scope::Full`.
8583    ///
8584    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8585    /// tokens for more than one scope.
8586    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
8587    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
8588    /// function for details).
8589    ///
8590    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8591    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8592    /// sufficient, a read-write scope will do as well.
8593    pub fn add_scope<T, St>(mut self, scope: T) -> FileCopyCall<'a, S>
8594    where
8595        T: Into<Option<St>>,
8596        St: AsRef<str>,
8597    {
8598        match scope.into() {
8599            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
8600            None => None,
8601        };
8602        self
8603    }
8604}
8605
8606/// Creates a new file.
8607///
8608/// A builder for the *create* method supported by a *file* resource.
8609/// It is not used directly, but through a `FileMethods` instance.
8610///
8611/// # Example
8612///
8613/// Instantiate a resource method builder
8614///
8615/// ```test_harness,no_run
8616/// # extern crate hyper;
8617/// # extern crate hyper_rustls;
8618/// # extern crate google_drive3 as drive3;
8619/// use drive3::api::File;
8620/// use std::fs;
8621/// # async fn dox() {
8622/// # use std::default::Default;
8623/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
8624///
8625/// # let secret: oauth2::ApplicationSecret = Default::default();
8626/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
8627/// #         secret,
8628/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8629/// #     ).build().await.unwrap();
8630/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
8631/// // As the method needs a request, you would usually fill it with the desired information
8632/// // into the respective structure. Some of the parts shown here might not be applicable !
8633/// // Values shown here are possibly random and not representative !
8634/// let mut req = File::default();
8635///
8636/// // You can configure optional parameters by calling the respective setters at will, and
8637/// // execute the final call using `upload(...)`.
8638/// // Values shown here are possibly random and not representative !
8639/// let result = hub.files().create(req)
8640///              .use_content_as_indexable_text(true)
8641///              .supports_team_drives(true)
8642///              .supports_all_drives(false)
8643///              .ocr_language("elitr")
8644///              .keep_revision_forever(true)
8645///              .include_permissions_for_view("est")
8646///              .ignore_default_visibility(true)
8647///              .enforce_single_parent(false)
8648///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
8649/// # }
8650/// ```
8651pub struct FileCreateCall<'a, S>
8652where
8653    S: 'a,
8654{
8655    hub: &'a DriveHub<S>,
8656    _request: File,
8657    _use_content_as_indexable_text: Option<bool>,
8658    _supports_team_drives: Option<bool>,
8659    _supports_all_drives: Option<bool>,
8660    _ocr_language: Option<String>,
8661    _keep_revision_forever: Option<bool>,
8662    _include_permissions_for_view: Option<String>,
8663    _ignore_default_visibility: Option<bool>,
8664    _enforce_single_parent: Option<bool>,
8665    _delegate: Option<&'a mut dyn client::Delegate>,
8666    _additional_params: HashMap<String, String>,
8667    _scopes: BTreeMap<String, ()>,
8668}
8669
8670impl<'a, S> client::CallBuilder for FileCreateCall<'a, S> {}
8671
8672impl<'a, S> FileCreateCall<'a, S>
8673where
8674    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
8675    S::Response:
8676        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
8677    S::Future: Send + Unpin + 'static,
8678    S::Error: Into<Box<dyn StdError + Send + Sync>>,
8679{
8680    /// Perform the operation you have build so far.
8681    async fn doit<RS>(
8682        mut self,
8683        mut reader: RS,
8684        reader_mime_type: mime::Mime,
8685        protocol: &'static str,
8686    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
8687    where
8688        RS: client::ReadSeek,
8689    {
8690        use client::ToParts;
8691        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8692        use std::io::{Read, Seek};
8693        let mut dd = client::DefaultDelegate;
8694        let mut dlg: &mut dyn client::Delegate = match self._delegate {
8695            Some(d) => d,
8696            None => &mut dd,
8697        };
8698        dlg.begin(client::MethodInfo {
8699            id: "drive.files.create",
8700            http_method: hyper::Method::POST,
8701        });
8702        let mut params: Vec<(&str, String)> =
8703            Vec::with_capacity(11 + self._additional_params.len());
8704        if let Some(value) = self._use_content_as_indexable_text {
8705            params.push(("useContentAsIndexableText", value.to_string()));
8706        }
8707        if let Some(value) = self._supports_team_drives {
8708            params.push(("supportsTeamDrives", value.to_string()));
8709        }
8710        if let Some(value) = self._supports_all_drives {
8711            params.push(("supportsAllDrives", value.to_string()));
8712        }
8713        if let Some(value) = self._ocr_language {
8714            params.push(("ocrLanguage", value.to_string()));
8715        }
8716        if let Some(value) = self._keep_revision_forever {
8717            params.push(("keepRevisionForever", value.to_string()));
8718        }
8719        if let Some(value) = self._include_permissions_for_view {
8720            params.push(("includePermissionsForView", value.to_string()));
8721        }
8722        if let Some(value) = self._ignore_default_visibility {
8723            params.push(("ignoreDefaultVisibility", value.to_string()));
8724        }
8725        if let Some(value) = self._enforce_single_parent {
8726            params.push(("enforceSingleParent", value.to_string()));
8727        }
8728        for &field in [
8729            "alt",
8730            "useContentAsIndexableText",
8731            "supportsTeamDrives",
8732            "supportsAllDrives",
8733            "ocrLanguage",
8734            "keepRevisionForever",
8735            "includePermissionsForView",
8736            "ignoreDefaultVisibility",
8737            "enforceSingleParent",
8738        ]
8739        .iter()
8740        {
8741            if self._additional_params.contains_key(field) {
8742                dlg.finished(false);
8743                return Err(client::Error::FieldClash(field));
8744            }
8745        }
8746        for (name, value) in self._additional_params.iter() {
8747            params.push((&name, value.clone()));
8748        }
8749
8750        params.push(("alt", "json".to_string()));
8751
8752        let (mut url, upload_type) = if protocol == "resumable" {
8753            (
8754                self.hub._root_url.clone() + "resumable/upload/drive/v3/files",
8755                "resumable",
8756            )
8757        } else if protocol == "simple" {
8758            (
8759                self.hub._root_url.clone() + "upload/drive/v3/files",
8760                "multipart",
8761            )
8762        } else {
8763            unreachable!()
8764        };
8765        params.push(("uploadType", upload_type.to_string()));
8766        if self._scopes.len() == 0 {
8767            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
8768        }
8769
8770        let url = url::Url::parse_with_params(&url, params).unwrap();
8771
8772        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
8773        let mut request_value_reader = {
8774            let mut value = json::value::to_value(&self._request).expect("serde to work");
8775            client::remove_json_null_values(&mut value);
8776            let mut dst = io::Cursor::new(Vec::with_capacity(128));
8777            json::to_writer(&mut dst, &value).unwrap();
8778            dst
8779        };
8780        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
8781        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8782
8783        let mut should_ask_dlg_for_url = false;
8784        let mut upload_url_from_server;
8785        let mut upload_url: Option<String> = None;
8786
8787        loop {
8788            let token = match self
8789                .hub
8790                .auth
8791                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
8792                .await
8793            {
8794                Ok(token) => token.clone(),
8795                Err(err) => match dlg.token(&err) {
8796                    Some(token) => token,
8797                    None => {
8798                        dlg.finished(false);
8799                        return Err(client::Error::MissingToken(err));
8800                    }
8801                },
8802            };
8803            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
8804            let mut req_result = {
8805                if should_ask_dlg_for_url
8806                    && (upload_url = dlg.upload_url()) == ()
8807                    && upload_url.is_some()
8808                {
8809                    should_ask_dlg_for_url = false;
8810                    upload_url_from_server = false;
8811                    Ok(hyper::Response::builder()
8812                        .status(hyper::StatusCode::OK)
8813                        .header("Location", upload_url.as_ref().unwrap().clone())
8814                        .body(hyper::body::Body::empty())
8815                        .unwrap())
8816                } else {
8817                    let mut mp_reader: client::MultiPartReader = Default::default();
8818                    let (mut body_reader, content_type) = match protocol {
8819                        "simple" => {
8820                            mp_reader.reserve_exact(2);
8821                            let size = reader.seek(io::SeekFrom::End(0)).unwrap();
8822                            reader.seek(io::SeekFrom::Start(0)).unwrap();
8823                            if size > 5497558138880 {
8824                                return Err(client::Error::UploadSizeLimitExceeded(
8825                                    size,
8826                                    5497558138880,
8827                                ));
8828                            }
8829                            mp_reader
8830                                .add_part(
8831                                    &mut request_value_reader,
8832                                    request_size,
8833                                    json_mime_type.clone(),
8834                                )
8835                                .add_part(&mut reader, size, reader_mime_type.clone());
8836                            let mime_type = mp_reader.mime_type();
8837                            (
8838                                &mut mp_reader as &mut (dyn io::Read + Send),
8839                                (CONTENT_TYPE, mime_type.to_string()),
8840                            )
8841                        }
8842                        _ => (
8843                            &mut request_value_reader as &mut (dyn io::Read + Send),
8844                            (CONTENT_TYPE, json_mime_type.to_string()),
8845                        ),
8846                    };
8847                    let client = &self.hub.client;
8848                    dlg.pre_request();
8849                    let mut req_builder = hyper::Request::builder()
8850                        .method(hyper::Method::POST)
8851                        .uri(url.clone().into_string())
8852                        .header(USER_AGENT, self.hub._user_agent.clone())
8853                        .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
8854
8855                    upload_url_from_server = true;
8856                    if protocol == "resumable" {
8857                        req_builder = req_builder
8858                            .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
8859                    }
8860
8861                    let mut body_reader_bytes = vec![];
8862                    body_reader.read_to_end(&mut body_reader_bytes).unwrap();
8863                    let request = req_builder
8864                        .header(content_type.0, content_type.1.to_string())
8865                        .body(hyper::body::Body::from(body_reader_bytes));
8866
8867                    client.request(request.unwrap()).await
8868                }
8869            };
8870
8871            match req_result {
8872                Err(err) => {
8873                    if let client::Retry::After(d) = dlg.http_error(&err) {
8874                        sleep(d);
8875                        continue;
8876                    }
8877                    dlg.finished(false);
8878                    return Err(client::Error::HttpError(err));
8879                }
8880                Ok(mut res) => {
8881                    if !res.status().is_success() {
8882                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8883                        let (parts, _) = res.into_parts();
8884                        let body = hyper::Body::from(res_body_string.clone());
8885                        let restored_response = hyper::Response::from_parts(parts, body);
8886
8887                        let server_response =
8888                            json::from_str::<serde_json::Value>(&res_body_string).ok();
8889
8890                        if let client::Retry::After(d) =
8891                            dlg.http_failure(&restored_response, server_response.clone())
8892                        {
8893                            sleep(d);
8894                            continue;
8895                        }
8896
8897                        dlg.finished(false);
8898
8899                        return match server_response {
8900                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
8901                            None => Err(client::Error::Failure(restored_response)),
8902                        };
8903                    }
8904                    if protocol == "resumable" {
8905                        let size = reader.seek(io::SeekFrom::End(0)).unwrap();
8906                        reader.seek(io::SeekFrom::Start(0)).unwrap();
8907                        if size > 5497558138880 {
8908                            return Err(client::Error::UploadSizeLimitExceeded(
8909                                size,
8910                                5497558138880,
8911                            ));
8912                        }
8913                        let upload_result = {
8914                            let url_str = &res
8915                                .headers()
8916                                .get("Location")
8917                                .expect("LOCATION header is part of protocol")
8918                                .to_str()
8919                                .unwrap();
8920                            if upload_url_from_server {
8921                                dlg.store_upload_url(Some(url_str));
8922                            }
8923
8924                            client::ResumableUploadHelper {
8925                                client: &self.hub.client,
8926                                delegate: dlg,
8927                                start_at: if upload_url_from_server {
8928                                    Some(0)
8929                                } else {
8930                                    None
8931                                },
8932                                auth: &self.hub.auth,
8933                                user_agent: &self.hub._user_agent,
8934                                auth_header: format!("Bearer {}", token.as_str()),
8935                                url: url_str,
8936                                reader: &mut reader,
8937                                media_type: reader_mime_type.clone(),
8938                                content_length: size,
8939                            }
8940                            .upload()
8941                            .await
8942                        };
8943                        match upload_result {
8944                            None => {
8945                                dlg.finished(false);
8946                                return Err(client::Error::Cancelled);
8947                            }
8948                            Some(Err(err)) => {
8949                                dlg.finished(false);
8950                                return Err(client::Error::HttpError(err));
8951                            }
8952                            Some(Ok(upload_result)) => {
8953                                res = upload_result;
8954                                if !res.status().is_success() {
8955                                    dlg.store_upload_url(None);
8956                                    dlg.finished(false);
8957                                    return Err(client::Error::Failure(res));
8958                                }
8959                            }
8960                        }
8961                    }
8962                    let result_value = {
8963                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
8964
8965                        match json::from_str(&res_body_string) {
8966                            Ok(decoded) => (res, decoded),
8967                            Err(err) => {
8968                                dlg.response_json_decode_error(&res_body_string, &err);
8969                                return Err(client::Error::JsonDecodeError(res_body_string, err));
8970                            }
8971                        }
8972                    };
8973
8974                    dlg.finished(true);
8975                    return Ok(result_value);
8976                }
8977            }
8978        }
8979    }
8980
8981    /// Upload media in a resumable fashion.
8982    /// Even if the upload fails or is interrupted, it can be resumed for a
8983    /// certain amount of time as the server maintains state temporarily.
8984    ///
8985    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
8986    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
8987    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
8988    /// `cancel_chunk_upload(...)`.
8989    ///
8990    /// * *multipart*: yes
8991    /// * *max size*: 5120GB
8992    /// * *valid mime types*: '*/*'
8993    pub async fn upload_resumable<RS>(
8994        self,
8995        resumeable_stream: RS,
8996        mime_type: mime::Mime,
8997    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
8998    where
8999        RS: client::ReadSeek,
9000    {
9001        self.doit(resumeable_stream, mime_type, "resumable").await
9002    }
9003    /// Upload media all at once.
9004    /// If the upload fails for whichever reason, all progress is lost.
9005    ///
9006    /// * *multipart*: yes
9007    /// * *max size*: 5120GB
9008    /// * *valid mime types*: '*/*'
9009    pub async fn upload<RS>(
9010        self,
9011        stream: RS,
9012        mime_type: mime::Mime,
9013    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
9014    where
9015        RS: client::ReadSeek,
9016    {
9017        self.doit(stream, mime_type, "simple").await
9018    }
9019
9020    ///
9021    /// Sets the *request* property to the given value.
9022    ///
9023    /// Even though the property as already been set when instantiating this call,
9024    /// we provide this method for API completeness.
9025    pub fn request(mut self, new_value: File) -> FileCreateCall<'a, S> {
9026        self._request = new_value;
9027        self
9028    }
9029    /// Whether to use the uploaded content as indexable text.
9030    ///
9031    /// Sets the *use content as indexable text* query property to the given value.
9032    pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9033        self._use_content_as_indexable_text = Some(new_value);
9034        self
9035    }
9036    /// Deprecated use supportsAllDrives instead.
9037    ///
9038    /// Sets the *supports team drives* query property to the given value.
9039    pub fn supports_team_drives(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9040        self._supports_team_drives = Some(new_value);
9041        self
9042    }
9043    /// Whether the requesting application supports both My Drives and shared drives.
9044    ///
9045    /// Sets the *supports all drives* query property to the given value.
9046    pub fn supports_all_drives(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9047        self._supports_all_drives = Some(new_value);
9048        self
9049    }
9050    /// A language hint for OCR processing during image import (ISO 639-1 code).
9051    ///
9052    /// Sets the *ocr language* query property to the given value.
9053    pub fn ocr_language(mut self, new_value: &str) -> FileCreateCall<'a, S> {
9054        self._ocr_language = Some(new_value.to_string());
9055        self
9056    }
9057    /// Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
9058    ///
9059    /// Sets the *keep revision forever* query property to the given value.
9060    pub fn keep_revision_forever(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9061        self._keep_revision_forever = Some(new_value);
9062        self
9063    }
9064    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
9065    ///
9066    /// Sets the *include permissions for view* query property to the given value.
9067    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileCreateCall<'a, S> {
9068        self._include_permissions_for_view = Some(new_value.to_string());
9069        self
9070    }
9071    /// Whether to ignore the domain's default visibility settings for the created file. Domain administrators can choose to make all uploaded files visible to the domain by default; this parameter bypasses that behavior for the request. Permissions are still inherited from parent folders.
9072    ///
9073    /// Sets the *ignore default visibility* query property to the given value.
9074    pub fn ignore_default_visibility(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9075        self._ignore_default_visibility = Some(new_value);
9076        self
9077    }
9078    /// Deprecated. Creating files in multiple folders is no longer supported.
9079    ///
9080    /// Sets the *enforce single parent* query property to the given value.
9081    pub fn enforce_single_parent(mut self, new_value: bool) -> FileCreateCall<'a, S> {
9082        self._enforce_single_parent = Some(new_value);
9083        self
9084    }
9085    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9086    /// while executing the actual API request.
9087    ///
9088    /// It should be used to handle progress information, and to implement a certain level of resilience.
9089    ///
9090    /// Sets the *delegate* property to the given value.
9091    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileCreateCall<'a, S> {
9092        self._delegate = Some(new_value);
9093        self
9094    }
9095
9096    /// Set any additional parameter of the query string used in the request.
9097    /// It should be used to set parameters which are not yet available through their own
9098    /// setters.
9099    ///
9100    /// Please note that this method must not be used to set any of the known parameters
9101    /// which have their own setter method. If done anyway, the request will fail.
9102    ///
9103    /// # Additional Parameters
9104    ///
9105    /// * *alt* (query-string) - Data format for the response.
9106    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9107    /// * *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.
9108    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9109    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9110    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9111    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9112    pub fn param<T>(mut self, name: T, value: T) -> FileCreateCall<'a, S>
9113    where
9114        T: AsRef<str>,
9115    {
9116        self._additional_params
9117            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9118        self
9119    }
9120
9121    /// Identifies the authorization scope for the method you are building.
9122    ///
9123    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9124    /// `Scope::Full`.
9125    ///
9126    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9127    /// tokens for more than one scope.
9128    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9129    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9130    /// function for details).
9131    ///
9132    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9133    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9134    /// sufficient, a read-write scope will do as well.
9135    pub fn add_scope<T, St>(mut self, scope: T) -> FileCreateCall<'a, S>
9136    where
9137        T: Into<Option<St>>,
9138        St: AsRef<str>,
9139    {
9140        match scope.into() {
9141            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9142            None => None,
9143        };
9144        self
9145    }
9146}
9147
9148/// Permanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive the user must be an organizer on the parent. If the target is a folder, all descendants owned by the user are also deleted.
9149///
9150/// A builder for the *delete* method supported by a *file* resource.
9151/// It is not used directly, but through a `FileMethods` instance.
9152///
9153/// # Example
9154///
9155/// Instantiate a resource method builder
9156///
9157/// ```test_harness,no_run
9158/// # extern crate hyper;
9159/// # extern crate hyper_rustls;
9160/// # extern crate google_drive3 as drive3;
9161/// # async fn dox() {
9162/// # use std::default::Default;
9163/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
9164///
9165/// # let secret: oauth2::ApplicationSecret = Default::default();
9166/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
9167/// #         secret,
9168/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9169/// #     ).build().await.unwrap();
9170/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
9171/// // You can configure optional parameters by calling the respective setters at will, and
9172/// // execute the final call using `doit()`.
9173/// // Values shown here are possibly random and not representative !
9174/// let result = hub.files().delete("fileId")
9175///              .supports_team_drives(true)
9176///              .supports_all_drives(true)
9177///              .enforce_single_parent(false)
9178///              .doit().await;
9179/// # }
9180/// ```
9181pub struct FileDeleteCall<'a, S>
9182where
9183    S: 'a,
9184{
9185    hub: &'a DriveHub<S>,
9186    _file_id: String,
9187    _supports_team_drives: Option<bool>,
9188    _supports_all_drives: Option<bool>,
9189    _enforce_single_parent: Option<bool>,
9190    _delegate: Option<&'a mut dyn client::Delegate>,
9191    _additional_params: HashMap<String, String>,
9192    _scopes: BTreeMap<String, ()>,
9193}
9194
9195impl<'a, S> client::CallBuilder for FileDeleteCall<'a, S> {}
9196
9197impl<'a, S> FileDeleteCall<'a, S>
9198where
9199    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
9200    S::Response:
9201        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
9202    S::Future: Send + Unpin + 'static,
9203    S::Error: Into<Box<dyn StdError + Send + Sync>>,
9204{
9205    /// Perform the operation you have build so far.
9206    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
9207        use client::ToParts;
9208        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9209        use std::io::{Read, Seek};
9210        let mut dd = client::DefaultDelegate;
9211        let mut dlg: &mut dyn client::Delegate = match self._delegate {
9212            Some(d) => d,
9213            None => &mut dd,
9214        };
9215        dlg.begin(client::MethodInfo {
9216            id: "drive.files.delete",
9217            http_method: hyper::Method::DELETE,
9218        });
9219        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
9220        params.push(("fileId", self._file_id.to_string()));
9221        if let Some(value) = self._supports_team_drives {
9222            params.push(("supportsTeamDrives", value.to_string()));
9223        }
9224        if let Some(value) = self._supports_all_drives {
9225            params.push(("supportsAllDrives", value.to_string()));
9226        }
9227        if let Some(value) = self._enforce_single_parent {
9228            params.push(("enforceSingleParent", value.to_string()));
9229        }
9230        for &field in [
9231            "fileId",
9232            "supportsTeamDrives",
9233            "supportsAllDrives",
9234            "enforceSingleParent",
9235        ]
9236        .iter()
9237        {
9238            if self._additional_params.contains_key(field) {
9239                dlg.finished(false);
9240                return Err(client::Error::FieldClash(field));
9241            }
9242        }
9243        for (name, value) in self._additional_params.iter() {
9244            params.push((&name, value.clone()));
9245        }
9246
9247        let mut url = self.hub._base_url.clone() + "files/{fileId}";
9248        if self._scopes.len() == 0 {
9249            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
9250        }
9251
9252        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
9253            let mut replace_with: Option<&str> = None;
9254            for &(name, ref value) in params.iter() {
9255                if name == param_name {
9256                    replace_with = Some(value);
9257                    break;
9258                }
9259            }
9260            url = url.replace(
9261                find_this,
9262                replace_with.expect("to find substitution value in params"),
9263            );
9264        }
9265        {
9266            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
9267            for param_name in ["fileId"].iter() {
9268                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
9269                    indices_for_removal.push(index);
9270                }
9271            }
9272            for &index in indices_for_removal.iter() {
9273                params.remove(index);
9274            }
9275        }
9276
9277        let url = url::Url::parse_with_params(&url, params).unwrap();
9278
9279        loop {
9280            let token = match self
9281                .hub
9282                .auth
9283                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
9284                .await
9285            {
9286                Ok(token) => token.clone(),
9287                Err(err) => match dlg.token(&err) {
9288                    Some(token) => token,
9289                    None => {
9290                        dlg.finished(false);
9291                        return Err(client::Error::MissingToken(err));
9292                    }
9293                },
9294            };
9295            let mut req_result = {
9296                let client = &self.hub.client;
9297                dlg.pre_request();
9298                let mut req_builder = hyper::Request::builder()
9299                    .method(hyper::Method::DELETE)
9300                    .uri(url.clone().into_string())
9301                    .header(USER_AGENT, self.hub._user_agent.clone())
9302                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
9303
9304                let request = req_builder.body(hyper::body::Body::empty());
9305
9306                client.request(request.unwrap()).await
9307            };
9308
9309            match req_result {
9310                Err(err) => {
9311                    if let client::Retry::After(d) = dlg.http_error(&err) {
9312                        sleep(d);
9313                        continue;
9314                    }
9315                    dlg.finished(false);
9316                    return Err(client::Error::HttpError(err));
9317                }
9318                Ok(mut res) => {
9319                    if !res.status().is_success() {
9320                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
9321                        let (parts, _) = res.into_parts();
9322                        let body = hyper::Body::from(res_body_string.clone());
9323                        let restored_response = hyper::Response::from_parts(parts, body);
9324
9325                        let server_response =
9326                            json::from_str::<serde_json::Value>(&res_body_string).ok();
9327
9328                        if let client::Retry::After(d) =
9329                            dlg.http_failure(&restored_response, server_response.clone())
9330                        {
9331                            sleep(d);
9332                            continue;
9333                        }
9334
9335                        dlg.finished(false);
9336
9337                        return match server_response {
9338                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
9339                            None => Err(client::Error::Failure(restored_response)),
9340                        };
9341                    }
9342                    let result_value = res;
9343
9344                    dlg.finished(true);
9345                    return Ok(result_value);
9346                }
9347            }
9348        }
9349    }
9350
9351    /// The ID of the file.
9352    ///
9353    /// Sets the *file id* path property to the given value.
9354    ///
9355    /// Even though the property as already been set when instantiating this call,
9356    /// we provide this method for API completeness.
9357    pub fn file_id(mut self, new_value: &str) -> FileDeleteCall<'a, S> {
9358        self._file_id = new_value.to_string();
9359        self
9360    }
9361    /// Deprecated use supportsAllDrives instead.
9362    ///
9363    /// Sets the *supports team drives* query property to the given value.
9364    pub fn supports_team_drives(mut self, new_value: bool) -> FileDeleteCall<'a, S> {
9365        self._supports_team_drives = Some(new_value);
9366        self
9367    }
9368    /// Whether the requesting application supports both My Drives and shared drives.
9369    ///
9370    /// Sets the *supports all drives* query property to the given value.
9371    pub fn supports_all_drives(mut self, new_value: bool) -> FileDeleteCall<'a, S> {
9372        self._supports_all_drives = Some(new_value);
9373        self
9374    }
9375    /// Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root.
9376    ///
9377    /// Sets the *enforce single parent* query property to the given value.
9378    pub fn enforce_single_parent(mut self, new_value: bool) -> FileDeleteCall<'a, S> {
9379        self._enforce_single_parent = Some(new_value);
9380        self
9381    }
9382    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9383    /// while executing the actual API request.
9384    ///
9385    /// It should be used to handle progress information, and to implement a certain level of resilience.
9386    ///
9387    /// Sets the *delegate* property to the given value.
9388    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileDeleteCall<'a, S> {
9389        self._delegate = Some(new_value);
9390        self
9391    }
9392
9393    /// Set any additional parameter of the query string used in the request.
9394    /// It should be used to set parameters which are not yet available through their own
9395    /// setters.
9396    ///
9397    /// Please note that this method must not be used to set any of the known parameters
9398    /// which have their own setter method. If done anyway, the request will fail.
9399    ///
9400    /// # Additional Parameters
9401    ///
9402    /// * *alt* (query-string) - Data format for the response.
9403    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9404    /// * *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.
9405    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9406    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9407    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9408    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9409    pub fn param<T>(mut self, name: T, value: T) -> FileDeleteCall<'a, S>
9410    where
9411        T: AsRef<str>,
9412    {
9413        self._additional_params
9414            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9415        self
9416    }
9417
9418    /// Identifies the authorization scope for the method you are building.
9419    ///
9420    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9421    /// `Scope::Full`.
9422    ///
9423    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9424    /// tokens for more than one scope.
9425    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9426    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9427    /// function for details).
9428    ///
9429    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9430    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9431    /// sufficient, a read-write scope will do as well.
9432    pub fn add_scope<T, St>(mut self, scope: T) -> FileDeleteCall<'a, S>
9433    where
9434        T: Into<Option<St>>,
9435        St: AsRef<str>,
9436    {
9437        match scope.into() {
9438            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9439            None => None,
9440        };
9441        self
9442    }
9443}
9444
9445/// Permanently deletes all of the user's trashed files.
9446///
9447/// A builder for the *emptyTrash* method supported by a *file* resource.
9448/// It is not used directly, but through a `FileMethods` instance.
9449///
9450/// # Example
9451///
9452/// Instantiate a resource method builder
9453///
9454/// ```test_harness,no_run
9455/// # extern crate hyper;
9456/// # extern crate hyper_rustls;
9457/// # extern crate google_drive3 as drive3;
9458/// # async fn dox() {
9459/// # use std::default::Default;
9460/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
9461///
9462/// # let secret: oauth2::ApplicationSecret = Default::default();
9463/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
9464/// #         secret,
9465/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9466/// #     ).build().await.unwrap();
9467/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
9468/// // You can configure optional parameters by calling the respective setters at will, and
9469/// // execute the final call using `doit()`.
9470/// // Values shown here are possibly random and not representative !
9471/// let result = hub.files().empty_trash()
9472///              .enforce_single_parent(false)
9473///              .doit().await;
9474/// # }
9475/// ```
9476pub struct FileEmptyTrashCall<'a, S>
9477where
9478    S: 'a,
9479{
9480    hub: &'a DriveHub<S>,
9481    _enforce_single_parent: Option<bool>,
9482    _delegate: Option<&'a mut dyn client::Delegate>,
9483    _additional_params: HashMap<String, String>,
9484    _scopes: BTreeMap<String, ()>,
9485}
9486
9487impl<'a, S> client::CallBuilder for FileEmptyTrashCall<'a, S> {}
9488
9489impl<'a, S> FileEmptyTrashCall<'a, S>
9490where
9491    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
9492    S::Response:
9493        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
9494    S::Future: Send + Unpin + 'static,
9495    S::Error: Into<Box<dyn StdError + Send + Sync>>,
9496{
9497    /// Perform the operation you have build so far.
9498    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
9499        use client::ToParts;
9500        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9501        use std::io::{Read, Seek};
9502        let mut dd = client::DefaultDelegate;
9503        let mut dlg: &mut dyn client::Delegate = match self._delegate {
9504            Some(d) => d,
9505            None => &mut dd,
9506        };
9507        dlg.begin(client::MethodInfo {
9508            id: "drive.files.emptyTrash",
9509            http_method: hyper::Method::DELETE,
9510        });
9511        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
9512        if let Some(value) = self._enforce_single_parent {
9513            params.push(("enforceSingleParent", value.to_string()));
9514        }
9515        for &field in ["enforceSingleParent"].iter() {
9516            if self._additional_params.contains_key(field) {
9517                dlg.finished(false);
9518                return Err(client::Error::FieldClash(field));
9519            }
9520        }
9521        for (name, value) in self._additional_params.iter() {
9522            params.push((&name, value.clone()));
9523        }
9524
9525        let mut url = self.hub._base_url.clone() + "files/trash";
9526        if self._scopes.len() == 0 {
9527            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
9528        }
9529
9530        let url = url::Url::parse_with_params(&url, params).unwrap();
9531
9532        loop {
9533            let token = match self
9534                .hub
9535                .auth
9536                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
9537                .await
9538            {
9539                Ok(token) => token.clone(),
9540                Err(err) => match dlg.token(&err) {
9541                    Some(token) => token,
9542                    None => {
9543                        dlg.finished(false);
9544                        return Err(client::Error::MissingToken(err));
9545                    }
9546                },
9547            };
9548            let mut req_result = {
9549                let client = &self.hub.client;
9550                dlg.pre_request();
9551                let mut req_builder = hyper::Request::builder()
9552                    .method(hyper::Method::DELETE)
9553                    .uri(url.clone().into_string())
9554                    .header(USER_AGENT, self.hub._user_agent.clone())
9555                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
9556
9557                let request = req_builder.body(hyper::body::Body::empty());
9558
9559                client.request(request.unwrap()).await
9560            };
9561
9562            match req_result {
9563                Err(err) => {
9564                    if let client::Retry::After(d) = dlg.http_error(&err) {
9565                        sleep(d);
9566                        continue;
9567                    }
9568                    dlg.finished(false);
9569                    return Err(client::Error::HttpError(err));
9570                }
9571                Ok(mut res) => {
9572                    if !res.status().is_success() {
9573                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
9574                        let (parts, _) = res.into_parts();
9575                        let body = hyper::Body::from(res_body_string.clone());
9576                        let restored_response = hyper::Response::from_parts(parts, body);
9577
9578                        let server_response =
9579                            json::from_str::<serde_json::Value>(&res_body_string).ok();
9580
9581                        if let client::Retry::After(d) =
9582                            dlg.http_failure(&restored_response, server_response.clone())
9583                        {
9584                            sleep(d);
9585                            continue;
9586                        }
9587
9588                        dlg.finished(false);
9589
9590                        return match server_response {
9591                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
9592                            None => Err(client::Error::Failure(restored_response)),
9593                        };
9594                    }
9595                    let result_value = res;
9596
9597                    dlg.finished(true);
9598                    return Ok(result_value);
9599                }
9600            }
9601        }
9602    }
9603
9604    /// Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root.
9605    ///
9606    /// Sets the *enforce single parent* query property to the given value.
9607    pub fn enforce_single_parent(mut self, new_value: bool) -> FileEmptyTrashCall<'a, S> {
9608        self._enforce_single_parent = Some(new_value);
9609        self
9610    }
9611    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9612    /// while executing the actual API request.
9613    ///
9614    /// It should be used to handle progress information, and to implement a certain level of resilience.
9615    ///
9616    /// Sets the *delegate* property to the given value.
9617    pub fn delegate(
9618        mut self,
9619        new_value: &'a mut dyn client::Delegate,
9620    ) -> FileEmptyTrashCall<'a, S> {
9621        self._delegate = Some(new_value);
9622        self
9623    }
9624
9625    /// Set any additional parameter of the query string used in the request.
9626    /// It should be used to set parameters which are not yet available through their own
9627    /// setters.
9628    ///
9629    /// Please note that this method must not be used to set any of the known parameters
9630    /// which have their own setter method. If done anyway, the request will fail.
9631    ///
9632    /// # Additional Parameters
9633    ///
9634    /// * *alt* (query-string) - Data format for the response.
9635    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9636    /// * *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.
9637    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9638    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9639    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9640    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9641    pub fn param<T>(mut self, name: T, value: T) -> FileEmptyTrashCall<'a, S>
9642    where
9643        T: AsRef<str>,
9644    {
9645        self._additional_params
9646            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9647        self
9648    }
9649
9650    /// Identifies the authorization scope for the method you are building.
9651    ///
9652    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9653    /// `Scope::Full`.
9654    ///
9655    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9656    /// tokens for more than one scope.
9657    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9658    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9659    /// function for details).
9660    ///
9661    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9662    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9663    /// sufficient, a read-write scope will do as well.
9664    pub fn add_scope<T, St>(mut self, scope: T) -> FileEmptyTrashCall<'a, S>
9665    where
9666        T: Into<Option<St>>,
9667        St: AsRef<str>,
9668    {
9669        match scope.into() {
9670            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9671            None => None,
9672        };
9673        self
9674    }
9675}
9676
9677/// Exports a Google Workspace document to the requested MIME type and returns exported byte content. Note that the exported content is limited to 10MB.
9678///
9679/// This method supports **media download**. To enable it, adjust the builder like this:
9680/// `.param("alt", "media")`.
9681///
9682/// A builder for the *export* method supported by a *file* resource.
9683/// It is not used directly, but through a `FileMethods` instance.
9684///
9685/// # Example
9686///
9687/// Instantiate a resource method builder
9688///
9689/// ```test_harness,no_run
9690/// # extern crate hyper;
9691/// # extern crate hyper_rustls;
9692/// # extern crate google_drive3 as drive3;
9693/// # async fn dox() {
9694/// # use std::default::Default;
9695/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
9696///
9697/// # let secret: oauth2::ApplicationSecret = Default::default();
9698/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
9699/// #         secret,
9700/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9701/// #     ).build().await.unwrap();
9702/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
9703/// // You can configure optional parameters by calling the respective setters at will, and
9704/// // execute the final call using `doit()`.
9705/// // Values shown here are possibly random and not representative !
9706/// let result = hub.files().export("fileId", "mimeType")
9707///              .doit().await;
9708/// # }
9709/// ```
9710pub struct FileExportCall<'a, S>
9711where
9712    S: 'a,
9713{
9714    hub: &'a DriveHub<S>,
9715    _file_id: String,
9716    _mime_type: String,
9717    _delegate: Option<&'a mut dyn client::Delegate>,
9718    _additional_params: HashMap<String, String>,
9719    _scopes: BTreeMap<String, ()>,
9720}
9721
9722impl<'a, S> client::CallBuilder for FileExportCall<'a, S> {}
9723
9724impl<'a, S> FileExportCall<'a, S>
9725where
9726    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
9727    S::Response:
9728        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
9729    S::Future: Send + Unpin + 'static,
9730    S::Error: Into<Box<dyn StdError + Send + Sync>>,
9731{
9732    /// Perform the operation you have build so far.
9733    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
9734        use client::ToParts;
9735        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9736        use std::io::{Read, Seek};
9737        let mut dd = client::DefaultDelegate;
9738        let mut dlg: &mut dyn client::Delegate = match self._delegate {
9739            Some(d) => d,
9740            None => &mut dd,
9741        };
9742        dlg.begin(client::MethodInfo {
9743            id: "drive.files.export",
9744            http_method: hyper::Method::GET,
9745        });
9746        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
9747        params.push(("fileId", self._file_id.to_string()));
9748        params.push(("mimeType", self._mime_type.to_string()));
9749        for &field in ["fileId", "mimeType"].iter() {
9750            if self._additional_params.contains_key(field) {
9751                dlg.finished(false);
9752                return Err(client::Error::FieldClash(field));
9753            }
9754        }
9755        for (name, value) in self._additional_params.iter() {
9756            params.push((&name, value.clone()));
9757        }
9758
9759        let mut url = self.hub._base_url.clone() + "files/{fileId}/export";
9760        if self._scopes.len() == 0 {
9761            self._scopes
9762                .insert(Scope::Readonly.as_ref().to_string(), ());
9763        }
9764
9765        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
9766            let mut replace_with: Option<&str> = None;
9767            for &(name, ref value) in params.iter() {
9768                if name == param_name {
9769                    replace_with = Some(value);
9770                    break;
9771                }
9772            }
9773            url = url.replace(
9774                find_this,
9775                replace_with.expect("to find substitution value in params"),
9776            );
9777        }
9778        {
9779            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
9780            for param_name in ["fileId"].iter() {
9781                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
9782                    indices_for_removal.push(index);
9783                }
9784            }
9785            for &index in indices_for_removal.iter() {
9786                params.remove(index);
9787            }
9788        }
9789
9790        let url = url::Url::parse_with_params(&url, params).unwrap();
9791
9792        loop {
9793            let token = match self
9794                .hub
9795                .auth
9796                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
9797                .await
9798            {
9799                Ok(token) => token.clone(),
9800                Err(err) => match dlg.token(&err) {
9801                    Some(token) => token,
9802                    None => {
9803                        dlg.finished(false);
9804                        return Err(client::Error::MissingToken(err));
9805                    }
9806                },
9807            };
9808            let mut req_result = {
9809                let client = &self.hub.client;
9810                dlg.pre_request();
9811                let mut req_builder = hyper::Request::builder()
9812                    .method(hyper::Method::GET)
9813                    .uri(url.clone().into_string())
9814                    .header(USER_AGENT, self.hub._user_agent.clone())
9815                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
9816
9817                let request = req_builder.body(hyper::body::Body::empty());
9818
9819                client.request(request.unwrap()).await
9820            };
9821
9822            match req_result {
9823                Err(err) => {
9824                    if let client::Retry::After(d) = dlg.http_error(&err) {
9825                        sleep(d);
9826                        continue;
9827                    }
9828                    dlg.finished(false);
9829                    return Err(client::Error::HttpError(err));
9830                }
9831                Ok(mut res) => {
9832                    if !res.status().is_success() {
9833                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
9834                        let (parts, _) = res.into_parts();
9835                        let body = hyper::Body::from(res_body_string.clone());
9836                        let restored_response = hyper::Response::from_parts(parts, body);
9837
9838                        let server_response =
9839                            json::from_str::<serde_json::Value>(&res_body_string).ok();
9840
9841                        if let client::Retry::After(d) =
9842                            dlg.http_failure(&restored_response, server_response.clone())
9843                        {
9844                            sleep(d);
9845                            continue;
9846                        }
9847
9848                        dlg.finished(false);
9849
9850                        return match server_response {
9851                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
9852                            None => Err(client::Error::Failure(restored_response)),
9853                        };
9854                    }
9855                    let result_value = res;
9856
9857                    dlg.finished(true);
9858                    return Ok(result_value);
9859                }
9860            }
9861        }
9862    }
9863
9864    /// The ID of the file.
9865    ///
9866    /// Sets the *file id* path property to the given value.
9867    ///
9868    /// Even though the property as already been set when instantiating this call,
9869    /// we provide this method for API completeness.
9870    pub fn file_id(mut self, new_value: &str) -> FileExportCall<'a, S> {
9871        self._file_id = new_value.to_string();
9872        self
9873    }
9874    /// The MIME type of the format requested for this export.
9875    ///
9876    /// Sets the *mime type* query property to the given value.
9877    ///
9878    /// Even though the property as already been set when instantiating this call,
9879    /// we provide this method for API completeness.
9880    pub fn mime_type(mut self, new_value: &str) -> FileExportCall<'a, S> {
9881        self._mime_type = new_value.to_string();
9882        self
9883    }
9884    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9885    /// while executing the actual API request.
9886    ///
9887    /// It should be used to handle progress information, and to implement a certain level of resilience.
9888    ///
9889    /// Sets the *delegate* property to the given value.
9890    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileExportCall<'a, S> {
9891        self._delegate = Some(new_value);
9892        self
9893    }
9894
9895    /// Set any additional parameter of the query string used in the request.
9896    /// It should be used to set parameters which are not yet available through their own
9897    /// setters.
9898    ///
9899    /// Please note that this method must not be used to set any of the known parameters
9900    /// which have their own setter method. If done anyway, the request will fail.
9901    ///
9902    /// # Additional Parameters
9903    ///
9904    /// * *alt* (query-string) - Data format for the response.
9905    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9906    /// * *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.
9907    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9908    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9909    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9910    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9911    pub fn param<T>(mut self, name: T, value: T) -> FileExportCall<'a, S>
9912    where
9913        T: AsRef<str>,
9914    {
9915        self._additional_params
9916            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9917        self
9918    }
9919
9920    /// Identifies the authorization scope for the method you are building.
9921    ///
9922    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
9923    /// `Scope::Readonly`.
9924    ///
9925    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9926    /// tokens for more than one scope.
9927    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
9928    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
9929    /// function for details).
9930    ///
9931    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9932    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9933    /// sufficient, a read-write scope will do as well.
9934    pub fn add_scope<T, St>(mut self, scope: T) -> FileExportCall<'a, S>
9935    where
9936        T: Into<Option<St>>,
9937        St: AsRef<str>,
9938    {
9939        match scope.into() {
9940            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
9941            None => None,
9942        };
9943        self
9944    }
9945}
9946
9947/// Generates a set of file IDs which can be provided in create or copy requests.
9948///
9949/// A builder for the *generateIds* method supported by a *file* resource.
9950/// It is not used directly, but through a `FileMethods` instance.
9951///
9952/// # Example
9953///
9954/// Instantiate a resource method builder
9955///
9956/// ```test_harness,no_run
9957/// # extern crate hyper;
9958/// # extern crate hyper_rustls;
9959/// # extern crate google_drive3 as drive3;
9960/// # async fn dox() {
9961/// # use std::default::Default;
9962/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
9963///
9964/// # let secret: oauth2::ApplicationSecret = Default::default();
9965/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
9966/// #         secret,
9967/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9968/// #     ).build().await.unwrap();
9969/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
9970/// // You can configure optional parameters by calling the respective setters at will, and
9971/// // execute the final call using `doit()`.
9972/// // Values shown here are possibly random and not representative !
9973/// let result = hub.files().generate_ids()
9974///              .type_("Lorem")
9975///              .space("accusam")
9976///              .count(-47)
9977///              .doit().await;
9978/// # }
9979/// ```
9980pub struct FileGenerateIdCall<'a, S>
9981where
9982    S: 'a,
9983{
9984    hub: &'a DriveHub<S>,
9985    _type_: Option<String>,
9986    _space: Option<String>,
9987    _count: Option<i32>,
9988    _delegate: Option<&'a mut dyn client::Delegate>,
9989    _additional_params: HashMap<String, String>,
9990    _scopes: BTreeMap<String, ()>,
9991}
9992
9993impl<'a, S> client::CallBuilder for FileGenerateIdCall<'a, S> {}
9994
9995impl<'a, S> FileGenerateIdCall<'a, S>
9996where
9997    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
9998    S::Response:
9999        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
10000    S::Future: Send + Unpin + 'static,
10001    S::Error: Into<Box<dyn StdError + Send + Sync>>,
10002{
10003    /// Perform the operation you have build so far.
10004    pub async fn doit(
10005        mut self,
10006    ) -> client::Result<(hyper::Response<hyper::body::Body>, GeneratedIds)> {
10007        use client::ToParts;
10008        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10009        use std::io::{Read, Seek};
10010        let mut dd = client::DefaultDelegate;
10011        let mut dlg: &mut dyn client::Delegate = match self._delegate {
10012            Some(d) => d,
10013            None => &mut dd,
10014        };
10015        dlg.begin(client::MethodInfo {
10016            id: "drive.files.generateIds",
10017            http_method: hyper::Method::GET,
10018        });
10019        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
10020        if let Some(value) = self._type_ {
10021            params.push(("type", value.to_string()));
10022        }
10023        if let Some(value) = self._space {
10024            params.push(("space", value.to_string()));
10025        }
10026        if let Some(value) = self._count {
10027            params.push(("count", value.to_string()));
10028        }
10029        for &field in ["alt", "type", "space", "count"].iter() {
10030            if self._additional_params.contains_key(field) {
10031                dlg.finished(false);
10032                return Err(client::Error::FieldClash(field));
10033            }
10034        }
10035        for (name, value) in self._additional_params.iter() {
10036            params.push((&name, value.clone()));
10037        }
10038
10039        params.push(("alt", "json".to_string()));
10040
10041        let mut url = self.hub._base_url.clone() + "files/generateIds";
10042        if self._scopes.len() == 0 {
10043            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
10044        }
10045
10046        let url = url::Url::parse_with_params(&url, params).unwrap();
10047
10048        loop {
10049            let token = match self
10050                .hub
10051                .auth
10052                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
10053                .await
10054            {
10055                Ok(token) => token.clone(),
10056                Err(err) => match dlg.token(&err) {
10057                    Some(token) => token,
10058                    None => {
10059                        dlg.finished(false);
10060                        return Err(client::Error::MissingToken(err));
10061                    }
10062                },
10063            };
10064            let mut req_result = {
10065                let client = &self.hub.client;
10066                dlg.pre_request();
10067                let mut req_builder = hyper::Request::builder()
10068                    .method(hyper::Method::GET)
10069                    .uri(url.clone().into_string())
10070                    .header(USER_AGENT, self.hub._user_agent.clone())
10071                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
10072
10073                let request = req_builder.body(hyper::body::Body::empty());
10074
10075                client.request(request.unwrap()).await
10076            };
10077
10078            match req_result {
10079                Err(err) => {
10080                    if let client::Retry::After(d) = dlg.http_error(&err) {
10081                        sleep(d);
10082                        continue;
10083                    }
10084                    dlg.finished(false);
10085                    return Err(client::Error::HttpError(err));
10086                }
10087                Ok(mut res) => {
10088                    if !res.status().is_success() {
10089                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10090                        let (parts, _) = res.into_parts();
10091                        let body = hyper::Body::from(res_body_string.clone());
10092                        let restored_response = hyper::Response::from_parts(parts, body);
10093
10094                        let server_response =
10095                            json::from_str::<serde_json::Value>(&res_body_string).ok();
10096
10097                        if let client::Retry::After(d) =
10098                            dlg.http_failure(&restored_response, server_response.clone())
10099                        {
10100                            sleep(d);
10101                            continue;
10102                        }
10103
10104                        dlg.finished(false);
10105
10106                        return match server_response {
10107                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
10108                            None => Err(client::Error::Failure(restored_response)),
10109                        };
10110                    }
10111                    let result_value = {
10112                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10113
10114                        match json::from_str(&res_body_string) {
10115                            Ok(decoded) => (res, decoded),
10116                            Err(err) => {
10117                                dlg.response_json_decode_error(&res_body_string, &err);
10118                                return Err(client::Error::JsonDecodeError(res_body_string, err));
10119                            }
10120                        }
10121                    };
10122
10123                    dlg.finished(true);
10124                    return Ok(result_value);
10125                }
10126            }
10127        }
10128    }
10129
10130    /// The type of items which the IDs can be used for. Supported values are 'files' and 'shortcuts'. Note that 'shortcuts' are only supported in the drive 'space'. (Default: 'files')
10131    ///
10132    /// Sets the *type* query property to the given value.
10133    pub fn type_(mut self, new_value: &str) -> FileGenerateIdCall<'a, S> {
10134        self._type_ = Some(new_value.to_string());
10135        self
10136    }
10137    /// The space in which the IDs can be used to create new files. Supported values are 'drive' and 'appDataFolder'. (Default: 'drive')
10138    ///
10139    /// Sets the *space* query property to the given value.
10140    pub fn space(mut self, new_value: &str) -> FileGenerateIdCall<'a, S> {
10141        self._space = Some(new_value.to_string());
10142        self
10143    }
10144    /// The number of IDs to return.
10145    ///
10146    /// Sets the *count* query property to the given value.
10147    pub fn count(mut self, new_value: i32) -> FileGenerateIdCall<'a, S> {
10148        self._count = Some(new_value);
10149        self
10150    }
10151    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10152    /// while executing the actual API request.
10153    ///
10154    /// It should be used to handle progress information, and to implement a certain level of resilience.
10155    ///
10156    /// Sets the *delegate* property to the given value.
10157    pub fn delegate(
10158        mut self,
10159        new_value: &'a mut dyn client::Delegate,
10160    ) -> FileGenerateIdCall<'a, S> {
10161        self._delegate = Some(new_value);
10162        self
10163    }
10164
10165    /// Set any additional parameter of the query string used in the request.
10166    /// It should be used to set parameters which are not yet available through their own
10167    /// setters.
10168    ///
10169    /// Please note that this method must not be used to set any of the known parameters
10170    /// which have their own setter method. If done anyway, the request will fail.
10171    ///
10172    /// # Additional Parameters
10173    ///
10174    /// * *alt* (query-string) - Data format for the response.
10175    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10176    /// * *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.
10177    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10178    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10179    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10180    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10181    pub fn param<T>(mut self, name: T, value: T) -> FileGenerateIdCall<'a, S>
10182    where
10183        T: AsRef<str>,
10184    {
10185        self._additional_params
10186            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10187        self
10188    }
10189
10190    /// Identifies the authorization scope for the method you are building.
10191    ///
10192    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10193    /// `Scope::Full`.
10194    ///
10195    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10196    /// tokens for more than one scope.
10197    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10198    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10199    /// function for details).
10200    ///
10201    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10202    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10203    /// sufficient, a read-write scope will do as well.
10204    pub fn add_scope<T, St>(mut self, scope: T) -> FileGenerateIdCall<'a, S>
10205    where
10206        T: Into<Option<St>>,
10207        St: AsRef<str>,
10208    {
10209        match scope.into() {
10210            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10211            None => None,
10212        };
10213        self
10214    }
10215}
10216
10217/// Gets a file's metadata or content by ID.
10218///
10219/// This method supports **media download**. To enable it, adjust the builder like this:
10220/// `.param("alt", "media")`.
10221/// Please note that due to missing multi-part support on the server side, you will only receive the media,
10222/// but not the `File` structure that you would usually get. The latter will be a default value.
10223///
10224/// A builder for the *get* method supported by a *file* resource.
10225/// It is not used directly, but through a `FileMethods` instance.
10226///
10227/// # Example
10228///
10229/// Instantiate a resource method builder
10230///
10231/// ```test_harness,no_run
10232/// # extern crate hyper;
10233/// # extern crate hyper_rustls;
10234/// # extern crate google_drive3 as drive3;
10235/// # async fn dox() {
10236/// # use std::default::Default;
10237/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
10238///
10239/// # let secret: oauth2::ApplicationSecret = Default::default();
10240/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
10241/// #         secret,
10242/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10243/// #     ).build().await.unwrap();
10244/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
10245/// // You can configure optional parameters by calling the respective setters at will, and
10246/// // execute the final call using `doit()`.
10247/// // Values shown here are possibly random and not representative !
10248/// let result = hub.files().get("fileId")
10249///              .supports_team_drives(true)
10250///              .supports_all_drives(false)
10251///              .include_permissions_for_view("accusam")
10252///              .acknowledge_abuse(true)
10253///              .doit().await;
10254/// # }
10255/// ```
10256pub struct FileGetCall<'a, S>
10257where
10258    S: 'a,
10259{
10260    hub: &'a DriveHub<S>,
10261    _file_id: String,
10262    _supports_team_drives: Option<bool>,
10263    _supports_all_drives: Option<bool>,
10264    _include_permissions_for_view: Option<String>,
10265    _acknowledge_abuse: Option<bool>,
10266    _delegate: Option<&'a mut dyn client::Delegate>,
10267    _additional_params: HashMap<String, String>,
10268    _scopes: BTreeMap<String, ()>,
10269    _range: Option<String>,
10270}
10271
10272impl<'a, S> client::CallBuilder for FileGetCall<'a, S> {}
10273
10274impl<'a, S> FileGetCall<'a, S>
10275where
10276    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
10277    S::Response:
10278        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
10279    S::Future: Send + Unpin + 'static,
10280    S::Error: Into<Box<dyn StdError + Send + Sync>>,
10281{
10282    /// Perform the operation you have build so far.
10283    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, File)> {
10284        use client::ToParts;
10285        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10286        use std::io::{Read, Seek};
10287        let mut dd = client::DefaultDelegate;
10288        let mut dlg: &mut dyn client::Delegate = match self._delegate {
10289            Some(d) => d,
10290            None => &mut dd,
10291        };
10292        dlg.begin(client::MethodInfo {
10293            id: "drive.files.get",
10294            http_method: hyper::Method::GET,
10295        });
10296        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
10297        params.push(("fileId", self._file_id.to_string()));
10298        if let Some(value) = self._supports_team_drives {
10299            params.push(("supportsTeamDrives", value.to_string()));
10300        }
10301        if let Some(value) = self._supports_all_drives {
10302            params.push(("supportsAllDrives", value.to_string()));
10303        }
10304        if let Some(value) = self._include_permissions_for_view {
10305            params.push(("includePermissionsForView", value.to_string()));
10306        }
10307        if let Some(value) = self._acknowledge_abuse {
10308            params.push(("acknowledgeAbuse", value.to_string()));
10309        }
10310        for &field in [
10311            "fileId",
10312            "supportsTeamDrives",
10313            "supportsAllDrives",
10314            "includePermissionsForView",
10315            "acknowledgeAbuse",
10316        ]
10317        .iter()
10318        {
10319            if self._additional_params.contains_key(field) {
10320                dlg.finished(false);
10321                return Err(client::Error::FieldClash(field));
10322            }
10323        }
10324        for (name, value) in self._additional_params.iter() {
10325            params.push((&name, value.clone()));
10326        }
10327
10328        let (json_field_missing, enable_resource_parsing) = {
10329            let mut enable = true;
10330            let mut field_present = true;
10331            for &(name, ref value) in params.iter() {
10332                if name == "alt" {
10333                    field_present = false;
10334                    if <String as AsRef<str>>::as_ref(&value) != "json" {
10335                        enable = false;
10336                    }
10337                    break;
10338                }
10339            }
10340            (field_present, enable)
10341        };
10342        if json_field_missing {
10343            params.push(("alt", "json".to_string()));
10344        }
10345
10346        let mut url = self.hub._base_url.clone() + "files/{fileId}";
10347        if self._scopes.len() == 0 {
10348            self._scopes
10349                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
10350        }
10351
10352        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
10353            let mut replace_with: Option<&str> = None;
10354            for &(name, ref value) in params.iter() {
10355                if name == param_name {
10356                    replace_with = Some(value);
10357                    break;
10358                }
10359            }
10360            url = url.replace(
10361                find_this,
10362                replace_with.expect("to find substitution value in params"),
10363            );
10364        }
10365        {
10366            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
10367            for param_name in ["fileId"].iter() {
10368                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
10369                    indices_for_removal.push(index);
10370                }
10371            }
10372            for &index in indices_for_removal.iter() {
10373                params.remove(index);
10374            }
10375        }
10376
10377        let url = url::Url::parse_with_params(&url, params).unwrap();
10378
10379        loop {
10380            let token = match self
10381                .hub
10382                .auth
10383                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
10384                .await
10385            {
10386                Ok(token) => token.clone(),
10387                Err(err) => match dlg.token(&err) {
10388                    Some(token) => token,
10389                    None => {
10390                        dlg.finished(false);
10391                        return Err(client::Error::MissingToken(err));
10392                    }
10393                },
10394            };
10395            let mut req_result = {
10396                let client = &self.hub.client;
10397                dlg.pre_request();
10398                let mut req_builder = hyper::Request::builder()
10399                    .method(hyper::Method::GET)
10400                    .uri(url.clone().into_string())
10401                    .header(USER_AGENT, self.hub._user_agent.clone())
10402                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
10403                if let Some(range) = &self._range {
10404                    req_builder = req_builder.header("Range", range);
10405                }
10406
10407                let request = req_builder.body(hyper::body::Body::empty());
10408
10409                client.request(request.unwrap()).await
10410            };
10411
10412            match req_result {
10413                Err(err) => {
10414                    if let client::Retry::After(d) = dlg.http_error(&err) {
10415                        sleep(d);
10416                        continue;
10417                    }
10418                    dlg.finished(false);
10419                    return Err(client::Error::HttpError(err));
10420                }
10421                Ok(mut res) => {
10422                    if !res.status().is_success() {
10423                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10424                        let (parts, _) = res.into_parts();
10425                        let body = hyper::Body::from(res_body_string.clone());
10426                        let restored_response = hyper::Response::from_parts(parts, body);
10427
10428                        let server_response =
10429                            json::from_str::<serde_json::Value>(&res_body_string).ok();
10430
10431                        if let client::Retry::After(d) =
10432                            dlg.http_failure(&restored_response, server_response.clone())
10433                        {
10434                            sleep(d);
10435                            continue;
10436                        }
10437
10438                        dlg.finished(false);
10439
10440                        return match server_response {
10441                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
10442                            None => Err(client::Error::Failure(restored_response)),
10443                        };
10444                    }
10445                    let result_value = if enable_resource_parsing {
10446                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10447
10448                        match json::from_str(&res_body_string) {
10449                            Ok(decoded) => (res, decoded),
10450                            Err(err) => {
10451                                dlg.response_json_decode_error(&res_body_string, &err);
10452                                return Err(client::Error::JsonDecodeError(res_body_string, err));
10453                            }
10454                        }
10455                    } else {
10456                        (res, Default::default())
10457                    };
10458
10459                    dlg.finished(true);
10460                    return Ok(result_value);
10461                }
10462            }
10463        }
10464    }
10465
10466    /// The ID of the file.
10467    ///
10468    /// Sets the *file id* path property to the given value.
10469    ///
10470    /// Even though the property as already been set when instantiating this call,
10471    /// we provide this method for API completeness.
10472    pub fn file_id(mut self, new_value: &str) -> FileGetCall<'a, S> {
10473        self._file_id = new_value.to_string();
10474        self
10475    }
10476    /// Deprecated use supportsAllDrives instead.
10477    ///
10478    /// Sets the *supports team drives* query property to the given value.
10479    pub fn supports_team_drives(mut self, new_value: bool) -> FileGetCall<'a, S> {
10480        self._supports_team_drives = Some(new_value);
10481        self
10482    }
10483    /// Whether the requesting application supports both My Drives and shared drives.
10484    ///
10485    /// Sets the *supports all drives* query property to the given value.
10486    pub fn supports_all_drives(mut self, new_value: bool) -> FileGetCall<'a, S> {
10487        self._supports_all_drives = Some(new_value);
10488        self
10489    }
10490    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
10491    ///
10492    /// Sets the *include permissions for view* query property to the given value.
10493    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileGetCall<'a, S> {
10494        self._include_permissions_for_view = Some(new_value.to_string());
10495        self
10496    }
10497    /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.
10498    ///
10499    /// Sets the *acknowledge abuse* query property to the given value.
10500    pub fn acknowledge_abuse(mut self, new_value: bool) -> FileGetCall<'a, S> {
10501        self._acknowledge_abuse = Some(new_value);
10502        self
10503    }
10504    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10505    /// while executing the actual API request.
10506    ///
10507    /// It should be used to handle progress information, and to implement a certain level of resilience.
10508    ///
10509    /// Sets the *delegate* property to the given value.
10510    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileGetCall<'a, S> {
10511        self._delegate = Some(new_value);
10512        self
10513    }
10514
10515    /// Set any additional parameter of the query string used in the request.
10516    /// It should be used to set parameters which are not yet available through their own
10517    /// setters.
10518    ///
10519    /// Please note that this method must not be used to set any of the known parameters
10520    /// which have their own setter method. If done anyway, the request will fail.
10521    ///
10522    /// # Additional Parameters
10523    ///
10524    /// * *alt* (query-string) - Data format for the response.
10525    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10526    /// * *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.
10527    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10529    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10530    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10531    pub fn param<T>(mut self, name: T, value: T) -> FileGetCall<'a, S>
10532    where
10533        T: AsRef<str>,
10534    {
10535        self._additional_params
10536            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10537        self
10538    }
10539
10540    /// Identifies the authorization scope for the method you are building.
10541    ///
10542    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10543    /// `Scope::MetadataReadonly`.
10544    ///
10545    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10546    /// tokens for more than one scope.
10547    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10548    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10549    /// function for details).
10550    ///
10551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10553    /// sufficient, a read-write scope will do as well.
10554    pub fn add_scope<T, St>(mut self, scope: T) -> FileGetCall<'a, S>
10555    where
10556        T: Into<Option<St>>,
10557        St: AsRef<str>,
10558    {
10559        match scope.into() {
10560            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10561            None => None,
10562        };
10563        self
10564    }
10565
10566    pub fn range(mut self, new_value: Option<String>) -> FileGetCall<'a, S> {
10567        self._range = new_value;
10568        self
10569    }
10570}
10571
10572/// Lists or searches files.
10573///
10574/// A builder for the *list* method supported by a *file* resource.
10575/// It is not used directly, but through a `FileMethods` instance.
10576///
10577/// # Example
10578///
10579/// Instantiate a resource method builder
10580///
10581/// ```test_harness,no_run
10582/// # extern crate hyper;
10583/// # extern crate hyper_rustls;
10584/// # extern crate google_drive3 as drive3;
10585/// # async fn dox() {
10586/// # use std::default::Default;
10587/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
10588///
10589/// # let secret: oauth2::ApplicationSecret = Default::default();
10590/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
10591/// #         secret,
10592/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10593/// #     ).build().await.unwrap();
10594/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
10595/// // You can configure optional parameters by calling the respective setters at will, and
10596/// // execute the final call using `doit()`.
10597/// // Values shown here are possibly random and not representative !
10598/// let result = hub.files().list()
10599///              .team_drive_id("Lorem")
10600///              .supports_team_drives(false)
10601///              .supports_all_drives(true)
10602///              .spaces("erat")
10603///              .q("sea")
10604///              .page_token("nonumy")
10605///              .page_size(-22)
10606///              .order_by("gubergren")
10607///              .include_team_drive_items(true)
10608///              .include_permissions_for_view("consetetur")
10609///              .include_items_from_all_drives(false)
10610///              .drive_id("aliquyam")
10611///              .corpus("eos")
10612///              .corpora("At")
10613///              .doit().await;
10614/// # }
10615/// ```
10616pub struct FileListCall<'a, S>
10617where
10618    S: 'a,
10619{
10620    hub: &'a DriveHub<S>,
10621    _team_drive_id: Option<String>,
10622    _supports_team_drives: Option<bool>,
10623    _supports_all_drives: Option<bool>,
10624    _spaces: Option<String>,
10625    _q: Option<String>,
10626    _page_token: Option<String>,
10627    _page_size: Option<i32>,
10628    _order_by: Option<String>,
10629    _include_team_drive_items: Option<bool>,
10630    _include_permissions_for_view: Option<String>,
10631    _include_items_from_all_drives: Option<bool>,
10632    _drive_id: Option<String>,
10633    _corpus: Option<String>,
10634    _corpora: Option<String>,
10635    _delegate: Option<&'a mut dyn client::Delegate>,
10636    _additional_params: HashMap<String, String>,
10637    _scopes: BTreeMap<String, ()>,
10638}
10639
10640impl<'a, S> client::CallBuilder for FileListCall<'a, S> {}
10641
10642impl<'a, S> FileListCall<'a, S>
10643where
10644    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
10645    S::Response:
10646        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
10647    S::Future: Send + Unpin + 'static,
10648    S::Error: Into<Box<dyn StdError + Send + Sync>>,
10649{
10650    /// Perform the operation you have build so far.
10651    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, FileList)> {
10652        use client::ToParts;
10653        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10654        use std::io::{Read, Seek};
10655        let mut dd = client::DefaultDelegate;
10656        let mut dlg: &mut dyn client::Delegate = match self._delegate {
10657            Some(d) => d,
10658            None => &mut dd,
10659        };
10660        dlg.begin(client::MethodInfo {
10661            id: "drive.files.list",
10662            http_method: hyper::Method::GET,
10663        });
10664        let mut params: Vec<(&str, String)> =
10665            Vec::with_capacity(16 + self._additional_params.len());
10666        if let Some(value) = self._team_drive_id {
10667            params.push(("teamDriveId", value.to_string()));
10668        }
10669        if let Some(value) = self._supports_team_drives {
10670            params.push(("supportsTeamDrives", value.to_string()));
10671        }
10672        if let Some(value) = self._supports_all_drives {
10673            params.push(("supportsAllDrives", value.to_string()));
10674        }
10675        if let Some(value) = self._spaces {
10676            params.push(("spaces", value.to_string()));
10677        }
10678        if let Some(value) = self._q {
10679            params.push(("q", value.to_string()));
10680        }
10681        if let Some(value) = self._page_token {
10682            params.push(("pageToken", value.to_string()));
10683        }
10684        if let Some(value) = self._page_size {
10685            params.push(("pageSize", value.to_string()));
10686        }
10687        if let Some(value) = self._order_by {
10688            params.push(("orderBy", value.to_string()));
10689        }
10690        if let Some(value) = self._include_team_drive_items {
10691            params.push(("includeTeamDriveItems", value.to_string()));
10692        }
10693        if let Some(value) = self._include_permissions_for_view {
10694            params.push(("includePermissionsForView", value.to_string()));
10695        }
10696        if let Some(value) = self._include_items_from_all_drives {
10697            params.push(("includeItemsFromAllDrives", value.to_string()));
10698        }
10699        if let Some(value) = self._drive_id {
10700            params.push(("driveId", value.to_string()));
10701        }
10702        if let Some(value) = self._corpus {
10703            params.push(("corpus", value.to_string()));
10704        }
10705        if let Some(value) = self._corpora {
10706            params.push(("corpora", value.to_string()));
10707        }
10708        for &field in [
10709            "alt",
10710            "teamDriveId",
10711            "supportsTeamDrives",
10712            "supportsAllDrives",
10713            "spaces",
10714            "q",
10715            "pageToken",
10716            "pageSize",
10717            "orderBy",
10718            "includeTeamDriveItems",
10719            "includePermissionsForView",
10720            "includeItemsFromAllDrives",
10721            "driveId",
10722            "corpus",
10723            "corpora",
10724        ]
10725        .iter()
10726        {
10727            if self._additional_params.contains_key(field) {
10728                dlg.finished(false);
10729                return Err(client::Error::FieldClash(field));
10730            }
10731        }
10732        for (name, value) in self._additional_params.iter() {
10733            params.push((&name, value.clone()));
10734        }
10735
10736        params.push(("alt", "json".to_string()));
10737
10738        let mut url = self.hub._base_url.clone() + "files";
10739        if self._scopes.len() == 0 {
10740            self._scopes
10741                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
10742        }
10743
10744        let url = url::Url::parse_with_params(&url, params).unwrap();
10745
10746        loop {
10747            let token = match self
10748                .hub
10749                .auth
10750                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
10751                .await
10752            {
10753                Ok(token) => token.clone(),
10754                Err(err) => match dlg.token(&err) {
10755                    Some(token) => token,
10756                    None => {
10757                        dlg.finished(false);
10758                        return Err(client::Error::MissingToken(err));
10759                    }
10760                },
10761            };
10762            let mut req_result = {
10763                let client = &self.hub.client;
10764                dlg.pre_request();
10765                let mut req_builder = hyper::Request::builder()
10766                    .method(hyper::Method::GET)
10767                    .uri(url.clone().into_string())
10768                    .header(USER_AGENT, self.hub._user_agent.clone())
10769                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
10770
10771                let request = req_builder.body(hyper::body::Body::empty());
10772
10773                client.request(request.unwrap()).await
10774            };
10775
10776            match req_result {
10777                Err(err) => {
10778                    if let client::Retry::After(d) = dlg.http_error(&err) {
10779                        sleep(d);
10780                        continue;
10781                    }
10782                    dlg.finished(false);
10783                    return Err(client::Error::HttpError(err));
10784                }
10785                Ok(mut res) => {
10786                    if !res.status().is_success() {
10787                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10788                        let (parts, _) = res.into_parts();
10789                        let body = hyper::Body::from(res_body_string.clone());
10790                        let restored_response = hyper::Response::from_parts(parts, body);
10791
10792                        let server_response =
10793                            json::from_str::<serde_json::Value>(&res_body_string).ok();
10794
10795                        if let client::Retry::After(d) =
10796                            dlg.http_failure(&restored_response, server_response.clone())
10797                        {
10798                            sleep(d);
10799                            continue;
10800                        }
10801
10802                        dlg.finished(false);
10803
10804                        return match server_response {
10805                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
10806                            None => Err(client::Error::Failure(restored_response)),
10807                        };
10808                    }
10809                    let result_value = {
10810                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
10811
10812                        match json::from_str(&res_body_string) {
10813                            Ok(decoded) => (res, decoded),
10814                            Err(err) => {
10815                                dlg.response_json_decode_error(&res_body_string, &err);
10816                                return Err(client::Error::JsonDecodeError(res_body_string, err));
10817                            }
10818                        }
10819                    };
10820
10821                    dlg.finished(true);
10822                    return Ok(result_value);
10823                }
10824            }
10825        }
10826    }
10827
10828    /// Deprecated use driveId instead.
10829    ///
10830    /// Sets the *team drive id* query property to the given value.
10831    pub fn team_drive_id(mut self, new_value: &str) -> FileListCall<'a, S> {
10832        self._team_drive_id = Some(new_value.to_string());
10833        self
10834    }
10835    /// Deprecated use supportsAllDrives instead.
10836    ///
10837    /// Sets the *supports team drives* query property to the given value.
10838    pub fn supports_team_drives(mut self, new_value: bool) -> FileListCall<'a, S> {
10839        self._supports_team_drives = Some(new_value);
10840        self
10841    }
10842    /// Whether the requesting application supports both My Drives and shared drives.
10843    ///
10844    /// Sets the *supports all drives* query property to the given value.
10845    pub fn supports_all_drives(mut self, new_value: bool) -> FileListCall<'a, S> {
10846        self._supports_all_drives = Some(new_value);
10847        self
10848    }
10849    /// A comma-separated list of spaces to query within the corpus. Supported values are 'drive' and 'appDataFolder'.
10850    ///
10851    /// Sets the *spaces* query property to the given value.
10852    pub fn spaces(mut self, new_value: &str) -> FileListCall<'a, S> {
10853        self._spaces = Some(new_value.to_string());
10854        self
10855    }
10856    /// A query for filtering the file results. See the "Search for Files" guide for supported syntax.
10857    ///
10858    /// Sets the *q* query property to the given value.
10859    pub fn q(mut self, new_value: &str) -> FileListCall<'a, S> {
10860        self._q = Some(new_value.to_string());
10861        self
10862    }
10863    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
10864    ///
10865    /// Sets the *page token* query property to the given value.
10866    pub fn page_token(mut self, new_value: &str) -> FileListCall<'a, S> {
10867        self._page_token = Some(new_value.to_string());
10868        self
10869    }
10870    /// The maximum number of files to return per page. Partial or empty result pages are possible even before the end of the files list has been reached.
10871    ///
10872    /// Sets the *page size* query property to the given value.
10873    pub fn page_size(mut self, new_value: i32) -> FileListCall<'a, S> {
10874        self._page_size = Some(new_value);
10875        self
10876    }
10877    /// A comma-separated list of sort keys. Valid keys are 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and 'viewedByMeTime'. Each key sorts ascending by default, but may be reversed with the 'desc' modifier. Example usage: ?orderBy=folder,modifiedTime desc,name. Please note that there is a current limitation for users with approximately one million files in which the requested sort order is ignored.
10878    ///
10879    /// Sets the *order by* query property to the given value.
10880    pub fn order_by(mut self, new_value: &str) -> FileListCall<'a, S> {
10881        self._order_by = Some(new_value.to_string());
10882        self
10883    }
10884    /// Deprecated use includeItemsFromAllDrives instead.
10885    ///
10886    /// Sets the *include team drive items* query property to the given value.
10887    pub fn include_team_drive_items(mut self, new_value: bool) -> FileListCall<'a, S> {
10888        self._include_team_drive_items = Some(new_value);
10889        self
10890    }
10891    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
10892    ///
10893    /// Sets the *include permissions for view* query property to the given value.
10894    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileListCall<'a, S> {
10895        self._include_permissions_for_view = Some(new_value.to_string());
10896        self
10897    }
10898    /// Whether both My Drive and shared drive items should be included in results.
10899    ///
10900    /// Sets the *include items from all drives* query property to the given value.
10901    pub fn include_items_from_all_drives(mut self, new_value: bool) -> FileListCall<'a, S> {
10902        self._include_items_from_all_drives = Some(new_value);
10903        self
10904    }
10905    /// ID of the shared drive to search.
10906    ///
10907    /// Sets the *drive id* query property to the given value.
10908    pub fn drive_id(mut self, new_value: &str) -> FileListCall<'a, S> {
10909        self._drive_id = Some(new_value.to_string());
10910        self
10911    }
10912    /// The source of files to list. Deprecated: use 'corpora' instead.
10913    ///
10914    /// Sets the *corpus* query property to the given value.
10915    pub fn corpus(mut self, new_value: &str) -> FileListCall<'a, S> {
10916        self._corpus = Some(new_value.to_string());
10917        self
10918    }
10919    /// Groupings of files to which the query applies. Supported groupings are: 'user' (files created by, opened by, or shared directly with the user), 'drive' (files in the specified shared drive as indicated by the 'driveId'), 'domain' (files shared to the user's domain), and 'allDrives' (A combination of 'user' and 'drive' for all drives where the user is a member). When able, use 'user' or 'drive', instead of 'allDrives', for efficiency.
10920    ///
10921    /// Sets the *corpora* query property to the given value.
10922    pub fn corpora(mut self, new_value: &str) -> FileListCall<'a, S> {
10923        self._corpora = Some(new_value.to_string());
10924        self
10925    }
10926    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10927    /// while executing the actual API request.
10928    ///
10929    /// It should be used to handle progress information, and to implement a certain level of resilience.
10930    ///
10931    /// Sets the *delegate* property to the given value.
10932    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileListCall<'a, S> {
10933        self._delegate = Some(new_value);
10934        self
10935    }
10936
10937    /// Set any additional parameter of the query string used in the request.
10938    /// It should be used to set parameters which are not yet available through their own
10939    /// setters.
10940    ///
10941    /// Please note that this method must not be used to set any of the known parameters
10942    /// which have their own setter method. If done anyway, the request will fail.
10943    ///
10944    /// # Additional Parameters
10945    ///
10946    /// * *alt* (query-string) - Data format for the response.
10947    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10948    /// * *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.
10949    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10950    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10951    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10952    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10953    pub fn param<T>(mut self, name: T, value: T) -> FileListCall<'a, S>
10954    where
10955        T: AsRef<str>,
10956    {
10957        self._additional_params
10958            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10959        self
10960    }
10961
10962    /// Identifies the authorization scope for the method you are building.
10963    ///
10964    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
10965    /// `Scope::MetadataReadonly`.
10966    ///
10967    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10968    /// tokens for more than one scope.
10969    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
10970    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
10971    /// function for details).
10972    ///
10973    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10974    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10975    /// sufficient, a read-write scope will do as well.
10976    pub fn add_scope<T, St>(mut self, scope: T) -> FileListCall<'a, S>
10977    where
10978        T: Into<Option<St>>,
10979        St: AsRef<str>,
10980    {
10981        match scope.into() {
10982            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
10983            None => None,
10984        };
10985        self
10986    }
10987}
10988
10989/// Updates a file's metadata and/or content. When calling this method, only populate fields in the request that you want to modify. When updating fields, some fields might change automatically, such as modifiedDate. This method supports patch semantics.
10990///
10991/// A builder for the *update* method supported by a *file* resource.
10992/// It is not used directly, but through a `FileMethods` instance.
10993///
10994/// # Example
10995///
10996/// Instantiate a resource method builder
10997///
10998/// ```test_harness,no_run
10999/// # extern crate hyper;
11000/// # extern crate hyper_rustls;
11001/// # extern crate google_drive3 as drive3;
11002/// use drive3::api::File;
11003/// use std::fs;
11004/// # async fn dox() {
11005/// # use std::default::Default;
11006/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
11007///
11008/// # let secret: oauth2::ApplicationSecret = Default::default();
11009/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
11010/// #         secret,
11011/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11012/// #     ).build().await.unwrap();
11013/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
11014/// // As the method needs a request, you would usually fill it with the desired information
11015/// // into the respective structure. Some of the parts shown here might not be applicable !
11016/// // Values shown here are possibly random and not representative !
11017/// let mut req = File::default();
11018///
11019/// // You can configure optional parameters by calling the respective setters at will, and
11020/// // execute the final call using `upload(...)`.
11021/// // Values shown here are possibly random and not representative !
11022/// let result = hub.files().update(req, "fileId")
11023///              .use_content_as_indexable_text(true)
11024///              .supports_team_drives(true)
11025///              .supports_all_drives(true)
11026///              .remove_parents("amet.")
11027///              .ocr_language("ipsum")
11028///              .keep_revision_forever(true)
11029///              .include_permissions_for_view("accusam")
11030///              .enforce_single_parent(true)
11031///              .add_parents("sadipscing")
11032///              .upload(fs::File::open("file.ext").unwrap(), "application/octet-stream".parse().unwrap()).await;
11033/// # }
11034/// ```
11035pub struct FileUpdateCall<'a, S>
11036where
11037    S: 'a,
11038{
11039    hub: &'a DriveHub<S>,
11040    _request: File,
11041    _file_id: String,
11042    _use_content_as_indexable_text: Option<bool>,
11043    _supports_team_drives: Option<bool>,
11044    _supports_all_drives: Option<bool>,
11045    _remove_parents: Option<String>,
11046    _ocr_language: Option<String>,
11047    _keep_revision_forever: Option<bool>,
11048    _include_permissions_for_view: Option<String>,
11049    _enforce_single_parent: Option<bool>,
11050    _add_parents: Option<String>,
11051    _delegate: Option<&'a mut dyn client::Delegate>,
11052    _additional_params: HashMap<String, String>,
11053    _scopes: BTreeMap<String, ()>,
11054}
11055
11056impl<'a, S> client::CallBuilder for FileUpdateCall<'a, S> {}
11057
11058impl<'a, S> FileUpdateCall<'a, S>
11059where
11060    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
11061    S::Response:
11062        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
11063    S::Future: Send + Unpin + 'static,
11064    S::Error: Into<Box<dyn StdError + Send + Sync>>,
11065{
11066    /// Perform the operation you have build so far, but without uploading. This is used to e.g. renaming or updating the description for a file
11067    pub async fn doit_without_upload(
11068        mut self,
11069    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)> {
11070        use client::ToParts;
11071        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11072        use std::io::{Read, Seek};
11073        let mut dd = client::DefaultDelegate;
11074        let mut dlg: &mut dyn client::Delegate = match self._delegate {
11075            Some(d) => d,
11076            None => &mut dd,
11077        };
11078        dlg.begin(client::MethodInfo {
11079            id: "drive.files.update",
11080            http_method: hyper::Method::PATCH,
11081        });
11082        let mut params: Vec<(&str, String)> =
11083            Vec::with_capacity(13 + self._additional_params.len());
11084        params.push(("fileId", self._file_id.to_string()));
11085        if let Some(value) = self._use_content_as_indexable_text {
11086            params.push(("useContentAsIndexableText", value.to_string()));
11087        }
11088        if let Some(value) = self._supports_team_drives {
11089            params.push(("supportsTeamDrives", value.to_string()));
11090        }
11091        if let Some(value) = self._supports_all_drives {
11092            params.push(("supportsAllDrives", value.to_string()));
11093        }
11094        if let Some(value) = self._remove_parents {
11095            params.push(("removeParents", value.to_string()));
11096        }
11097        if let Some(value) = self._ocr_language {
11098            params.push(("ocrLanguage", value.to_string()));
11099        }
11100        if let Some(value) = self._keep_revision_forever {
11101            params.push(("keepRevisionForever", value.to_string()));
11102        }
11103        if let Some(value) = self._include_permissions_for_view {
11104            params.push(("includePermissionsForView", value.to_string()));
11105        }
11106        if let Some(value) = self._enforce_single_parent {
11107            params.push(("enforceSingleParent", value.to_string()));
11108        }
11109        if let Some(value) = self._add_parents {
11110            params.push(("addParents", value.to_string()));
11111        }
11112        for &field in [
11113            "alt",
11114            "fileId",
11115            "useContentAsIndexableText",
11116            "supportsTeamDrives",
11117            "supportsAllDrives",
11118            "removeParents",
11119            "ocrLanguage",
11120            "keepRevisionForever",
11121            "includePermissionsForView",
11122            "enforceSingleParent",
11123            "addParents",
11124        ]
11125        .iter()
11126        {
11127            if self._additional_params.contains_key(field) {
11128                dlg.finished(false);
11129                return Err(client::Error::FieldClash(field));
11130            }
11131        }
11132        for (name, value) in self._additional_params.iter() {
11133            params.push((&name, value.clone()));
11134        }
11135
11136        params.push(("alt", "json".to_string()));
11137
11138        let mut url = self.hub._base_url.clone() + "files/{fileId}";
11139        if self._scopes.len() == 0 {
11140            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
11141        }
11142
11143        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
11144            let mut replace_with: Option<&str> = None;
11145            for &(name, ref value) in params.iter() {
11146                if name == param_name {
11147                    replace_with = Some(value);
11148                    break;
11149                }
11150            }
11151            url = url.replace(
11152                find_this,
11153                replace_with.expect("to find substitution value in params"),
11154            );
11155        }
11156        {
11157            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
11158            for param_name in ["fileId"].iter() {
11159                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11160                    indices_for_removal.push(index);
11161                }
11162            }
11163            for &index in indices_for_removal.iter() {
11164                params.remove(index);
11165            }
11166        }
11167
11168        let url = url::Url::parse_with_params(&url, params).unwrap();
11169
11170        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
11171        let mut request_value_reader = {
11172            let mut value = json::value::to_value(&self._request).expect("serde to work");
11173            client::remove_json_null_values(&mut value);
11174            let mut dst = io::Cursor::new(Vec::with_capacity(128));
11175            json::to_writer(&mut dst, &value).unwrap();
11176            dst
11177        };
11178        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
11179        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11180
11181        loop {
11182            let token = match self
11183                .hub
11184                .auth
11185                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
11186                .await
11187            {
11188                Ok(token) => token.clone(),
11189                Err(err) => match dlg.token(&err) {
11190                    Some(token) => token,
11191                    None => {
11192                        dlg.finished(false);
11193                        return Err(client::Error::MissingToken(err));
11194                    }
11195                },
11196            };
11197            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11198            let mut req_result = {
11199                let client = &self.hub.client;
11200                dlg.pre_request();
11201                let mut req_builder = hyper::Request::builder()
11202                    .method(hyper::Method::PATCH)
11203                    .uri(url.clone().into_string())
11204                    .header(USER_AGENT, self.hub._user_agent.clone())
11205                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
11206
11207                let request = req_builder
11208                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
11209                    .header(CONTENT_LENGTH, request_size as u64)
11210                    .body(hyper::body::Body::from(
11211                        request_value_reader.get_ref().clone(),
11212                    ));
11213
11214                client.request(request.unwrap()).await
11215            };
11216
11217            match req_result {
11218                Err(err) => {
11219                    if let client::Retry::After(d) = dlg.http_error(&err) {
11220                        sleep(d);
11221                        continue;
11222                    }
11223                    dlg.finished(false);
11224                    return Err(client::Error::HttpError(err));
11225                }
11226                Ok(mut res) => {
11227                    if !res.status().is_success() {
11228                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
11229                        let (parts, _) = res.into_parts();
11230                        let body = hyper::Body::from(res_body_string.clone());
11231                        let restored_response = hyper::Response::from_parts(parts, body);
11232
11233                        let server_response =
11234                            json::from_str::<serde_json::Value>(&res_body_string).ok();
11235
11236                        if let client::Retry::After(d) =
11237                            dlg.http_failure(&restored_response, server_response.clone())
11238                        {
11239                            sleep(d);
11240                            continue;
11241                        }
11242
11243                        dlg.finished(false);
11244
11245                        return match server_response {
11246                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
11247                            None => Err(client::Error::Failure(restored_response)),
11248                        };
11249                    }
11250                    let result_value = {
11251                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
11252
11253                        match json::from_str(&res_body_string) {
11254                            Ok(decoded) => (res, decoded),
11255                            Err(err) => {
11256                                dlg.response_json_decode_error(&res_body_string, &err);
11257                                return Err(client::Error::JsonDecodeError(res_body_string, err));
11258                            }
11259                        }
11260                    };
11261
11262                    dlg.finished(true);
11263                    return Ok(result_value);
11264                }
11265            }
11266        }
11267    }
11268
11269    /// Perform the operation you have build so far.
11270    async fn doit<RS>(
11271        mut self,
11272        mut reader: RS,
11273        reader_mime_type: mime::Mime,
11274        protocol: &'static str,
11275    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
11276    where
11277        RS: client::ReadSeek,
11278    {
11279        use client::ToParts;
11280        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11281        use std::io::{Read, Seek};
11282        let mut dd = client::DefaultDelegate;
11283        let mut dlg: &mut dyn client::Delegate = match self._delegate {
11284            Some(d) => d,
11285            None => &mut dd,
11286        };
11287        dlg.begin(client::MethodInfo {
11288            id: "drive.files.update",
11289            http_method: hyper::Method::PATCH,
11290        });
11291        let mut params: Vec<(&str, String)> =
11292            Vec::with_capacity(13 + self._additional_params.len());
11293        params.push(("fileId", self._file_id.to_string()));
11294        if let Some(value) = self._use_content_as_indexable_text {
11295            params.push(("useContentAsIndexableText", value.to_string()));
11296        }
11297        if let Some(value) = self._supports_team_drives {
11298            params.push(("supportsTeamDrives", value.to_string()));
11299        }
11300        if let Some(value) = self._supports_all_drives {
11301            params.push(("supportsAllDrives", value.to_string()));
11302        }
11303        if let Some(value) = self._remove_parents {
11304            params.push(("removeParents", value.to_string()));
11305        }
11306        if let Some(value) = self._ocr_language {
11307            params.push(("ocrLanguage", value.to_string()));
11308        }
11309        if let Some(value) = self._keep_revision_forever {
11310            params.push(("keepRevisionForever", value.to_string()));
11311        }
11312        if let Some(value) = self._include_permissions_for_view {
11313            params.push(("includePermissionsForView", value.to_string()));
11314        }
11315        if let Some(value) = self._enforce_single_parent {
11316            params.push(("enforceSingleParent", value.to_string()));
11317        }
11318        if let Some(value) = self._add_parents {
11319            params.push(("addParents", value.to_string()));
11320        }
11321        for &field in [
11322            "alt",
11323            "fileId",
11324            "useContentAsIndexableText",
11325            "supportsTeamDrives",
11326            "supportsAllDrives",
11327            "removeParents",
11328            "ocrLanguage",
11329            "keepRevisionForever",
11330            "includePermissionsForView",
11331            "enforceSingleParent",
11332            "addParents",
11333        ]
11334        .iter()
11335        {
11336            if self._additional_params.contains_key(field) {
11337                dlg.finished(false);
11338                return Err(client::Error::FieldClash(field));
11339            }
11340        }
11341        for (name, value) in self._additional_params.iter() {
11342            params.push((&name, value.clone()));
11343        }
11344
11345        params.push(("alt", "json".to_string()));
11346
11347        let (mut url, upload_type) = if protocol == "resumable" {
11348            (
11349                self.hub._root_url.clone() + "resumable/upload/drive/v3/files/{fileId}",
11350                "resumable",
11351            )
11352        } else if protocol == "simple" {
11353            (
11354                self.hub._root_url.clone() + "upload/drive/v3/files/{fileId}",
11355                "multipart",
11356            )
11357        } else {
11358            unreachable!()
11359        };
11360        params.push(("uploadType", upload_type.to_string()));
11361        if self._scopes.len() == 0 {
11362            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
11363        }
11364
11365        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
11366            let mut replace_with: Option<&str> = None;
11367            for &(name, ref value) in params.iter() {
11368                if name == param_name {
11369                    replace_with = Some(value);
11370                    break;
11371                }
11372            }
11373            url = url.replace(
11374                find_this,
11375                replace_with.expect("to find substitution value in params"),
11376            );
11377        }
11378        {
11379            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
11380            for param_name in ["fileId"].iter() {
11381                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11382                    indices_for_removal.push(index);
11383                }
11384            }
11385            for &index in indices_for_removal.iter() {
11386                params.remove(index);
11387            }
11388        }
11389
11390        let url = url::Url::parse_with_params(&url, params).unwrap();
11391
11392        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
11393        let mut request_value_reader = {
11394            let mut value = json::value::to_value(&self._request).expect("serde to work");
11395            client::remove_json_null_values(&mut value);
11396            let mut dst = io::Cursor::new(Vec::with_capacity(128));
11397            json::to_writer(&mut dst, &value).unwrap();
11398            dst
11399        };
11400        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
11401        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11402
11403        let mut should_ask_dlg_for_url = false;
11404        let mut upload_url_from_server;
11405        let mut upload_url: Option<String> = None;
11406
11407        loop {
11408            let token = match self
11409                .hub
11410                .auth
11411                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
11412                .await
11413            {
11414                Ok(token) => token.clone(),
11415                Err(err) => match dlg.token(&err) {
11416                    Some(token) => token,
11417                    None => {
11418                        dlg.finished(false);
11419                        return Err(client::Error::MissingToken(err));
11420                    }
11421                },
11422            };
11423            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11424            let mut req_result = {
11425                if should_ask_dlg_for_url
11426                    && (upload_url = dlg.upload_url()) == ()
11427                    && upload_url.is_some()
11428                {
11429                    should_ask_dlg_for_url = false;
11430                    upload_url_from_server = false;
11431                    Ok(hyper::Response::builder()
11432                        .status(hyper::StatusCode::OK)
11433                        .header("Location", upload_url.as_ref().unwrap().clone())
11434                        .body(hyper::body::Body::empty())
11435                        .unwrap())
11436                } else {
11437                    let mut mp_reader: client::MultiPartReader = Default::default();
11438                    let (mut body_reader, content_type) = match protocol {
11439                        "simple" => {
11440                            mp_reader.reserve_exact(2);
11441                            let size = reader.seek(io::SeekFrom::End(0)).unwrap();
11442                            reader.seek(io::SeekFrom::Start(0)).unwrap();
11443                            if size > 5497558138880 {
11444                                return Err(client::Error::UploadSizeLimitExceeded(
11445                                    size,
11446                                    5497558138880,
11447                                ));
11448                            }
11449                            mp_reader
11450                                .add_part(
11451                                    &mut request_value_reader,
11452                                    request_size,
11453                                    json_mime_type.clone(),
11454                                )
11455                                .add_part(&mut reader, size, reader_mime_type.clone());
11456                            let mime_type = mp_reader.mime_type();
11457                            (
11458                                &mut mp_reader as &mut (dyn io::Read + Send),
11459                                (CONTENT_TYPE, mime_type.to_string()),
11460                            )
11461                        }
11462                        _ => (
11463                            &mut request_value_reader as &mut (dyn io::Read + Send),
11464                            (CONTENT_TYPE, json_mime_type.to_string()),
11465                        ),
11466                    };
11467                    let client = &self.hub.client;
11468                    dlg.pre_request();
11469                    let mut req_builder = hyper::Request::builder()
11470                        .method(hyper::Method::PATCH)
11471                        .uri(url.clone().into_string())
11472                        .header(USER_AGENT, self.hub._user_agent.clone())
11473                        .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
11474
11475                    upload_url_from_server = true;
11476                    if protocol == "resumable" {
11477                        req_builder = req_builder
11478                            .header("X-Upload-Content-Type", format!("{}", reader_mime_type));
11479                    }
11480
11481                    let mut body_reader_bytes = vec![];
11482                    body_reader.read_to_end(&mut body_reader_bytes).unwrap();
11483                    let request = req_builder
11484                        .header(content_type.0, content_type.1.to_string())
11485                        .body(hyper::body::Body::from(body_reader_bytes));
11486
11487                    client.request(request.unwrap()).await
11488                }
11489            };
11490
11491            match req_result {
11492                Err(err) => {
11493                    if let client::Retry::After(d) = dlg.http_error(&err) {
11494                        sleep(d);
11495                        continue;
11496                    }
11497                    dlg.finished(false);
11498                    return Err(client::Error::HttpError(err));
11499                }
11500                Ok(mut res) => {
11501                    if !res.status().is_success() {
11502                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
11503                        let (parts, _) = res.into_parts();
11504                        let body = hyper::Body::from(res_body_string.clone());
11505                        let restored_response = hyper::Response::from_parts(parts, body);
11506
11507                        let server_response =
11508                            json::from_str::<serde_json::Value>(&res_body_string).ok();
11509
11510                        if let client::Retry::After(d) =
11511                            dlg.http_failure(&restored_response, server_response.clone())
11512                        {
11513                            sleep(d);
11514                            continue;
11515                        }
11516
11517                        dlg.finished(false);
11518
11519                        return match server_response {
11520                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
11521                            None => Err(client::Error::Failure(restored_response)),
11522                        };
11523                    }
11524                    if protocol == "resumable" {
11525                        let size = reader.seek(io::SeekFrom::End(0)).unwrap();
11526                        reader.seek(io::SeekFrom::Start(0)).unwrap();
11527                        if size > 5497558138880 {
11528                            return Err(client::Error::UploadSizeLimitExceeded(
11529                                size,
11530                                5497558138880,
11531                            ));
11532                        }
11533                        let upload_result = {
11534                            let url_str = &res
11535                                .headers()
11536                                .get("Location")
11537                                .expect("LOCATION header is part of protocol")
11538                                .to_str()
11539                                .unwrap();
11540                            if upload_url_from_server {
11541                                dlg.store_upload_url(Some(url_str));
11542                            }
11543
11544                            client::ResumableUploadHelper {
11545                                client: &self.hub.client,
11546                                delegate: dlg,
11547                                start_at: if upload_url_from_server {
11548                                    Some(0)
11549                                } else {
11550                                    None
11551                                },
11552                                auth: &self.hub.auth,
11553                                user_agent: &self.hub._user_agent,
11554                                auth_header: format!("Bearer {}", token.as_str()),
11555                                url: url_str,
11556                                reader: &mut reader,
11557                                media_type: reader_mime_type.clone(),
11558                                content_length: size,
11559                            }
11560                            .upload()
11561                            .await
11562                        };
11563                        match upload_result {
11564                            None => {
11565                                dlg.finished(false);
11566                                return Err(client::Error::Cancelled);
11567                            }
11568                            Some(Err(err)) => {
11569                                dlg.finished(false);
11570                                return Err(client::Error::HttpError(err));
11571                            }
11572                            Some(Ok(upload_result)) => {
11573                                res = upload_result;
11574                                if !res.status().is_success() {
11575                                    dlg.store_upload_url(None);
11576                                    dlg.finished(false);
11577                                    return Err(client::Error::Failure(res));
11578                                }
11579                            }
11580                        }
11581                    }
11582                    let result_value = {
11583                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
11584
11585                        match json::from_str(&res_body_string) {
11586                            Ok(decoded) => (res, decoded),
11587                            Err(err) => {
11588                                dlg.response_json_decode_error(&res_body_string, &err);
11589                                return Err(client::Error::JsonDecodeError(res_body_string, err));
11590                            }
11591                        }
11592                    };
11593
11594                    dlg.finished(true);
11595                    return Ok(result_value);
11596                }
11597            }
11598        }
11599    }
11600
11601    /// Upload media in a resumable fashion.
11602    /// Even if the upload fails or is interrupted, it can be resumed for a
11603    /// certain amount of time as the server maintains state temporarily.
11604    ///
11605    /// The delegate will be asked for an `upload_url()`, and if not provided, will be asked to store an upload URL
11606    /// that was provided by the server, using `store_upload_url(...)`. The upload will be done in chunks, the delegate
11607    /// may specify the `chunk_size()` and may cancel the operation before each chunk is uploaded, using
11608    /// `cancel_chunk_upload(...)`.
11609    ///
11610    /// * *multipart*: yes
11611    /// * *max size*: 5120GB
11612    /// * *valid mime types*: '*/*'
11613    pub async fn upload_resumable<RS>(
11614        self,
11615        resumeable_stream: RS,
11616        mime_type: mime::Mime,
11617    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
11618    where
11619        RS: client::ReadSeek,
11620    {
11621        self.doit(resumeable_stream, mime_type, "resumable").await
11622    }
11623    /// Upload media all at once.
11624    /// If the upload fails for whichever reason, all progress is lost.
11625    ///
11626    /// * *multipart*: yes
11627    /// * *max size*: 5120GB
11628    /// * *valid mime types*: '*/*'
11629    pub async fn upload<RS>(
11630        self,
11631        stream: RS,
11632        mime_type: mime::Mime,
11633    ) -> client::Result<(hyper::Response<hyper::body::Body>, File)>
11634    where
11635        RS: client::ReadSeek,
11636    {
11637        self.doit(stream, mime_type, "simple").await
11638    }
11639
11640    ///
11641    /// Sets the *request* property to the given value.
11642    ///
11643    /// Even though the property as already been set when instantiating this call,
11644    /// we provide this method for API completeness.
11645    pub fn request(mut self, new_value: File) -> FileUpdateCall<'a, S> {
11646        self._request = new_value;
11647        self
11648    }
11649    /// The ID of the file.
11650    ///
11651    /// Sets the *file id* path property to the given value.
11652    ///
11653    /// Even though the property as already been set when instantiating this call,
11654    /// we provide this method for API completeness.
11655    pub fn file_id(mut self, new_value: &str) -> FileUpdateCall<'a, S> {
11656        self._file_id = new_value.to_string();
11657        self
11658    }
11659    /// Whether to use the uploaded content as indexable text.
11660    ///
11661    /// Sets the *use content as indexable text* query property to the given value.
11662    pub fn use_content_as_indexable_text(mut self, new_value: bool) -> FileUpdateCall<'a, S> {
11663        self._use_content_as_indexable_text = Some(new_value);
11664        self
11665    }
11666    /// Deprecated use supportsAllDrives instead.
11667    ///
11668    /// Sets the *supports team drives* query property to the given value.
11669    pub fn supports_team_drives(mut self, new_value: bool) -> FileUpdateCall<'a, S> {
11670        self._supports_team_drives = Some(new_value);
11671        self
11672    }
11673    /// Whether the requesting application supports both My Drives and shared drives.
11674    ///
11675    /// Sets the *supports all drives* query property to the given value.
11676    pub fn supports_all_drives(mut self, new_value: bool) -> FileUpdateCall<'a, S> {
11677        self._supports_all_drives = Some(new_value);
11678        self
11679    }
11680    /// A comma-separated list of parent IDs to remove.
11681    ///
11682    /// Sets the *remove parents* query property to the given value.
11683    pub fn remove_parents(mut self, new_value: &str) -> FileUpdateCall<'a, S> {
11684        self._remove_parents = Some(new_value.to_string());
11685        self
11686    }
11687    /// A language hint for OCR processing during image import (ISO 639-1 code).
11688    ///
11689    /// Sets the *ocr language* query property to the given value.
11690    pub fn ocr_language(mut self, new_value: &str) -> FileUpdateCall<'a, S> {
11691        self._ocr_language = Some(new_value.to_string());
11692        self
11693    }
11694    /// Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.
11695    ///
11696    /// Sets the *keep revision forever* query property to the given value.
11697    pub fn keep_revision_forever(mut self, new_value: bool) -> FileUpdateCall<'a, S> {
11698        self._keep_revision_forever = Some(new_value);
11699        self
11700    }
11701    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
11702    ///
11703    /// Sets the *include permissions for view* query property to the given value.
11704    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileUpdateCall<'a, S> {
11705        self._include_permissions_for_view = Some(new_value.to_string());
11706        self
11707    }
11708    /// Deprecated. Adding files to multiple folders is no longer supported. Use shortcuts instead.
11709    ///
11710    /// Sets the *enforce single parent* query property to the given value.
11711    pub fn enforce_single_parent(mut self, new_value: bool) -> FileUpdateCall<'a, S> {
11712        self._enforce_single_parent = Some(new_value);
11713        self
11714    }
11715    /// A comma-separated list of parent IDs to add.
11716    ///
11717    /// Sets the *add parents* query property to the given value.
11718    pub fn add_parents(mut self, new_value: &str) -> FileUpdateCall<'a, S> {
11719        self._add_parents = Some(new_value.to_string());
11720        self
11721    }
11722    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11723    /// while executing the actual API request.
11724    ///
11725    /// It should be used to handle progress information, and to implement a certain level of resilience.
11726    ///
11727    /// Sets the *delegate* property to the given value.
11728    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileUpdateCall<'a, S> {
11729        self._delegate = Some(new_value);
11730        self
11731    }
11732
11733    /// Set any additional parameter of the query string used in the request.
11734    /// It should be used to set parameters which are not yet available through their own
11735    /// setters.
11736    ///
11737    /// Please note that this method must not be used to set any of the known parameters
11738    /// which have their own setter method. If done anyway, the request will fail.
11739    ///
11740    /// # Additional Parameters
11741    ///
11742    /// * *alt* (query-string) - Data format for the response.
11743    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11744    /// * *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.
11745    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11746    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11747    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11748    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11749    pub fn param<T>(mut self, name: T, value: T) -> FileUpdateCall<'a, S>
11750    where
11751        T: AsRef<str>,
11752    {
11753        self._additional_params
11754            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11755        self
11756    }
11757
11758    /// Identifies the authorization scope for the method you are building.
11759    ///
11760    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
11761    /// `Scope::Full`.
11762    ///
11763    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11764    /// tokens for more than one scope.
11765    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
11766    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
11767    /// function for details).
11768    ///
11769    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11770    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11771    /// sufficient, a read-write scope will do as well.
11772    pub fn add_scope<T, St>(mut self, scope: T) -> FileUpdateCall<'a, S>
11773    where
11774        T: Into<Option<St>>,
11775        St: AsRef<str>,
11776    {
11777        match scope.into() {
11778            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
11779            None => None,
11780        };
11781        self
11782    }
11783}
11784
11785/// Subscribes to changes to a file. While you can establish a channel forchanges to a file on a shared drive, a change to a shared drive file won't create a notification.
11786///
11787/// This method supports **media download**. To enable it, adjust the builder like this:
11788/// `.param("alt", "media")`.
11789/// Please note that due to missing multi-part support on the server side, you will only receive the media,
11790/// but not the `Channel` structure that you would usually get. The latter will be a default value.
11791///
11792/// A builder for the *watch* method supported by a *file* resource.
11793/// It is not used directly, but through a `FileMethods` instance.
11794///
11795/// # Example
11796///
11797/// Instantiate a resource method builder
11798///
11799/// ```test_harness,no_run
11800/// # extern crate hyper;
11801/// # extern crate hyper_rustls;
11802/// # extern crate google_drive3 as drive3;
11803/// use drive3::api::Channel;
11804/// # async fn dox() {
11805/// # use std::default::Default;
11806/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
11807///
11808/// # let secret: oauth2::ApplicationSecret = Default::default();
11809/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
11810/// #         secret,
11811/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11812/// #     ).build().await.unwrap();
11813/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
11814/// // As the method needs a request, you would usually fill it with the desired information
11815/// // into the respective structure. Some of the parts shown here might not be applicable !
11816/// // Values shown here are possibly random and not representative !
11817/// let mut req = Channel::default();
11818///
11819/// // You can configure optional parameters by calling the respective setters at will, and
11820/// // execute the final call using `doit()`.
11821/// // Values shown here are possibly random and not representative !
11822/// let result = hub.files().watch(req, "fileId")
11823///              .supports_team_drives(true)
11824///              .supports_all_drives(true)
11825///              .include_permissions_for_view("magna")
11826///              .acknowledge_abuse(true)
11827///              .doit().await;
11828/// # }
11829/// ```
11830pub struct FileWatchCall<'a, S>
11831where
11832    S: 'a,
11833{
11834    hub: &'a DriveHub<S>,
11835    _request: Channel,
11836    _file_id: String,
11837    _supports_team_drives: Option<bool>,
11838    _supports_all_drives: Option<bool>,
11839    _include_permissions_for_view: Option<String>,
11840    _acknowledge_abuse: Option<bool>,
11841    _delegate: Option<&'a mut dyn client::Delegate>,
11842    _additional_params: HashMap<String, String>,
11843    _scopes: BTreeMap<String, ()>,
11844}
11845
11846impl<'a, S> client::CallBuilder for FileWatchCall<'a, S> {}
11847
11848impl<'a, S> FileWatchCall<'a, S>
11849where
11850    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
11851    S::Response:
11852        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
11853    S::Future: Send + Unpin + 'static,
11854    S::Error: Into<Box<dyn StdError + Send + Sync>>,
11855{
11856    /// Perform the operation you have build so far.
11857    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Channel)> {
11858        use client::ToParts;
11859        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11860        use std::io::{Read, Seek};
11861        let mut dd = client::DefaultDelegate;
11862        let mut dlg: &mut dyn client::Delegate = match self._delegate {
11863            Some(d) => d,
11864            None => &mut dd,
11865        };
11866        dlg.begin(client::MethodInfo {
11867            id: "drive.files.watch",
11868            http_method: hyper::Method::POST,
11869        });
11870        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
11871        params.push(("fileId", self._file_id.to_string()));
11872        if let Some(value) = self._supports_team_drives {
11873            params.push(("supportsTeamDrives", value.to_string()));
11874        }
11875        if let Some(value) = self._supports_all_drives {
11876            params.push(("supportsAllDrives", value.to_string()));
11877        }
11878        if let Some(value) = self._include_permissions_for_view {
11879            params.push(("includePermissionsForView", value.to_string()));
11880        }
11881        if let Some(value) = self._acknowledge_abuse {
11882            params.push(("acknowledgeAbuse", value.to_string()));
11883        }
11884        for &field in [
11885            "fileId",
11886            "supportsTeamDrives",
11887            "supportsAllDrives",
11888            "includePermissionsForView",
11889            "acknowledgeAbuse",
11890        ]
11891        .iter()
11892        {
11893            if self._additional_params.contains_key(field) {
11894                dlg.finished(false);
11895                return Err(client::Error::FieldClash(field));
11896            }
11897        }
11898        for (name, value) in self._additional_params.iter() {
11899            params.push((&name, value.clone()));
11900        }
11901
11902        let (json_field_missing, enable_resource_parsing) = {
11903            let mut enable = true;
11904            let mut field_present = true;
11905            for &(name, ref value) in params.iter() {
11906                if name == "alt" {
11907                    field_present = false;
11908                    if <String as AsRef<str>>::as_ref(&value) != "json" {
11909                        enable = false;
11910                    }
11911                    break;
11912                }
11913            }
11914            (field_present, enable)
11915        };
11916        if json_field_missing {
11917            params.push(("alt", "json".to_string()));
11918        }
11919
11920        let mut url = self.hub._base_url.clone() + "files/{fileId}/watch";
11921        if self._scopes.len() == 0 {
11922            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
11923        }
11924
11925        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
11926            let mut replace_with: Option<&str> = None;
11927            for &(name, ref value) in params.iter() {
11928                if name == param_name {
11929                    replace_with = Some(value);
11930                    break;
11931                }
11932            }
11933            url = url.replace(
11934                find_this,
11935                replace_with.expect("to find substitution value in params"),
11936            );
11937        }
11938        {
11939            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
11940            for param_name in ["fileId"].iter() {
11941                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
11942                    indices_for_removal.push(index);
11943                }
11944            }
11945            for &index in indices_for_removal.iter() {
11946                params.remove(index);
11947            }
11948        }
11949
11950        let url = url::Url::parse_with_params(&url, params).unwrap();
11951
11952        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
11953        let mut request_value_reader = {
11954            let mut value = json::value::to_value(&self._request).expect("serde to work");
11955            client::remove_json_null_values(&mut value);
11956            let mut dst = io::Cursor::new(Vec::with_capacity(128));
11957            json::to_writer(&mut dst, &value).unwrap();
11958            dst
11959        };
11960        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
11961        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11962
11963        loop {
11964            let token = match self
11965                .hub
11966                .auth
11967                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
11968                .await
11969            {
11970                Ok(token) => token.clone(),
11971                Err(err) => match dlg.token(&err) {
11972                    Some(token) => token,
11973                    None => {
11974                        dlg.finished(false);
11975                        return Err(client::Error::MissingToken(err));
11976                    }
11977                },
11978            };
11979            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
11980            let mut req_result = {
11981                let client = &self.hub.client;
11982                dlg.pre_request();
11983                let mut req_builder = hyper::Request::builder()
11984                    .method(hyper::Method::POST)
11985                    .uri(url.clone().into_string())
11986                    .header(USER_AGENT, self.hub._user_agent.clone())
11987                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
11988
11989                let request = req_builder
11990                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
11991                    .header(CONTENT_LENGTH, request_size as u64)
11992                    .body(hyper::body::Body::from(
11993                        request_value_reader.get_ref().clone(),
11994                    ));
11995
11996                client.request(request.unwrap()).await
11997            };
11998
11999            match req_result {
12000                Err(err) => {
12001                    if let client::Retry::After(d) = dlg.http_error(&err) {
12002                        sleep(d);
12003                        continue;
12004                    }
12005                    dlg.finished(false);
12006                    return Err(client::Error::HttpError(err));
12007                }
12008                Ok(mut res) => {
12009                    if !res.status().is_success() {
12010                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
12011                        let (parts, _) = res.into_parts();
12012                        let body = hyper::Body::from(res_body_string.clone());
12013                        let restored_response = hyper::Response::from_parts(parts, body);
12014
12015                        let server_response =
12016                            json::from_str::<serde_json::Value>(&res_body_string).ok();
12017
12018                        if let client::Retry::After(d) =
12019                            dlg.http_failure(&restored_response, server_response.clone())
12020                        {
12021                            sleep(d);
12022                            continue;
12023                        }
12024
12025                        dlg.finished(false);
12026
12027                        return match server_response {
12028                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
12029                            None => Err(client::Error::Failure(restored_response)),
12030                        };
12031                    }
12032                    let result_value = if enable_resource_parsing {
12033                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
12034
12035                        match json::from_str(&res_body_string) {
12036                            Ok(decoded) => (res, decoded),
12037                            Err(err) => {
12038                                dlg.response_json_decode_error(&res_body_string, &err);
12039                                return Err(client::Error::JsonDecodeError(res_body_string, err));
12040                            }
12041                        }
12042                    } else {
12043                        (res, Default::default())
12044                    };
12045
12046                    dlg.finished(true);
12047                    return Ok(result_value);
12048                }
12049            }
12050        }
12051    }
12052
12053    ///
12054    /// Sets the *request* property to the given value.
12055    ///
12056    /// Even though the property as already been set when instantiating this call,
12057    /// we provide this method for API completeness.
12058    pub fn request(mut self, new_value: Channel) -> FileWatchCall<'a, S> {
12059        self._request = new_value;
12060        self
12061    }
12062    /// The ID of the file.
12063    ///
12064    /// Sets the *file id* path property to the given value.
12065    ///
12066    /// Even though the property as already been set when instantiating this call,
12067    /// we provide this method for API completeness.
12068    pub fn file_id(mut self, new_value: &str) -> FileWatchCall<'a, S> {
12069        self._file_id = new_value.to_string();
12070        self
12071    }
12072    /// Deprecated use supportsAllDrives instead.
12073    ///
12074    /// Sets the *supports team drives* query property to the given value.
12075    pub fn supports_team_drives(mut self, new_value: bool) -> FileWatchCall<'a, S> {
12076        self._supports_team_drives = Some(new_value);
12077        self
12078    }
12079    /// Whether the requesting application supports both My Drives and shared drives.
12080    ///
12081    /// Sets the *supports all drives* query property to the given value.
12082    pub fn supports_all_drives(mut self, new_value: bool) -> FileWatchCall<'a, S> {
12083        self._supports_all_drives = Some(new_value);
12084        self
12085    }
12086    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
12087    ///
12088    /// Sets the *include permissions for view* query property to the given value.
12089    pub fn include_permissions_for_view(mut self, new_value: &str) -> FileWatchCall<'a, S> {
12090        self._include_permissions_for_view = Some(new_value.to_string());
12091        self
12092    }
12093    /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.
12094    ///
12095    /// Sets the *acknowledge abuse* query property to the given value.
12096    pub fn acknowledge_abuse(mut self, new_value: bool) -> FileWatchCall<'a, S> {
12097        self._acknowledge_abuse = Some(new_value);
12098        self
12099    }
12100    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12101    /// while executing the actual API request.
12102    ///
12103    /// It should be used to handle progress information, and to implement a certain level of resilience.
12104    ///
12105    /// Sets the *delegate* property to the given value.
12106    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> FileWatchCall<'a, S> {
12107        self._delegate = Some(new_value);
12108        self
12109    }
12110
12111    /// Set any additional parameter of the query string used in the request.
12112    /// It should be used to set parameters which are not yet available through their own
12113    /// setters.
12114    ///
12115    /// Please note that this method must not be used to set any of the known parameters
12116    /// which have their own setter method. If done anyway, the request will fail.
12117    ///
12118    /// # Additional Parameters
12119    ///
12120    /// * *alt* (query-string) - Data format for the response.
12121    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12122    /// * *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.
12123    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12124    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12125    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12126    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12127    pub fn param<T>(mut self, name: T, value: T) -> FileWatchCall<'a, S>
12128    where
12129        T: AsRef<str>,
12130    {
12131        self._additional_params
12132            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12133        self
12134    }
12135
12136    /// Identifies the authorization scope for the method you are building.
12137    ///
12138    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12139    /// `Scope::Full`.
12140    ///
12141    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12142    /// tokens for more than one scope.
12143    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12144    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12145    /// function for details).
12146    ///
12147    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12148    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12149    /// sufficient, a read-write scope will do as well.
12150    pub fn add_scope<T, St>(mut self, scope: T) -> FileWatchCall<'a, S>
12151    where
12152        T: Into<Option<St>>,
12153        St: AsRef<str>,
12154    {
12155        match scope.into() {
12156            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12157            None => None,
12158        };
12159        self
12160    }
12161}
12162
12163/// Creates a permission for a file or shared drive.
12164///
12165/// A builder for the *create* method supported by a *permission* resource.
12166/// It is not used directly, but through a `PermissionMethods` instance.
12167///
12168/// # Example
12169///
12170/// Instantiate a resource method builder
12171///
12172/// ```test_harness,no_run
12173/// # extern crate hyper;
12174/// # extern crate hyper_rustls;
12175/// # extern crate google_drive3 as drive3;
12176/// use drive3::api::Permission;
12177/// # async fn dox() {
12178/// # use std::default::Default;
12179/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
12180///
12181/// # let secret: oauth2::ApplicationSecret = Default::default();
12182/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
12183/// #         secret,
12184/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12185/// #     ).build().await.unwrap();
12186/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
12187/// // As the method needs a request, you would usually fill it with the desired information
12188/// // into the respective structure. Some of the parts shown here might not be applicable !
12189/// // Values shown here are possibly random and not representative !
12190/// let mut req = Permission::default();
12191///
12192/// // You can configure optional parameters by calling the respective setters at will, and
12193/// // execute the final call using `doit()`.
12194/// // Values shown here are possibly random and not representative !
12195/// let result = hub.permissions().create(req, "fileId")
12196///              .use_domain_admin_access(false)
12197///              .transfer_ownership(true)
12198///              .supports_team_drives(false)
12199///              .supports_all_drives(true)
12200///              .send_notification_email(false)
12201///              .move_to_new_owners_root(true)
12202///              .enforce_single_parent(false)
12203///              .email_message("rebum.")
12204///              .doit().await;
12205/// # }
12206/// ```
12207pub struct PermissionCreateCall<'a, S>
12208where
12209    S: 'a,
12210{
12211    hub: &'a DriveHub<S>,
12212    _request: Permission,
12213    _file_id: String,
12214    _use_domain_admin_access: Option<bool>,
12215    _transfer_ownership: Option<bool>,
12216    _supports_team_drives: Option<bool>,
12217    _supports_all_drives: Option<bool>,
12218    _send_notification_email: Option<bool>,
12219    _move_to_new_owners_root: Option<bool>,
12220    _enforce_single_parent: Option<bool>,
12221    _email_message: Option<String>,
12222    _delegate: Option<&'a mut dyn client::Delegate>,
12223    _additional_params: HashMap<String, String>,
12224    _scopes: BTreeMap<String, ()>,
12225}
12226
12227impl<'a, S> client::CallBuilder for PermissionCreateCall<'a, S> {}
12228
12229impl<'a, S> PermissionCreateCall<'a, S>
12230where
12231    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
12232    S::Response:
12233        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
12234    S::Future: Send + Unpin + 'static,
12235    S::Error: Into<Box<dyn StdError + Send + Sync>>,
12236{
12237    /// Perform the operation you have build so far.
12238    pub async fn doit(
12239        mut self,
12240    ) -> client::Result<(hyper::Response<hyper::body::Body>, Permission)> {
12241        use client::ToParts;
12242        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12243        use std::io::{Read, Seek};
12244        let mut dd = client::DefaultDelegate;
12245        let mut dlg: &mut dyn client::Delegate = match self._delegate {
12246            Some(d) => d,
12247            None => &mut dd,
12248        };
12249        dlg.begin(client::MethodInfo {
12250            id: "drive.permissions.create",
12251            http_method: hyper::Method::POST,
12252        });
12253        let mut params: Vec<(&str, String)> =
12254            Vec::with_capacity(12 + self._additional_params.len());
12255        params.push(("fileId", self._file_id.to_string()));
12256        if let Some(value) = self._use_domain_admin_access {
12257            params.push(("useDomainAdminAccess", value.to_string()));
12258        }
12259        if let Some(value) = self._transfer_ownership {
12260            params.push(("transferOwnership", value.to_string()));
12261        }
12262        if let Some(value) = self._supports_team_drives {
12263            params.push(("supportsTeamDrives", value.to_string()));
12264        }
12265        if let Some(value) = self._supports_all_drives {
12266            params.push(("supportsAllDrives", value.to_string()));
12267        }
12268        if let Some(value) = self._send_notification_email {
12269            params.push(("sendNotificationEmail", value.to_string()));
12270        }
12271        if let Some(value) = self._move_to_new_owners_root {
12272            params.push(("moveToNewOwnersRoot", value.to_string()));
12273        }
12274        if let Some(value) = self._enforce_single_parent {
12275            params.push(("enforceSingleParent", value.to_string()));
12276        }
12277        if let Some(value) = self._email_message {
12278            params.push(("emailMessage", value.to_string()));
12279        }
12280        for &field in [
12281            "alt",
12282            "fileId",
12283            "useDomainAdminAccess",
12284            "transferOwnership",
12285            "supportsTeamDrives",
12286            "supportsAllDrives",
12287            "sendNotificationEmail",
12288            "moveToNewOwnersRoot",
12289            "enforceSingleParent",
12290            "emailMessage",
12291        ]
12292        .iter()
12293        {
12294            if self._additional_params.contains_key(field) {
12295                dlg.finished(false);
12296                return Err(client::Error::FieldClash(field));
12297            }
12298        }
12299        for (name, value) in self._additional_params.iter() {
12300            params.push((&name, value.clone()));
12301        }
12302
12303        params.push(("alt", "json".to_string()));
12304
12305        let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions";
12306        if self._scopes.len() == 0 {
12307            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
12308        }
12309
12310        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
12311            let mut replace_with: Option<&str> = None;
12312            for &(name, ref value) in params.iter() {
12313                if name == param_name {
12314                    replace_with = Some(value);
12315                    break;
12316                }
12317            }
12318            url = url.replace(
12319                find_this,
12320                replace_with.expect("to find substitution value in params"),
12321            );
12322        }
12323        {
12324            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
12325            for param_name in ["fileId"].iter() {
12326                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12327                    indices_for_removal.push(index);
12328                }
12329            }
12330            for &index in indices_for_removal.iter() {
12331                params.remove(index);
12332            }
12333        }
12334
12335        let url = url::Url::parse_with_params(&url, params).unwrap();
12336
12337        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
12338        let mut request_value_reader = {
12339            let mut value = json::value::to_value(&self._request).expect("serde to work");
12340            client::remove_json_null_values(&mut value);
12341            let mut dst = io::Cursor::new(Vec::with_capacity(128));
12342            json::to_writer(&mut dst, &value).unwrap();
12343            dst
12344        };
12345        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
12346        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12347
12348        loop {
12349            let token = match self
12350                .hub
12351                .auth
12352                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
12353                .await
12354            {
12355                Ok(token) => token.clone(),
12356                Err(err) => match dlg.token(&err) {
12357                    Some(token) => token,
12358                    None => {
12359                        dlg.finished(false);
12360                        return Err(client::Error::MissingToken(err));
12361                    }
12362                },
12363            };
12364            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
12365            let mut req_result = {
12366                let client = &self.hub.client;
12367                dlg.pre_request();
12368                let mut req_builder = hyper::Request::builder()
12369                    .method(hyper::Method::POST)
12370                    .uri(url.clone().into_string())
12371                    .header(USER_AGENT, self.hub._user_agent.clone())
12372                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
12373
12374                let request = req_builder
12375                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
12376                    .header(CONTENT_LENGTH, request_size as u64)
12377                    .body(hyper::body::Body::from(
12378                        request_value_reader.get_ref().clone(),
12379                    ));
12380
12381                client.request(request.unwrap()).await
12382            };
12383
12384            match req_result {
12385                Err(err) => {
12386                    if let client::Retry::After(d) = dlg.http_error(&err) {
12387                        sleep(d);
12388                        continue;
12389                    }
12390                    dlg.finished(false);
12391                    return Err(client::Error::HttpError(err));
12392                }
12393                Ok(mut res) => {
12394                    if !res.status().is_success() {
12395                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
12396                        let (parts, _) = res.into_parts();
12397                        let body = hyper::Body::from(res_body_string.clone());
12398                        let restored_response = hyper::Response::from_parts(parts, body);
12399
12400                        let server_response =
12401                            json::from_str::<serde_json::Value>(&res_body_string).ok();
12402
12403                        if let client::Retry::After(d) =
12404                            dlg.http_failure(&restored_response, server_response.clone())
12405                        {
12406                            sleep(d);
12407                            continue;
12408                        }
12409
12410                        dlg.finished(false);
12411
12412                        return match server_response {
12413                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
12414                            None => Err(client::Error::Failure(restored_response)),
12415                        };
12416                    }
12417                    let result_value = {
12418                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
12419
12420                        match json::from_str(&res_body_string) {
12421                            Ok(decoded) => (res, decoded),
12422                            Err(err) => {
12423                                dlg.response_json_decode_error(&res_body_string, &err);
12424                                return Err(client::Error::JsonDecodeError(res_body_string, err));
12425                            }
12426                        }
12427                    };
12428
12429                    dlg.finished(true);
12430                    return Ok(result_value);
12431                }
12432            }
12433        }
12434    }
12435
12436    ///
12437    /// Sets the *request* property to the given value.
12438    ///
12439    /// Even though the property as already been set when instantiating this call,
12440    /// we provide this method for API completeness.
12441    pub fn request(mut self, new_value: Permission) -> PermissionCreateCall<'a, S> {
12442        self._request = new_value;
12443        self
12444    }
12445    /// The ID of the file or shared drive.
12446    ///
12447    /// Sets the *file id* path property to the given value.
12448    ///
12449    /// Even though the property as already been set when instantiating this call,
12450    /// we provide this method for API completeness.
12451    pub fn file_id(mut self, new_value: &str) -> PermissionCreateCall<'a, S> {
12452        self._file_id = new_value.to_string();
12453        self
12454    }
12455    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
12456    ///
12457    /// Sets the *use domain admin access* query property to the given value.
12458    pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12459        self._use_domain_admin_access = Some(new_value);
12460        self
12461    }
12462    /// Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. File owners can only transfer ownership of files existing on My Drive. Files existing in a shared drive are owned by the organization that owns that shared drive. Ownership transfers are not supported for files and folders in shared drives. Organizers of a shared drive can move items from that shared drive into their My Drive which transfers the ownership to them.
12463    ///
12464    /// Sets the *transfer ownership* query property to the given value.
12465    pub fn transfer_ownership(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12466        self._transfer_ownership = Some(new_value);
12467        self
12468    }
12469    /// Deprecated use supportsAllDrives instead.
12470    ///
12471    /// Sets the *supports team drives* query property to the given value.
12472    pub fn supports_team_drives(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12473        self._supports_team_drives = Some(new_value);
12474        self
12475    }
12476    /// Whether the requesting application supports both My Drives and shared drives.
12477    ///
12478    /// Sets the *supports all drives* query property to the given value.
12479    pub fn supports_all_drives(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12480        self._supports_all_drives = Some(new_value);
12481        self
12482    }
12483    /// Whether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.
12484    ///
12485    /// Sets the *send notification email* query property to the given value.
12486    pub fn send_notification_email(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12487        self._send_notification_email = Some(new_value);
12488        self
12489    }
12490    /// This parameter will only take effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item. If set to true, the item will be moved to the new owner's My Drive root folder and all prior parents removed. If set to false, parents are not changed.
12491    ///
12492    /// Sets the *move to new owners root* query property to the given value.
12493    pub fn move_to_new_owners_root(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12494        self._move_to_new_owners_root = Some(new_value);
12495        self
12496    }
12497    /// Deprecated. See moveToNewOwnersRoot for details.
12498    ///
12499    /// Sets the *enforce single parent* query property to the given value.
12500    pub fn enforce_single_parent(mut self, new_value: bool) -> PermissionCreateCall<'a, S> {
12501        self._enforce_single_parent = Some(new_value);
12502        self
12503    }
12504    /// A plain text custom message to include in the notification email.
12505    ///
12506    /// Sets the *email message* query property to the given value.
12507    pub fn email_message(mut self, new_value: &str) -> PermissionCreateCall<'a, S> {
12508        self._email_message = Some(new_value.to_string());
12509        self
12510    }
12511    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12512    /// while executing the actual API request.
12513    ///
12514    /// It should be used to handle progress information, and to implement a certain level of resilience.
12515    ///
12516    /// Sets the *delegate* property to the given value.
12517    pub fn delegate(
12518        mut self,
12519        new_value: &'a mut dyn client::Delegate,
12520    ) -> PermissionCreateCall<'a, S> {
12521        self._delegate = Some(new_value);
12522        self
12523    }
12524
12525    /// Set any additional parameter of the query string used in the request.
12526    /// It should be used to set parameters which are not yet available through their own
12527    /// setters.
12528    ///
12529    /// Please note that this method must not be used to set any of the known parameters
12530    /// which have their own setter method. If done anyway, the request will fail.
12531    ///
12532    /// # Additional Parameters
12533    ///
12534    /// * *alt* (query-string) - Data format for the response.
12535    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12536    /// * *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.
12537    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12538    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12539    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12540    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12541    pub fn param<T>(mut self, name: T, value: T) -> PermissionCreateCall<'a, S>
12542    where
12543        T: AsRef<str>,
12544    {
12545        self._additional_params
12546            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12547        self
12548    }
12549
12550    /// Identifies the authorization scope for the method you are building.
12551    ///
12552    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12553    /// `Scope::Full`.
12554    ///
12555    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12556    /// tokens for more than one scope.
12557    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12558    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12559    /// function for details).
12560    ///
12561    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12562    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12563    /// sufficient, a read-write scope will do as well.
12564    pub fn add_scope<T, St>(mut self, scope: T) -> PermissionCreateCall<'a, S>
12565    where
12566        T: Into<Option<St>>,
12567        St: AsRef<str>,
12568    {
12569        match scope.into() {
12570            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12571            None => None,
12572        };
12573        self
12574    }
12575}
12576
12577/// Deletes a permission.
12578///
12579/// A builder for the *delete* method supported by a *permission* resource.
12580/// It is not used directly, but through a `PermissionMethods` instance.
12581///
12582/// # Example
12583///
12584/// Instantiate a resource method builder
12585///
12586/// ```test_harness,no_run
12587/// # extern crate hyper;
12588/// # extern crate hyper_rustls;
12589/// # extern crate google_drive3 as drive3;
12590/// # async fn dox() {
12591/// # use std::default::Default;
12592/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
12593///
12594/// # let secret: oauth2::ApplicationSecret = Default::default();
12595/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
12596/// #         secret,
12597/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12598/// #     ).build().await.unwrap();
12599/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
12600/// // You can configure optional parameters by calling the respective setters at will, and
12601/// // execute the final call using `doit()`.
12602/// // Values shown here are possibly random and not representative !
12603/// let result = hub.permissions().delete("fileId", "permissionId")
12604///              .use_domain_admin_access(true)
12605///              .supports_team_drives(false)
12606///              .supports_all_drives(false)
12607///              .doit().await;
12608/// # }
12609/// ```
12610pub struct PermissionDeleteCall<'a, S>
12611where
12612    S: 'a,
12613{
12614    hub: &'a DriveHub<S>,
12615    _file_id: String,
12616    _permission_id: String,
12617    _use_domain_admin_access: Option<bool>,
12618    _supports_team_drives: Option<bool>,
12619    _supports_all_drives: Option<bool>,
12620    _delegate: Option<&'a mut dyn client::Delegate>,
12621    _additional_params: HashMap<String, String>,
12622    _scopes: BTreeMap<String, ()>,
12623}
12624
12625impl<'a, S> client::CallBuilder for PermissionDeleteCall<'a, S> {}
12626
12627impl<'a, S> PermissionDeleteCall<'a, S>
12628where
12629    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
12630    S::Response:
12631        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
12632    S::Future: Send + Unpin + 'static,
12633    S::Error: Into<Box<dyn StdError + Send + Sync>>,
12634{
12635    /// Perform the operation you have build so far.
12636    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
12637        use client::ToParts;
12638        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12639        use std::io::{Read, Seek};
12640        let mut dd = client::DefaultDelegate;
12641        let mut dlg: &mut dyn client::Delegate = match self._delegate {
12642            Some(d) => d,
12643            None => &mut dd,
12644        };
12645        dlg.begin(client::MethodInfo {
12646            id: "drive.permissions.delete",
12647            http_method: hyper::Method::DELETE,
12648        });
12649        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
12650        params.push(("fileId", self._file_id.to_string()));
12651        params.push(("permissionId", self._permission_id.to_string()));
12652        if let Some(value) = self._use_domain_admin_access {
12653            params.push(("useDomainAdminAccess", value.to_string()));
12654        }
12655        if let Some(value) = self._supports_team_drives {
12656            params.push(("supportsTeamDrives", value.to_string()));
12657        }
12658        if let Some(value) = self._supports_all_drives {
12659            params.push(("supportsAllDrives", value.to_string()));
12660        }
12661        for &field in [
12662            "fileId",
12663            "permissionId",
12664            "useDomainAdminAccess",
12665            "supportsTeamDrives",
12666            "supportsAllDrives",
12667        ]
12668        .iter()
12669        {
12670            if self._additional_params.contains_key(field) {
12671                dlg.finished(false);
12672                return Err(client::Error::FieldClash(field));
12673            }
12674        }
12675        for (name, value) in self._additional_params.iter() {
12676            params.push((&name, value.clone()));
12677        }
12678
12679        let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
12680        if self._scopes.len() == 0 {
12681            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
12682        }
12683
12684        for &(find_this, param_name) in
12685            [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
12686        {
12687            let mut replace_with: Option<&str> = None;
12688            for &(name, ref value) in params.iter() {
12689                if name == param_name {
12690                    replace_with = Some(value);
12691                    break;
12692                }
12693            }
12694            url = url.replace(
12695                find_this,
12696                replace_with.expect("to find substitution value in params"),
12697            );
12698        }
12699        {
12700            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
12701            for param_name in ["permissionId", "fileId"].iter() {
12702                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
12703                    indices_for_removal.push(index);
12704                }
12705            }
12706            for &index in indices_for_removal.iter() {
12707                params.remove(index);
12708            }
12709        }
12710
12711        let url = url::Url::parse_with_params(&url, params).unwrap();
12712
12713        loop {
12714            let token = match self
12715                .hub
12716                .auth
12717                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
12718                .await
12719            {
12720                Ok(token) => token.clone(),
12721                Err(err) => match dlg.token(&err) {
12722                    Some(token) => token,
12723                    None => {
12724                        dlg.finished(false);
12725                        return Err(client::Error::MissingToken(err));
12726                    }
12727                },
12728            };
12729            let mut req_result = {
12730                let client = &self.hub.client;
12731                dlg.pre_request();
12732                let mut req_builder = hyper::Request::builder()
12733                    .method(hyper::Method::DELETE)
12734                    .uri(url.clone().into_string())
12735                    .header(USER_AGENT, self.hub._user_agent.clone())
12736                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
12737
12738                let request = req_builder.body(hyper::body::Body::empty());
12739
12740                client.request(request.unwrap()).await
12741            };
12742
12743            match req_result {
12744                Err(err) => {
12745                    if let client::Retry::After(d) = dlg.http_error(&err) {
12746                        sleep(d);
12747                        continue;
12748                    }
12749                    dlg.finished(false);
12750                    return Err(client::Error::HttpError(err));
12751                }
12752                Ok(mut res) => {
12753                    if !res.status().is_success() {
12754                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
12755                        let (parts, _) = res.into_parts();
12756                        let body = hyper::Body::from(res_body_string.clone());
12757                        let restored_response = hyper::Response::from_parts(parts, body);
12758
12759                        let server_response =
12760                            json::from_str::<serde_json::Value>(&res_body_string).ok();
12761
12762                        if let client::Retry::After(d) =
12763                            dlg.http_failure(&restored_response, server_response.clone())
12764                        {
12765                            sleep(d);
12766                            continue;
12767                        }
12768
12769                        dlg.finished(false);
12770
12771                        return match server_response {
12772                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
12773                            None => Err(client::Error::Failure(restored_response)),
12774                        };
12775                    }
12776                    let result_value = res;
12777
12778                    dlg.finished(true);
12779                    return Ok(result_value);
12780                }
12781            }
12782        }
12783    }
12784
12785    /// The ID of the file or shared drive.
12786    ///
12787    /// Sets the *file id* path property to the given value.
12788    ///
12789    /// Even though the property as already been set when instantiating this call,
12790    /// we provide this method for API completeness.
12791    pub fn file_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, S> {
12792        self._file_id = new_value.to_string();
12793        self
12794    }
12795    /// The ID of the permission.
12796    ///
12797    /// Sets the *permission id* path property to the given value.
12798    ///
12799    /// Even though the property as already been set when instantiating this call,
12800    /// we provide this method for API completeness.
12801    pub fn permission_id(mut self, new_value: &str) -> PermissionDeleteCall<'a, S> {
12802        self._permission_id = new_value.to_string();
12803        self
12804    }
12805    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
12806    ///
12807    /// Sets the *use domain admin access* query property to the given value.
12808    pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> {
12809        self._use_domain_admin_access = Some(new_value);
12810        self
12811    }
12812    /// Deprecated use supportsAllDrives instead.
12813    ///
12814    /// Sets the *supports team drives* query property to the given value.
12815    pub fn supports_team_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> {
12816        self._supports_team_drives = Some(new_value);
12817        self
12818    }
12819    /// Whether the requesting application supports both My Drives and shared drives.
12820    ///
12821    /// Sets the *supports all drives* query property to the given value.
12822    pub fn supports_all_drives(mut self, new_value: bool) -> PermissionDeleteCall<'a, S> {
12823        self._supports_all_drives = Some(new_value);
12824        self
12825    }
12826    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12827    /// while executing the actual API request.
12828    ///
12829    /// It should be used to handle progress information, and to implement a certain level of resilience.
12830    ///
12831    /// Sets the *delegate* property to the given value.
12832    pub fn delegate(
12833        mut self,
12834        new_value: &'a mut dyn client::Delegate,
12835    ) -> PermissionDeleteCall<'a, S> {
12836        self._delegate = Some(new_value);
12837        self
12838    }
12839
12840    /// Set any additional parameter of the query string used in the request.
12841    /// It should be used to set parameters which are not yet available through their own
12842    /// setters.
12843    ///
12844    /// Please note that this method must not be used to set any of the known parameters
12845    /// which have their own setter method. If done anyway, the request will fail.
12846    ///
12847    /// # Additional Parameters
12848    ///
12849    /// * *alt* (query-string) - Data format for the response.
12850    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12851    /// * *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.
12852    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12853    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12854    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12855    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12856    pub fn param<T>(mut self, name: T, value: T) -> PermissionDeleteCall<'a, S>
12857    where
12858        T: AsRef<str>,
12859    {
12860        self._additional_params
12861            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12862        self
12863    }
12864
12865    /// Identifies the authorization scope for the method you are building.
12866    ///
12867    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
12868    /// `Scope::Full`.
12869    ///
12870    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12871    /// tokens for more than one scope.
12872    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
12873    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
12874    /// function for details).
12875    ///
12876    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12877    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12878    /// sufficient, a read-write scope will do as well.
12879    pub fn add_scope<T, St>(mut self, scope: T) -> PermissionDeleteCall<'a, S>
12880    where
12881        T: Into<Option<St>>,
12882        St: AsRef<str>,
12883    {
12884        match scope.into() {
12885            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
12886            None => None,
12887        };
12888        self
12889    }
12890}
12891
12892/// Gets a permission by ID.
12893///
12894/// A builder for the *get* method supported by a *permission* resource.
12895/// It is not used directly, but through a `PermissionMethods` instance.
12896///
12897/// # Example
12898///
12899/// Instantiate a resource method builder
12900///
12901/// ```test_harness,no_run
12902/// # extern crate hyper;
12903/// # extern crate hyper_rustls;
12904/// # extern crate google_drive3 as drive3;
12905/// # async fn dox() {
12906/// # use std::default::Default;
12907/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
12908///
12909/// # let secret: oauth2::ApplicationSecret = Default::default();
12910/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
12911/// #         secret,
12912/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12913/// #     ).build().await.unwrap();
12914/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
12915/// // You can configure optional parameters by calling the respective setters at will, and
12916/// // execute the final call using `doit()`.
12917/// // Values shown here are possibly random and not representative !
12918/// let result = hub.permissions().get("fileId", "permissionId")
12919///              .use_domain_admin_access(true)
12920///              .supports_team_drives(false)
12921///              .supports_all_drives(true)
12922///              .doit().await;
12923/// # }
12924/// ```
12925pub struct PermissionGetCall<'a, S>
12926where
12927    S: 'a,
12928{
12929    hub: &'a DriveHub<S>,
12930    _file_id: String,
12931    _permission_id: String,
12932    _use_domain_admin_access: Option<bool>,
12933    _supports_team_drives: Option<bool>,
12934    _supports_all_drives: Option<bool>,
12935    _delegate: Option<&'a mut dyn client::Delegate>,
12936    _additional_params: HashMap<String, String>,
12937    _scopes: BTreeMap<String, ()>,
12938}
12939
12940impl<'a, S> client::CallBuilder for PermissionGetCall<'a, S> {}
12941
12942impl<'a, S> PermissionGetCall<'a, S>
12943where
12944    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
12945    S::Response:
12946        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
12947    S::Future: Send + Unpin + 'static,
12948    S::Error: Into<Box<dyn StdError + Send + Sync>>,
12949{
12950    /// Perform the operation you have build so far.
12951    pub async fn doit(
12952        mut self,
12953    ) -> client::Result<(hyper::Response<hyper::body::Body>, Permission)> {
12954        use client::ToParts;
12955        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12956        use std::io::{Read, Seek};
12957        let mut dd = client::DefaultDelegate;
12958        let mut dlg: &mut dyn client::Delegate = match self._delegate {
12959            Some(d) => d,
12960            None => &mut dd,
12961        };
12962        dlg.begin(client::MethodInfo {
12963            id: "drive.permissions.get",
12964            http_method: hyper::Method::GET,
12965        });
12966        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
12967        params.push(("fileId", self._file_id.to_string()));
12968        params.push(("permissionId", self._permission_id.to_string()));
12969        if let Some(value) = self._use_domain_admin_access {
12970            params.push(("useDomainAdminAccess", value.to_string()));
12971        }
12972        if let Some(value) = self._supports_team_drives {
12973            params.push(("supportsTeamDrives", value.to_string()));
12974        }
12975        if let Some(value) = self._supports_all_drives {
12976            params.push(("supportsAllDrives", value.to_string()));
12977        }
12978        for &field in [
12979            "alt",
12980            "fileId",
12981            "permissionId",
12982            "useDomainAdminAccess",
12983            "supportsTeamDrives",
12984            "supportsAllDrives",
12985        ]
12986        .iter()
12987        {
12988            if self._additional_params.contains_key(field) {
12989                dlg.finished(false);
12990                return Err(client::Error::FieldClash(field));
12991            }
12992        }
12993        for (name, value) in self._additional_params.iter() {
12994            params.push((&name, value.clone()));
12995        }
12996
12997        params.push(("alt", "json".to_string()));
12998
12999        let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
13000        if self._scopes.len() == 0 {
13001            self._scopes
13002                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
13003        }
13004
13005        for &(find_this, param_name) in
13006            [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
13007        {
13008            let mut replace_with: Option<&str> = None;
13009            for &(name, ref value) in params.iter() {
13010                if name == param_name {
13011                    replace_with = Some(value);
13012                    break;
13013                }
13014            }
13015            url = url.replace(
13016                find_this,
13017                replace_with.expect("to find substitution value in params"),
13018            );
13019        }
13020        {
13021            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13022            for param_name in ["permissionId", "fileId"].iter() {
13023                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13024                    indices_for_removal.push(index);
13025                }
13026            }
13027            for &index in indices_for_removal.iter() {
13028                params.remove(index);
13029            }
13030        }
13031
13032        let url = url::Url::parse_with_params(&url, params).unwrap();
13033
13034        loop {
13035            let token = match self
13036                .hub
13037                .auth
13038                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
13039                .await
13040            {
13041                Ok(token) => token.clone(),
13042                Err(err) => match dlg.token(&err) {
13043                    Some(token) => token,
13044                    None => {
13045                        dlg.finished(false);
13046                        return Err(client::Error::MissingToken(err));
13047                    }
13048                },
13049            };
13050            let mut req_result = {
13051                let client = &self.hub.client;
13052                dlg.pre_request();
13053                let mut req_builder = hyper::Request::builder()
13054                    .method(hyper::Method::GET)
13055                    .uri(url.clone().into_string())
13056                    .header(USER_AGENT, self.hub._user_agent.clone())
13057                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
13058
13059                let request = req_builder.body(hyper::body::Body::empty());
13060
13061                client.request(request.unwrap()).await
13062            };
13063
13064            match req_result {
13065                Err(err) => {
13066                    if let client::Retry::After(d) = dlg.http_error(&err) {
13067                        sleep(d);
13068                        continue;
13069                    }
13070                    dlg.finished(false);
13071                    return Err(client::Error::HttpError(err));
13072                }
13073                Ok(mut res) => {
13074                    if !res.status().is_success() {
13075                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13076                        let (parts, _) = res.into_parts();
13077                        let body = hyper::Body::from(res_body_string.clone());
13078                        let restored_response = hyper::Response::from_parts(parts, body);
13079
13080                        let server_response =
13081                            json::from_str::<serde_json::Value>(&res_body_string).ok();
13082
13083                        if let client::Retry::After(d) =
13084                            dlg.http_failure(&restored_response, server_response.clone())
13085                        {
13086                            sleep(d);
13087                            continue;
13088                        }
13089
13090                        dlg.finished(false);
13091
13092                        return match server_response {
13093                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
13094                            None => Err(client::Error::Failure(restored_response)),
13095                        };
13096                    }
13097                    let result_value = {
13098                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13099
13100                        match json::from_str(&res_body_string) {
13101                            Ok(decoded) => (res, decoded),
13102                            Err(err) => {
13103                                dlg.response_json_decode_error(&res_body_string, &err);
13104                                return Err(client::Error::JsonDecodeError(res_body_string, err));
13105                            }
13106                        }
13107                    };
13108
13109                    dlg.finished(true);
13110                    return Ok(result_value);
13111                }
13112            }
13113        }
13114    }
13115
13116    /// The ID of the file.
13117    ///
13118    /// Sets the *file id* path property to the given value.
13119    ///
13120    /// Even though the property as already been set when instantiating this call,
13121    /// we provide this method for API completeness.
13122    pub fn file_id(mut self, new_value: &str) -> PermissionGetCall<'a, S> {
13123        self._file_id = new_value.to_string();
13124        self
13125    }
13126    /// The ID of the permission.
13127    ///
13128    /// Sets the *permission id* path property to the given value.
13129    ///
13130    /// Even though the property as already been set when instantiating this call,
13131    /// we provide this method for API completeness.
13132    pub fn permission_id(mut self, new_value: &str) -> PermissionGetCall<'a, S> {
13133        self._permission_id = new_value.to_string();
13134        self
13135    }
13136    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
13137    ///
13138    /// Sets the *use domain admin access* query property to the given value.
13139    pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionGetCall<'a, S> {
13140        self._use_domain_admin_access = Some(new_value);
13141        self
13142    }
13143    /// Deprecated use supportsAllDrives instead.
13144    ///
13145    /// Sets the *supports team drives* query property to the given value.
13146    pub fn supports_team_drives(mut self, new_value: bool) -> PermissionGetCall<'a, S> {
13147        self._supports_team_drives = Some(new_value);
13148        self
13149    }
13150    /// Whether the requesting application supports both My Drives and shared drives.
13151    ///
13152    /// Sets the *supports all drives* query property to the given value.
13153    pub fn supports_all_drives(mut self, new_value: bool) -> PermissionGetCall<'a, S> {
13154        self._supports_all_drives = Some(new_value);
13155        self
13156    }
13157    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13158    /// while executing the actual API request.
13159    ///
13160    /// It should be used to handle progress information, and to implement a certain level of resilience.
13161    ///
13162    /// Sets the *delegate* property to the given value.
13163    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> PermissionGetCall<'a, S> {
13164        self._delegate = Some(new_value);
13165        self
13166    }
13167
13168    /// Set any additional parameter of the query string used in the request.
13169    /// It should be used to set parameters which are not yet available through their own
13170    /// setters.
13171    ///
13172    /// Please note that this method must not be used to set any of the known parameters
13173    /// which have their own setter method. If done anyway, the request will fail.
13174    ///
13175    /// # Additional Parameters
13176    ///
13177    /// * *alt* (query-string) - Data format for the response.
13178    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13179    /// * *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.
13180    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13181    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13182    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13183    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13184    pub fn param<T>(mut self, name: T, value: T) -> PermissionGetCall<'a, S>
13185    where
13186        T: AsRef<str>,
13187    {
13188        self._additional_params
13189            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13190        self
13191    }
13192
13193    /// Identifies the authorization scope for the method you are building.
13194    ///
13195    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13196    /// `Scope::MetadataReadonly`.
13197    ///
13198    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13199    /// tokens for more than one scope.
13200    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13201    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13202    /// function for details).
13203    ///
13204    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13205    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13206    /// sufficient, a read-write scope will do as well.
13207    pub fn add_scope<T, St>(mut self, scope: T) -> PermissionGetCall<'a, S>
13208    where
13209        T: Into<Option<St>>,
13210        St: AsRef<str>,
13211    {
13212        match scope.into() {
13213            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13214            None => None,
13215        };
13216        self
13217    }
13218}
13219
13220/// Lists a file's or shared drive's permissions.
13221///
13222/// A builder for the *list* method supported by a *permission* resource.
13223/// It is not used directly, but through a `PermissionMethods` instance.
13224///
13225/// # Example
13226///
13227/// Instantiate a resource method builder
13228///
13229/// ```test_harness,no_run
13230/// # extern crate hyper;
13231/// # extern crate hyper_rustls;
13232/// # extern crate google_drive3 as drive3;
13233/// # async fn dox() {
13234/// # use std::default::Default;
13235/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
13236///
13237/// # let secret: oauth2::ApplicationSecret = Default::default();
13238/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
13239/// #         secret,
13240/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13241/// #     ).build().await.unwrap();
13242/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
13243/// // You can configure optional parameters by calling the respective setters at will, and
13244/// // execute the final call using `doit()`.
13245/// // Values shown here are possibly random and not representative !
13246/// let result = hub.permissions().list("fileId")
13247///              .use_domain_admin_access(false)
13248///              .supports_team_drives(true)
13249///              .supports_all_drives(false)
13250///              .page_token("tempor")
13251///              .page_size(-10)
13252///              .include_permissions_for_view("et")
13253///              .doit().await;
13254/// # }
13255/// ```
13256pub struct PermissionListCall<'a, S>
13257where
13258    S: 'a,
13259{
13260    hub: &'a DriveHub<S>,
13261    _file_id: String,
13262    _use_domain_admin_access: Option<bool>,
13263    _supports_team_drives: Option<bool>,
13264    _supports_all_drives: Option<bool>,
13265    _page_token: Option<String>,
13266    _page_size: Option<i32>,
13267    _include_permissions_for_view: Option<String>,
13268    _delegate: Option<&'a mut dyn client::Delegate>,
13269    _additional_params: HashMap<String, String>,
13270    _scopes: BTreeMap<String, ()>,
13271}
13272
13273impl<'a, S> client::CallBuilder for PermissionListCall<'a, S> {}
13274
13275impl<'a, S> PermissionListCall<'a, S>
13276where
13277    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
13278    S::Response:
13279        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
13280    S::Future: Send + Unpin + 'static,
13281    S::Error: Into<Box<dyn StdError + Send + Sync>>,
13282{
13283    /// Perform the operation you have build so far.
13284    pub async fn doit(
13285        mut self,
13286    ) -> client::Result<(hyper::Response<hyper::body::Body>, PermissionList)> {
13287        use client::ToParts;
13288        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13289        use std::io::{Read, Seek};
13290        let mut dd = client::DefaultDelegate;
13291        let mut dlg: &mut dyn client::Delegate = match self._delegate {
13292            Some(d) => d,
13293            None => &mut dd,
13294        };
13295        dlg.begin(client::MethodInfo {
13296            id: "drive.permissions.list",
13297            http_method: hyper::Method::GET,
13298        });
13299        let mut params: Vec<(&str, String)> = Vec::with_capacity(9 + self._additional_params.len());
13300        params.push(("fileId", self._file_id.to_string()));
13301        if let Some(value) = self._use_domain_admin_access {
13302            params.push(("useDomainAdminAccess", value.to_string()));
13303        }
13304        if let Some(value) = self._supports_team_drives {
13305            params.push(("supportsTeamDrives", value.to_string()));
13306        }
13307        if let Some(value) = self._supports_all_drives {
13308            params.push(("supportsAllDrives", value.to_string()));
13309        }
13310        if let Some(value) = self._page_token {
13311            params.push(("pageToken", value.to_string()));
13312        }
13313        if let Some(value) = self._page_size {
13314            params.push(("pageSize", value.to_string()));
13315        }
13316        if let Some(value) = self._include_permissions_for_view {
13317            params.push(("includePermissionsForView", value.to_string()));
13318        }
13319        for &field in [
13320            "alt",
13321            "fileId",
13322            "useDomainAdminAccess",
13323            "supportsTeamDrives",
13324            "supportsAllDrives",
13325            "pageToken",
13326            "pageSize",
13327            "includePermissionsForView",
13328        ]
13329        .iter()
13330        {
13331            if self._additional_params.contains_key(field) {
13332                dlg.finished(false);
13333                return Err(client::Error::FieldClash(field));
13334            }
13335        }
13336        for (name, value) in self._additional_params.iter() {
13337            params.push((&name, value.clone()));
13338        }
13339
13340        params.push(("alt", "json".to_string()));
13341
13342        let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions";
13343        if self._scopes.len() == 0 {
13344            self._scopes
13345                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
13346        }
13347
13348        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
13349            let mut replace_with: Option<&str> = None;
13350            for &(name, ref value) in params.iter() {
13351                if name == param_name {
13352                    replace_with = Some(value);
13353                    break;
13354                }
13355            }
13356            url = url.replace(
13357                find_this,
13358                replace_with.expect("to find substitution value in params"),
13359            );
13360        }
13361        {
13362            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
13363            for param_name in ["fileId"].iter() {
13364                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13365                    indices_for_removal.push(index);
13366                }
13367            }
13368            for &index in indices_for_removal.iter() {
13369                params.remove(index);
13370            }
13371        }
13372
13373        let url = url::Url::parse_with_params(&url, params).unwrap();
13374
13375        loop {
13376            let token = match self
13377                .hub
13378                .auth
13379                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
13380                .await
13381            {
13382                Ok(token) => token.clone(),
13383                Err(err) => match dlg.token(&err) {
13384                    Some(token) => token,
13385                    None => {
13386                        dlg.finished(false);
13387                        return Err(client::Error::MissingToken(err));
13388                    }
13389                },
13390            };
13391            let mut req_result = {
13392                let client = &self.hub.client;
13393                dlg.pre_request();
13394                let mut req_builder = hyper::Request::builder()
13395                    .method(hyper::Method::GET)
13396                    .uri(url.clone().into_string())
13397                    .header(USER_AGENT, self.hub._user_agent.clone())
13398                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
13399
13400                let request = req_builder.body(hyper::body::Body::empty());
13401
13402                client.request(request.unwrap()).await
13403            };
13404
13405            match req_result {
13406                Err(err) => {
13407                    if let client::Retry::After(d) = dlg.http_error(&err) {
13408                        sleep(d);
13409                        continue;
13410                    }
13411                    dlg.finished(false);
13412                    return Err(client::Error::HttpError(err));
13413                }
13414                Ok(mut res) => {
13415                    if !res.status().is_success() {
13416                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13417                        let (parts, _) = res.into_parts();
13418                        let body = hyper::Body::from(res_body_string.clone());
13419                        let restored_response = hyper::Response::from_parts(parts, body);
13420
13421                        let server_response =
13422                            json::from_str::<serde_json::Value>(&res_body_string).ok();
13423
13424                        if let client::Retry::After(d) =
13425                            dlg.http_failure(&restored_response, server_response.clone())
13426                        {
13427                            sleep(d);
13428                            continue;
13429                        }
13430
13431                        dlg.finished(false);
13432
13433                        return match server_response {
13434                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
13435                            None => Err(client::Error::Failure(restored_response)),
13436                        };
13437                    }
13438                    let result_value = {
13439                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13440
13441                        match json::from_str(&res_body_string) {
13442                            Ok(decoded) => (res, decoded),
13443                            Err(err) => {
13444                                dlg.response_json_decode_error(&res_body_string, &err);
13445                                return Err(client::Error::JsonDecodeError(res_body_string, err));
13446                            }
13447                        }
13448                    };
13449
13450                    dlg.finished(true);
13451                    return Ok(result_value);
13452                }
13453            }
13454        }
13455    }
13456
13457    /// The ID of the file or shared drive.
13458    ///
13459    /// Sets the *file id* path property to the given value.
13460    ///
13461    /// Even though the property as already been set when instantiating this call,
13462    /// we provide this method for API completeness.
13463    pub fn file_id(mut self, new_value: &str) -> PermissionListCall<'a, S> {
13464        self._file_id = new_value.to_string();
13465        self
13466    }
13467    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
13468    ///
13469    /// Sets the *use domain admin access* query property to the given value.
13470    pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionListCall<'a, S> {
13471        self._use_domain_admin_access = Some(new_value);
13472        self
13473    }
13474    /// Deprecated use supportsAllDrives instead.
13475    ///
13476    /// Sets the *supports team drives* query property to the given value.
13477    pub fn supports_team_drives(mut self, new_value: bool) -> PermissionListCall<'a, S> {
13478        self._supports_team_drives = Some(new_value);
13479        self
13480    }
13481    /// Whether the requesting application supports both My Drives and shared drives.
13482    ///
13483    /// Sets the *supports all drives* query property to the given value.
13484    pub fn supports_all_drives(mut self, new_value: bool) -> PermissionListCall<'a, S> {
13485        self._supports_all_drives = Some(new_value);
13486        self
13487    }
13488    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
13489    ///
13490    /// Sets the *page token* query property to the given value.
13491    pub fn page_token(mut self, new_value: &str) -> PermissionListCall<'a, S> {
13492        self._page_token = Some(new_value.to_string());
13493        self
13494    }
13495    /// The maximum number of permissions to return per page. When not set for files in a shared drive, at most 100 results will be returned. When not set for files that are not in a shared drive, the entire list will be returned.
13496    ///
13497    /// Sets the *page size* query property to the given value.
13498    pub fn page_size(mut self, new_value: i32) -> PermissionListCall<'a, S> {
13499        self._page_size = Some(new_value);
13500        self
13501    }
13502    /// Specifies which additional view's permissions to include in the response. Only 'published' is supported.
13503    ///
13504    /// Sets the *include permissions for view* query property to the given value.
13505    pub fn include_permissions_for_view(mut self, new_value: &str) -> PermissionListCall<'a, S> {
13506        self._include_permissions_for_view = Some(new_value.to_string());
13507        self
13508    }
13509    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13510    /// while executing the actual API request.
13511    ///
13512    /// It should be used to handle progress information, and to implement a certain level of resilience.
13513    ///
13514    /// Sets the *delegate* property to the given value.
13515    pub fn delegate(
13516        mut self,
13517        new_value: &'a mut dyn client::Delegate,
13518    ) -> PermissionListCall<'a, S> {
13519        self._delegate = Some(new_value);
13520        self
13521    }
13522
13523    /// Set any additional parameter of the query string used in the request.
13524    /// It should be used to set parameters which are not yet available through their own
13525    /// setters.
13526    ///
13527    /// Please note that this method must not be used to set any of the known parameters
13528    /// which have their own setter method. If done anyway, the request will fail.
13529    ///
13530    /// # Additional Parameters
13531    ///
13532    /// * *alt* (query-string) - Data format for the response.
13533    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13534    /// * *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.
13535    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13536    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13537    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13538    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13539    pub fn param<T>(mut self, name: T, value: T) -> PermissionListCall<'a, S>
13540    where
13541        T: AsRef<str>,
13542    {
13543        self._additional_params
13544            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13545        self
13546    }
13547
13548    /// Identifies the authorization scope for the method you are building.
13549    ///
13550    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13551    /// `Scope::MetadataReadonly`.
13552    ///
13553    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13554    /// tokens for more than one scope.
13555    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13556    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13557    /// function for details).
13558    ///
13559    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13560    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13561    /// sufficient, a read-write scope will do as well.
13562    pub fn add_scope<T, St>(mut self, scope: T) -> PermissionListCall<'a, S>
13563    where
13564        T: Into<Option<St>>,
13565        St: AsRef<str>,
13566    {
13567        match scope.into() {
13568            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13569            None => None,
13570        };
13571        self
13572    }
13573}
13574
13575/// Updates a permission with patch semantics.
13576///
13577/// A builder for the *update* method supported by a *permission* resource.
13578/// It is not used directly, but through a `PermissionMethods` instance.
13579///
13580/// # Example
13581///
13582/// Instantiate a resource method builder
13583///
13584/// ```test_harness,no_run
13585/// # extern crate hyper;
13586/// # extern crate hyper_rustls;
13587/// # extern crate google_drive3 as drive3;
13588/// use drive3::api::Permission;
13589/// # async fn dox() {
13590/// # use std::default::Default;
13591/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
13592///
13593/// # let secret: oauth2::ApplicationSecret = Default::default();
13594/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
13595/// #         secret,
13596/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13597/// #     ).build().await.unwrap();
13598/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
13599/// // As the method needs a request, you would usually fill it with the desired information
13600/// // into the respective structure. Some of the parts shown here might not be applicable !
13601/// // Values shown here are possibly random and not representative !
13602/// let mut req = Permission::default();
13603///
13604/// // You can configure optional parameters by calling the respective setters at will, and
13605/// // execute the final call using `doit()`.
13606/// // Values shown here are possibly random and not representative !
13607/// let result = hub.permissions().update(req, "fileId", "permissionId")
13608///              .use_domain_admin_access(true)
13609///              .transfer_ownership(true)
13610///              .supports_team_drives(false)
13611///              .supports_all_drives(false)
13612///              .remove_expiration(false)
13613///              .doit().await;
13614/// # }
13615/// ```
13616pub struct PermissionUpdateCall<'a, S>
13617where
13618    S: 'a,
13619{
13620    hub: &'a DriveHub<S>,
13621    _request: Permission,
13622    _file_id: String,
13623    _permission_id: String,
13624    _use_domain_admin_access: Option<bool>,
13625    _transfer_ownership: Option<bool>,
13626    _supports_team_drives: Option<bool>,
13627    _supports_all_drives: Option<bool>,
13628    _remove_expiration: Option<bool>,
13629    _delegate: Option<&'a mut dyn client::Delegate>,
13630    _additional_params: HashMap<String, String>,
13631    _scopes: BTreeMap<String, ()>,
13632}
13633
13634impl<'a, S> client::CallBuilder for PermissionUpdateCall<'a, S> {}
13635
13636impl<'a, S> PermissionUpdateCall<'a, S>
13637where
13638    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
13639    S::Response:
13640        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
13641    S::Future: Send + Unpin + 'static,
13642    S::Error: Into<Box<dyn StdError + Send + Sync>>,
13643{
13644    /// Perform the operation you have build so far.
13645    pub async fn doit(
13646        mut self,
13647    ) -> client::Result<(hyper::Response<hyper::body::Body>, Permission)> {
13648        use client::ToParts;
13649        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13650        use std::io::{Read, Seek};
13651        let mut dd = client::DefaultDelegate;
13652        let mut dlg: &mut dyn client::Delegate = match self._delegate {
13653            Some(d) => d,
13654            None => &mut dd,
13655        };
13656        dlg.begin(client::MethodInfo {
13657            id: "drive.permissions.update",
13658            http_method: hyper::Method::PATCH,
13659        });
13660        let mut params: Vec<(&str, String)> =
13661            Vec::with_capacity(10 + self._additional_params.len());
13662        params.push(("fileId", self._file_id.to_string()));
13663        params.push(("permissionId", self._permission_id.to_string()));
13664        if let Some(value) = self._use_domain_admin_access {
13665            params.push(("useDomainAdminAccess", value.to_string()));
13666        }
13667        if let Some(value) = self._transfer_ownership {
13668            params.push(("transferOwnership", value.to_string()));
13669        }
13670        if let Some(value) = self._supports_team_drives {
13671            params.push(("supportsTeamDrives", value.to_string()));
13672        }
13673        if let Some(value) = self._supports_all_drives {
13674            params.push(("supportsAllDrives", value.to_string()));
13675        }
13676        if let Some(value) = self._remove_expiration {
13677            params.push(("removeExpiration", value.to_string()));
13678        }
13679        for &field in [
13680            "alt",
13681            "fileId",
13682            "permissionId",
13683            "useDomainAdminAccess",
13684            "transferOwnership",
13685            "supportsTeamDrives",
13686            "supportsAllDrives",
13687            "removeExpiration",
13688        ]
13689        .iter()
13690        {
13691            if self._additional_params.contains_key(field) {
13692                dlg.finished(false);
13693                return Err(client::Error::FieldClash(field));
13694            }
13695        }
13696        for (name, value) in self._additional_params.iter() {
13697            params.push((&name, value.clone()));
13698        }
13699
13700        params.push(("alt", "json".to_string()));
13701
13702        let mut url = self.hub._base_url.clone() + "files/{fileId}/permissions/{permissionId}";
13703        if self._scopes.len() == 0 {
13704            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
13705        }
13706
13707        for &(find_this, param_name) in
13708            [("{fileId}", "fileId"), ("{permissionId}", "permissionId")].iter()
13709        {
13710            let mut replace_with: Option<&str> = None;
13711            for &(name, ref value) in params.iter() {
13712                if name == param_name {
13713                    replace_with = Some(value);
13714                    break;
13715                }
13716            }
13717            url = url.replace(
13718                find_this,
13719                replace_with.expect("to find substitution value in params"),
13720            );
13721        }
13722        {
13723            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
13724            for param_name in ["permissionId", "fileId"].iter() {
13725                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
13726                    indices_for_removal.push(index);
13727                }
13728            }
13729            for &index in indices_for_removal.iter() {
13730                params.remove(index);
13731            }
13732        }
13733
13734        let url = url::Url::parse_with_params(&url, params).unwrap();
13735
13736        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
13737        let mut request_value_reader = {
13738            let mut value = json::value::to_value(&self._request).expect("serde to work");
13739            client::remove_json_null_values(&mut value);
13740            let mut dst = io::Cursor::new(Vec::with_capacity(128));
13741            json::to_writer(&mut dst, &value).unwrap();
13742            dst
13743        };
13744        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
13745        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13746
13747        loop {
13748            let token = match self
13749                .hub
13750                .auth
13751                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
13752                .await
13753            {
13754                Ok(token) => token.clone(),
13755                Err(err) => match dlg.token(&err) {
13756                    Some(token) => token,
13757                    None => {
13758                        dlg.finished(false);
13759                        return Err(client::Error::MissingToken(err));
13760                    }
13761                },
13762            };
13763            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
13764            let mut req_result = {
13765                let client = &self.hub.client;
13766                dlg.pre_request();
13767                let mut req_builder = hyper::Request::builder()
13768                    .method(hyper::Method::PATCH)
13769                    .uri(url.clone().into_string())
13770                    .header(USER_AGENT, self.hub._user_agent.clone())
13771                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
13772
13773                let request = req_builder
13774                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
13775                    .header(CONTENT_LENGTH, request_size as u64)
13776                    .body(hyper::body::Body::from(
13777                        request_value_reader.get_ref().clone(),
13778                    ));
13779
13780                client.request(request.unwrap()).await
13781            };
13782
13783            match req_result {
13784                Err(err) => {
13785                    if let client::Retry::After(d) = dlg.http_error(&err) {
13786                        sleep(d);
13787                        continue;
13788                    }
13789                    dlg.finished(false);
13790                    return Err(client::Error::HttpError(err));
13791                }
13792                Ok(mut res) => {
13793                    if !res.status().is_success() {
13794                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13795                        let (parts, _) = res.into_parts();
13796                        let body = hyper::Body::from(res_body_string.clone());
13797                        let restored_response = hyper::Response::from_parts(parts, body);
13798
13799                        let server_response =
13800                            json::from_str::<serde_json::Value>(&res_body_string).ok();
13801
13802                        if let client::Retry::After(d) =
13803                            dlg.http_failure(&restored_response, server_response.clone())
13804                        {
13805                            sleep(d);
13806                            continue;
13807                        }
13808
13809                        dlg.finished(false);
13810
13811                        return match server_response {
13812                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
13813                            None => Err(client::Error::Failure(restored_response)),
13814                        };
13815                    }
13816                    let result_value = {
13817                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
13818
13819                        match json::from_str(&res_body_string) {
13820                            Ok(decoded) => (res, decoded),
13821                            Err(err) => {
13822                                dlg.response_json_decode_error(&res_body_string, &err);
13823                                return Err(client::Error::JsonDecodeError(res_body_string, err));
13824                            }
13825                        }
13826                    };
13827
13828                    dlg.finished(true);
13829                    return Ok(result_value);
13830                }
13831            }
13832        }
13833    }
13834
13835    ///
13836    /// Sets the *request* property to the given value.
13837    ///
13838    /// Even though the property as already been set when instantiating this call,
13839    /// we provide this method for API completeness.
13840    pub fn request(mut self, new_value: Permission) -> PermissionUpdateCall<'a, S> {
13841        self._request = new_value;
13842        self
13843    }
13844    /// The ID of the file or shared drive.
13845    ///
13846    /// Sets the *file id* path property to the given value.
13847    ///
13848    /// Even though the property as already been set when instantiating this call,
13849    /// we provide this method for API completeness.
13850    pub fn file_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, S> {
13851        self._file_id = new_value.to_string();
13852        self
13853    }
13854    /// The ID of the permission.
13855    ///
13856    /// Sets the *permission id* path property to the given value.
13857    ///
13858    /// Even though the property as already been set when instantiating this call,
13859    /// we provide this method for API completeness.
13860    pub fn permission_id(mut self, new_value: &str) -> PermissionUpdateCall<'a, S> {
13861        self._permission_id = new_value.to_string();
13862        self
13863    }
13864    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
13865    ///
13866    /// Sets the *use domain admin access* query property to the given value.
13867    pub fn use_domain_admin_access(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> {
13868        self._use_domain_admin_access = Some(new_value);
13869        self
13870    }
13871    /// Whether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. File owners can only transfer ownership of files existing on My Drive. Files existing in a shared drive are owned by the organization that owns that shared drive. Ownership transfers are not supported for files and folders in shared drives. Organizers of a shared drive can move items from that shared drive into their My Drive which transfers the ownership to them.
13872    ///
13873    /// Sets the *transfer ownership* query property to the given value.
13874    pub fn transfer_ownership(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> {
13875        self._transfer_ownership = Some(new_value);
13876        self
13877    }
13878    /// Deprecated use supportsAllDrives instead.
13879    ///
13880    /// Sets the *supports team drives* query property to the given value.
13881    pub fn supports_team_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> {
13882        self._supports_team_drives = Some(new_value);
13883        self
13884    }
13885    /// Whether the requesting application supports both My Drives and shared drives.
13886    ///
13887    /// Sets the *supports all drives* query property to the given value.
13888    pub fn supports_all_drives(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> {
13889        self._supports_all_drives = Some(new_value);
13890        self
13891    }
13892    /// Whether to remove the expiration date.
13893    ///
13894    /// Sets the *remove expiration* query property to the given value.
13895    pub fn remove_expiration(mut self, new_value: bool) -> PermissionUpdateCall<'a, S> {
13896        self._remove_expiration = Some(new_value);
13897        self
13898    }
13899    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13900    /// while executing the actual API request.
13901    ///
13902    /// It should be used to handle progress information, and to implement a certain level of resilience.
13903    ///
13904    /// Sets the *delegate* property to the given value.
13905    pub fn delegate(
13906        mut self,
13907        new_value: &'a mut dyn client::Delegate,
13908    ) -> PermissionUpdateCall<'a, S> {
13909        self._delegate = Some(new_value);
13910        self
13911    }
13912
13913    /// Set any additional parameter of the query string used in the request.
13914    /// It should be used to set parameters which are not yet available through their own
13915    /// setters.
13916    ///
13917    /// Please note that this method must not be used to set any of the known parameters
13918    /// which have their own setter method. If done anyway, the request will fail.
13919    ///
13920    /// # Additional Parameters
13921    ///
13922    /// * *alt* (query-string) - Data format for the response.
13923    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13924    /// * *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.
13925    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13926    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13927    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13928    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13929    pub fn param<T>(mut self, name: T, value: T) -> PermissionUpdateCall<'a, S>
13930    where
13931        T: AsRef<str>,
13932    {
13933        self._additional_params
13934            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13935        self
13936    }
13937
13938    /// Identifies the authorization scope for the method you are building.
13939    ///
13940    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
13941    /// `Scope::Full`.
13942    ///
13943    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13944    /// tokens for more than one scope.
13945    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
13946    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
13947    /// function for details).
13948    ///
13949    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13950    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13951    /// sufficient, a read-write scope will do as well.
13952    pub fn add_scope<T, St>(mut self, scope: T) -> PermissionUpdateCall<'a, S>
13953    where
13954        T: Into<Option<St>>,
13955        St: AsRef<str>,
13956    {
13957        match scope.into() {
13958            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
13959            None => None,
13960        };
13961        self
13962    }
13963}
13964
13965/// Creates a new reply to a comment.
13966///
13967/// A builder for the *create* method supported by a *reply* resource.
13968/// It is not used directly, but through a `ReplyMethods` instance.
13969///
13970/// # Example
13971///
13972/// Instantiate a resource method builder
13973///
13974/// ```test_harness,no_run
13975/// # extern crate hyper;
13976/// # extern crate hyper_rustls;
13977/// # extern crate google_drive3 as drive3;
13978/// use drive3::api::Reply;
13979/// # async fn dox() {
13980/// # use std::default::Default;
13981/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
13982///
13983/// # let secret: oauth2::ApplicationSecret = Default::default();
13984/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
13985/// #         secret,
13986/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13987/// #     ).build().await.unwrap();
13988/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
13989/// // As the method needs a request, you would usually fill it with the desired information
13990/// // into the respective structure. Some of the parts shown here might not be applicable !
13991/// // Values shown here are possibly random and not representative !
13992/// let mut req = Reply::default();
13993///
13994/// // You can configure optional parameters by calling the respective setters at will, and
13995/// // execute the final call using `doit()`.
13996/// // Values shown here are possibly random and not representative !
13997/// let result = hub.replies().create(req, "fileId", "commentId")
13998///              .doit().await;
13999/// # }
14000/// ```
14001pub struct ReplyCreateCall<'a, S>
14002where
14003    S: 'a,
14004{
14005    hub: &'a DriveHub<S>,
14006    _request: Reply,
14007    _file_id: String,
14008    _comment_id: String,
14009    _delegate: Option<&'a mut dyn client::Delegate>,
14010    _additional_params: HashMap<String, String>,
14011    _scopes: BTreeMap<String, ()>,
14012}
14013
14014impl<'a, S> client::CallBuilder for ReplyCreateCall<'a, S> {}
14015
14016impl<'a, S> ReplyCreateCall<'a, S>
14017where
14018    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
14019    S::Response:
14020        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
14021    S::Future: Send + Unpin + 'static,
14022    S::Error: Into<Box<dyn StdError + Send + Sync>>,
14023{
14024    /// Perform the operation you have build so far.
14025    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Reply)> {
14026        use client::ToParts;
14027        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14028        use std::io::{Read, Seek};
14029        let mut dd = client::DefaultDelegate;
14030        let mut dlg: &mut dyn client::Delegate = match self._delegate {
14031            Some(d) => d,
14032            None => &mut dd,
14033        };
14034        dlg.begin(client::MethodInfo {
14035            id: "drive.replies.create",
14036            http_method: hyper::Method::POST,
14037        });
14038        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
14039        params.push(("fileId", self._file_id.to_string()));
14040        params.push(("commentId", self._comment_id.to_string()));
14041        for &field in ["alt", "fileId", "commentId"].iter() {
14042            if self._additional_params.contains_key(field) {
14043                dlg.finished(false);
14044                return Err(client::Error::FieldClash(field));
14045            }
14046        }
14047        for (name, value) in self._additional_params.iter() {
14048            params.push((&name, value.clone()));
14049        }
14050
14051        params.push(("alt", "json".to_string()));
14052
14053        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
14054        if self._scopes.len() == 0 {
14055            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
14056        }
14057
14058        for &(find_this, param_name) in
14059            [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
14060        {
14061            let mut replace_with: Option<&str> = None;
14062            for &(name, ref value) in params.iter() {
14063                if name == param_name {
14064                    replace_with = Some(value);
14065                    break;
14066                }
14067            }
14068            url = url.replace(
14069                find_this,
14070                replace_with.expect("to find substitution value in params"),
14071            );
14072        }
14073        {
14074            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
14075            for param_name in ["commentId", "fileId"].iter() {
14076                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14077                    indices_for_removal.push(index);
14078                }
14079            }
14080            for &index in indices_for_removal.iter() {
14081                params.remove(index);
14082            }
14083        }
14084
14085        let url = url::Url::parse_with_params(&url, params).unwrap();
14086
14087        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
14088        let mut request_value_reader = {
14089            let mut value = json::value::to_value(&self._request).expect("serde to work");
14090            client::remove_json_null_values(&mut value);
14091            let mut dst = io::Cursor::new(Vec::with_capacity(128));
14092            json::to_writer(&mut dst, &value).unwrap();
14093            dst
14094        };
14095        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
14096        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
14097
14098        loop {
14099            let token = match self
14100                .hub
14101                .auth
14102                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
14103                .await
14104            {
14105                Ok(token) => token.clone(),
14106                Err(err) => match dlg.token(&err) {
14107                    Some(token) => token,
14108                    None => {
14109                        dlg.finished(false);
14110                        return Err(client::Error::MissingToken(err));
14111                    }
14112                },
14113            };
14114            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
14115            let mut req_result = {
14116                let client = &self.hub.client;
14117                dlg.pre_request();
14118                let mut req_builder = hyper::Request::builder()
14119                    .method(hyper::Method::POST)
14120                    .uri(url.clone().into_string())
14121                    .header(USER_AGENT, self.hub._user_agent.clone())
14122                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
14123
14124                let request = req_builder
14125                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
14126                    .header(CONTENT_LENGTH, request_size as u64)
14127                    .body(hyper::body::Body::from(
14128                        request_value_reader.get_ref().clone(),
14129                    ));
14130
14131                client.request(request.unwrap()).await
14132            };
14133
14134            match req_result {
14135                Err(err) => {
14136                    if let client::Retry::After(d) = dlg.http_error(&err) {
14137                        sleep(d);
14138                        continue;
14139                    }
14140                    dlg.finished(false);
14141                    return Err(client::Error::HttpError(err));
14142                }
14143                Ok(mut res) => {
14144                    if !res.status().is_success() {
14145                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
14146                        let (parts, _) = res.into_parts();
14147                        let body = hyper::Body::from(res_body_string.clone());
14148                        let restored_response = hyper::Response::from_parts(parts, body);
14149
14150                        let server_response =
14151                            json::from_str::<serde_json::Value>(&res_body_string).ok();
14152
14153                        if let client::Retry::After(d) =
14154                            dlg.http_failure(&restored_response, server_response.clone())
14155                        {
14156                            sleep(d);
14157                            continue;
14158                        }
14159
14160                        dlg.finished(false);
14161
14162                        return match server_response {
14163                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
14164                            None => Err(client::Error::Failure(restored_response)),
14165                        };
14166                    }
14167                    let result_value = {
14168                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
14169
14170                        match json::from_str(&res_body_string) {
14171                            Ok(decoded) => (res, decoded),
14172                            Err(err) => {
14173                                dlg.response_json_decode_error(&res_body_string, &err);
14174                                return Err(client::Error::JsonDecodeError(res_body_string, err));
14175                            }
14176                        }
14177                    };
14178
14179                    dlg.finished(true);
14180                    return Ok(result_value);
14181                }
14182            }
14183        }
14184    }
14185
14186    ///
14187    /// Sets the *request* property to the given value.
14188    ///
14189    /// Even though the property as already been set when instantiating this call,
14190    /// we provide this method for API completeness.
14191    pub fn request(mut self, new_value: Reply) -> ReplyCreateCall<'a, S> {
14192        self._request = new_value;
14193        self
14194    }
14195    /// The ID of the file.
14196    ///
14197    /// Sets the *file id* path property to the given value.
14198    ///
14199    /// Even though the property as already been set when instantiating this call,
14200    /// we provide this method for API completeness.
14201    pub fn file_id(mut self, new_value: &str) -> ReplyCreateCall<'a, S> {
14202        self._file_id = new_value.to_string();
14203        self
14204    }
14205    /// The ID of the comment.
14206    ///
14207    /// Sets the *comment id* path property to the given value.
14208    ///
14209    /// Even though the property as already been set when instantiating this call,
14210    /// we provide this method for API completeness.
14211    pub fn comment_id(mut self, new_value: &str) -> ReplyCreateCall<'a, S> {
14212        self._comment_id = new_value.to_string();
14213        self
14214    }
14215    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14216    /// while executing the actual API request.
14217    ///
14218    /// It should be used to handle progress information, and to implement a certain level of resilience.
14219    ///
14220    /// Sets the *delegate* property to the given value.
14221    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyCreateCall<'a, S> {
14222        self._delegate = Some(new_value);
14223        self
14224    }
14225
14226    /// Set any additional parameter of the query string used in the request.
14227    /// It should be used to set parameters which are not yet available through their own
14228    /// setters.
14229    ///
14230    /// Please note that this method must not be used to set any of the known parameters
14231    /// which have their own setter method. If done anyway, the request will fail.
14232    ///
14233    /// # Additional Parameters
14234    ///
14235    /// * *alt* (query-string) - Data format for the response.
14236    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14237    /// * *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.
14238    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14239    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14240    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14241    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14242    pub fn param<T>(mut self, name: T, value: T) -> ReplyCreateCall<'a, S>
14243    where
14244        T: AsRef<str>,
14245    {
14246        self._additional_params
14247            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14248        self
14249    }
14250
14251    /// Identifies the authorization scope for the method you are building.
14252    ///
14253    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14254    /// `Scope::Full`.
14255    ///
14256    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14257    /// tokens for more than one scope.
14258    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14259    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14260    /// function for details).
14261    ///
14262    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14263    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14264    /// sufficient, a read-write scope will do as well.
14265    pub fn add_scope<T, St>(mut self, scope: T) -> ReplyCreateCall<'a, S>
14266    where
14267        T: Into<Option<St>>,
14268        St: AsRef<str>,
14269    {
14270        match scope.into() {
14271            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14272            None => None,
14273        };
14274        self
14275    }
14276}
14277
14278/// Deletes a reply.
14279///
14280/// A builder for the *delete* method supported by a *reply* resource.
14281/// It is not used directly, but through a `ReplyMethods` instance.
14282///
14283/// # Example
14284///
14285/// Instantiate a resource method builder
14286///
14287/// ```test_harness,no_run
14288/// # extern crate hyper;
14289/// # extern crate hyper_rustls;
14290/// # extern crate google_drive3 as drive3;
14291/// # async fn dox() {
14292/// # use std::default::Default;
14293/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
14294///
14295/// # let secret: oauth2::ApplicationSecret = Default::default();
14296/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
14297/// #         secret,
14298/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14299/// #     ).build().await.unwrap();
14300/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
14301/// // You can configure optional parameters by calling the respective setters at will, and
14302/// // execute the final call using `doit()`.
14303/// // Values shown here are possibly random and not representative !
14304/// let result = hub.replies().delete("fileId", "commentId", "replyId")
14305///              .doit().await;
14306/// # }
14307/// ```
14308pub struct ReplyDeleteCall<'a, S>
14309where
14310    S: 'a,
14311{
14312    hub: &'a DriveHub<S>,
14313    _file_id: String,
14314    _comment_id: String,
14315    _reply_id: String,
14316    _delegate: Option<&'a mut dyn client::Delegate>,
14317    _additional_params: HashMap<String, String>,
14318    _scopes: BTreeMap<String, ()>,
14319}
14320
14321impl<'a, S> client::CallBuilder for ReplyDeleteCall<'a, S> {}
14322
14323impl<'a, S> ReplyDeleteCall<'a, S>
14324where
14325    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
14326    S::Response:
14327        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
14328    S::Future: Send + Unpin + 'static,
14329    S::Error: Into<Box<dyn StdError + Send + Sync>>,
14330{
14331    /// Perform the operation you have build so far.
14332    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
14333        use client::ToParts;
14334        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14335        use std::io::{Read, Seek};
14336        let mut dd = client::DefaultDelegate;
14337        let mut dlg: &mut dyn client::Delegate = match self._delegate {
14338            Some(d) => d,
14339            None => &mut dd,
14340        };
14341        dlg.begin(client::MethodInfo {
14342            id: "drive.replies.delete",
14343            http_method: hyper::Method::DELETE,
14344        });
14345        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
14346        params.push(("fileId", self._file_id.to_string()));
14347        params.push(("commentId", self._comment_id.to_string()));
14348        params.push(("replyId", self._reply_id.to_string()));
14349        for &field in ["fileId", "commentId", "replyId"].iter() {
14350            if self._additional_params.contains_key(field) {
14351                dlg.finished(false);
14352                return Err(client::Error::FieldClash(field));
14353            }
14354        }
14355        for (name, value) in self._additional_params.iter() {
14356            params.push((&name, value.clone()));
14357        }
14358
14359        let mut url =
14360            self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
14361        if self._scopes.len() == 0 {
14362            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
14363        }
14364
14365        for &(find_this, param_name) in [
14366            ("{fileId}", "fileId"),
14367            ("{commentId}", "commentId"),
14368            ("{replyId}", "replyId"),
14369        ]
14370        .iter()
14371        {
14372            let mut replace_with: Option<&str> = None;
14373            for &(name, ref value) in params.iter() {
14374                if name == param_name {
14375                    replace_with = Some(value);
14376                    break;
14377                }
14378            }
14379            url = url.replace(
14380                find_this,
14381                replace_with.expect("to find substitution value in params"),
14382            );
14383        }
14384        {
14385            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
14386            for param_name in ["replyId", "commentId", "fileId"].iter() {
14387                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14388                    indices_for_removal.push(index);
14389                }
14390            }
14391            for &index in indices_for_removal.iter() {
14392                params.remove(index);
14393            }
14394        }
14395
14396        let url = url::Url::parse_with_params(&url, params).unwrap();
14397
14398        loop {
14399            let token = match self
14400                .hub
14401                .auth
14402                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
14403                .await
14404            {
14405                Ok(token) => token.clone(),
14406                Err(err) => match dlg.token(&err) {
14407                    Some(token) => token,
14408                    None => {
14409                        dlg.finished(false);
14410                        return Err(client::Error::MissingToken(err));
14411                    }
14412                },
14413            };
14414            let mut req_result = {
14415                let client = &self.hub.client;
14416                dlg.pre_request();
14417                let mut req_builder = hyper::Request::builder()
14418                    .method(hyper::Method::DELETE)
14419                    .uri(url.clone().into_string())
14420                    .header(USER_AGENT, self.hub._user_agent.clone())
14421                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
14422
14423                let request = req_builder.body(hyper::body::Body::empty());
14424
14425                client.request(request.unwrap()).await
14426            };
14427
14428            match req_result {
14429                Err(err) => {
14430                    if let client::Retry::After(d) = dlg.http_error(&err) {
14431                        sleep(d);
14432                        continue;
14433                    }
14434                    dlg.finished(false);
14435                    return Err(client::Error::HttpError(err));
14436                }
14437                Ok(mut res) => {
14438                    if !res.status().is_success() {
14439                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
14440                        let (parts, _) = res.into_parts();
14441                        let body = hyper::Body::from(res_body_string.clone());
14442                        let restored_response = hyper::Response::from_parts(parts, body);
14443
14444                        let server_response =
14445                            json::from_str::<serde_json::Value>(&res_body_string).ok();
14446
14447                        if let client::Retry::After(d) =
14448                            dlg.http_failure(&restored_response, server_response.clone())
14449                        {
14450                            sleep(d);
14451                            continue;
14452                        }
14453
14454                        dlg.finished(false);
14455
14456                        return match server_response {
14457                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
14458                            None => Err(client::Error::Failure(restored_response)),
14459                        };
14460                    }
14461                    let result_value = res;
14462
14463                    dlg.finished(true);
14464                    return Ok(result_value);
14465                }
14466            }
14467        }
14468    }
14469
14470    /// The ID of the file.
14471    ///
14472    /// Sets the *file id* path property to the given value.
14473    ///
14474    /// Even though the property as already been set when instantiating this call,
14475    /// we provide this method for API completeness.
14476    pub fn file_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> {
14477        self._file_id = new_value.to_string();
14478        self
14479    }
14480    /// The ID of the comment.
14481    ///
14482    /// Sets the *comment id* path property to the given value.
14483    ///
14484    /// Even though the property as already been set when instantiating this call,
14485    /// we provide this method for API completeness.
14486    pub fn comment_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> {
14487        self._comment_id = new_value.to_string();
14488        self
14489    }
14490    /// The ID of the reply.
14491    ///
14492    /// Sets the *reply id* path property to the given value.
14493    ///
14494    /// Even though the property as already been set when instantiating this call,
14495    /// we provide this method for API completeness.
14496    pub fn reply_id(mut self, new_value: &str) -> ReplyDeleteCall<'a, S> {
14497        self._reply_id = new_value.to_string();
14498        self
14499    }
14500    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14501    /// while executing the actual API request.
14502    ///
14503    /// It should be used to handle progress information, and to implement a certain level of resilience.
14504    ///
14505    /// Sets the *delegate* property to the given value.
14506    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyDeleteCall<'a, S> {
14507        self._delegate = Some(new_value);
14508        self
14509    }
14510
14511    /// Set any additional parameter of the query string used in the request.
14512    /// It should be used to set parameters which are not yet available through their own
14513    /// setters.
14514    ///
14515    /// Please note that this method must not be used to set any of the known parameters
14516    /// which have their own setter method. If done anyway, the request will fail.
14517    ///
14518    /// # Additional Parameters
14519    ///
14520    /// * *alt* (query-string) - Data format for the response.
14521    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14522    /// * *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.
14523    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14524    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14525    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14526    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14527    pub fn param<T>(mut self, name: T, value: T) -> ReplyDeleteCall<'a, S>
14528    where
14529        T: AsRef<str>,
14530    {
14531        self._additional_params
14532            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14533        self
14534    }
14535
14536    /// Identifies the authorization scope for the method you are building.
14537    ///
14538    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14539    /// `Scope::Full`.
14540    ///
14541    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14542    /// tokens for more than one scope.
14543    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14544    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14545    /// function for details).
14546    ///
14547    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14548    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14549    /// sufficient, a read-write scope will do as well.
14550    pub fn add_scope<T, St>(mut self, scope: T) -> ReplyDeleteCall<'a, S>
14551    where
14552        T: Into<Option<St>>,
14553        St: AsRef<str>,
14554    {
14555        match scope.into() {
14556            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14557            None => None,
14558        };
14559        self
14560    }
14561}
14562
14563/// Gets a reply by ID.
14564///
14565/// A builder for the *get* method supported by a *reply* resource.
14566/// It is not used directly, but through a `ReplyMethods` instance.
14567///
14568/// # Example
14569///
14570/// Instantiate a resource method builder
14571///
14572/// ```test_harness,no_run
14573/// # extern crate hyper;
14574/// # extern crate hyper_rustls;
14575/// # extern crate google_drive3 as drive3;
14576/// # async fn dox() {
14577/// # use std::default::Default;
14578/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
14579///
14580/// # let secret: oauth2::ApplicationSecret = Default::default();
14581/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
14582/// #         secret,
14583/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14584/// #     ).build().await.unwrap();
14585/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
14586/// // You can configure optional parameters by calling the respective setters at will, and
14587/// // execute the final call using `doit()`.
14588/// // Values shown here are possibly random and not representative !
14589/// let result = hub.replies().get("fileId", "commentId", "replyId")
14590///              .include_deleted(false)
14591///              .doit().await;
14592/// # }
14593/// ```
14594pub struct ReplyGetCall<'a, S>
14595where
14596    S: 'a,
14597{
14598    hub: &'a DriveHub<S>,
14599    _file_id: String,
14600    _comment_id: String,
14601    _reply_id: String,
14602    _include_deleted: Option<bool>,
14603    _delegate: Option<&'a mut dyn client::Delegate>,
14604    _additional_params: HashMap<String, String>,
14605    _scopes: BTreeMap<String, ()>,
14606}
14607
14608impl<'a, S> client::CallBuilder for ReplyGetCall<'a, S> {}
14609
14610impl<'a, S> ReplyGetCall<'a, S>
14611where
14612    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
14613    S::Response:
14614        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
14615    S::Future: Send + Unpin + 'static,
14616    S::Error: Into<Box<dyn StdError + Send + Sync>>,
14617{
14618    /// Perform the operation you have build so far.
14619    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Reply)> {
14620        use client::ToParts;
14621        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14622        use std::io::{Read, Seek};
14623        let mut dd = client::DefaultDelegate;
14624        let mut dlg: &mut dyn client::Delegate = match self._delegate {
14625            Some(d) => d,
14626            None => &mut dd,
14627        };
14628        dlg.begin(client::MethodInfo {
14629            id: "drive.replies.get",
14630            http_method: hyper::Method::GET,
14631        });
14632        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
14633        params.push(("fileId", self._file_id.to_string()));
14634        params.push(("commentId", self._comment_id.to_string()));
14635        params.push(("replyId", self._reply_id.to_string()));
14636        if let Some(value) = self._include_deleted {
14637            params.push(("includeDeleted", value.to_string()));
14638        }
14639        for &field in ["alt", "fileId", "commentId", "replyId", "includeDeleted"].iter() {
14640            if self._additional_params.contains_key(field) {
14641                dlg.finished(false);
14642                return Err(client::Error::FieldClash(field));
14643            }
14644        }
14645        for (name, value) in self._additional_params.iter() {
14646            params.push((&name, value.clone()));
14647        }
14648
14649        params.push(("alt", "json".to_string()));
14650
14651        let mut url =
14652            self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
14653        if self._scopes.len() == 0 {
14654            self._scopes
14655                .insert(Scope::Readonly.as_ref().to_string(), ());
14656        }
14657
14658        for &(find_this, param_name) in [
14659            ("{fileId}", "fileId"),
14660            ("{commentId}", "commentId"),
14661            ("{replyId}", "replyId"),
14662        ]
14663        .iter()
14664        {
14665            let mut replace_with: Option<&str> = None;
14666            for &(name, ref value) in params.iter() {
14667                if name == param_name {
14668                    replace_with = Some(value);
14669                    break;
14670                }
14671            }
14672            url = url.replace(
14673                find_this,
14674                replace_with.expect("to find substitution value in params"),
14675            );
14676        }
14677        {
14678            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
14679            for param_name in ["replyId", "commentId", "fileId"].iter() {
14680                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
14681                    indices_for_removal.push(index);
14682                }
14683            }
14684            for &index in indices_for_removal.iter() {
14685                params.remove(index);
14686            }
14687        }
14688
14689        let url = url::Url::parse_with_params(&url, params).unwrap();
14690
14691        loop {
14692            let token = match self
14693                .hub
14694                .auth
14695                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
14696                .await
14697            {
14698                Ok(token) => token.clone(),
14699                Err(err) => match dlg.token(&err) {
14700                    Some(token) => token,
14701                    None => {
14702                        dlg.finished(false);
14703                        return Err(client::Error::MissingToken(err));
14704                    }
14705                },
14706            };
14707            let mut req_result = {
14708                let client = &self.hub.client;
14709                dlg.pre_request();
14710                let mut req_builder = hyper::Request::builder()
14711                    .method(hyper::Method::GET)
14712                    .uri(url.clone().into_string())
14713                    .header(USER_AGENT, self.hub._user_agent.clone())
14714                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
14715
14716                let request = req_builder.body(hyper::body::Body::empty());
14717
14718                client.request(request.unwrap()).await
14719            };
14720
14721            match req_result {
14722                Err(err) => {
14723                    if let client::Retry::After(d) = dlg.http_error(&err) {
14724                        sleep(d);
14725                        continue;
14726                    }
14727                    dlg.finished(false);
14728                    return Err(client::Error::HttpError(err));
14729                }
14730                Ok(mut res) => {
14731                    if !res.status().is_success() {
14732                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
14733                        let (parts, _) = res.into_parts();
14734                        let body = hyper::Body::from(res_body_string.clone());
14735                        let restored_response = hyper::Response::from_parts(parts, body);
14736
14737                        let server_response =
14738                            json::from_str::<serde_json::Value>(&res_body_string).ok();
14739
14740                        if let client::Retry::After(d) =
14741                            dlg.http_failure(&restored_response, server_response.clone())
14742                        {
14743                            sleep(d);
14744                            continue;
14745                        }
14746
14747                        dlg.finished(false);
14748
14749                        return match server_response {
14750                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
14751                            None => Err(client::Error::Failure(restored_response)),
14752                        };
14753                    }
14754                    let result_value = {
14755                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
14756
14757                        match json::from_str(&res_body_string) {
14758                            Ok(decoded) => (res, decoded),
14759                            Err(err) => {
14760                                dlg.response_json_decode_error(&res_body_string, &err);
14761                                return Err(client::Error::JsonDecodeError(res_body_string, err));
14762                            }
14763                        }
14764                    };
14765
14766                    dlg.finished(true);
14767                    return Ok(result_value);
14768                }
14769            }
14770        }
14771    }
14772
14773    /// The ID of the file.
14774    ///
14775    /// Sets the *file id* path property to the given value.
14776    ///
14777    /// Even though the property as already been set when instantiating this call,
14778    /// we provide this method for API completeness.
14779    pub fn file_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> {
14780        self._file_id = new_value.to_string();
14781        self
14782    }
14783    /// The ID of the comment.
14784    ///
14785    /// Sets the *comment id* path property to the given value.
14786    ///
14787    /// Even though the property as already been set when instantiating this call,
14788    /// we provide this method for API completeness.
14789    pub fn comment_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> {
14790        self._comment_id = new_value.to_string();
14791        self
14792    }
14793    /// The ID of the reply.
14794    ///
14795    /// Sets the *reply id* path property to the given value.
14796    ///
14797    /// Even though the property as already been set when instantiating this call,
14798    /// we provide this method for API completeness.
14799    pub fn reply_id(mut self, new_value: &str) -> ReplyGetCall<'a, S> {
14800        self._reply_id = new_value.to_string();
14801        self
14802    }
14803    /// Whether to return deleted replies. Deleted replies will not include their original content.
14804    ///
14805    /// Sets the *include deleted* query property to the given value.
14806    pub fn include_deleted(mut self, new_value: bool) -> ReplyGetCall<'a, S> {
14807        self._include_deleted = Some(new_value);
14808        self
14809    }
14810    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14811    /// while executing the actual API request.
14812    ///
14813    /// It should be used to handle progress information, and to implement a certain level of resilience.
14814    ///
14815    /// Sets the *delegate* property to the given value.
14816    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyGetCall<'a, S> {
14817        self._delegate = Some(new_value);
14818        self
14819    }
14820
14821    /// Set any additional parameter of the query string used in the request.
14822    /// It should be used to set parameters which are not yet available through their own
14823    /// setters.
14824    ///
14825    /// Please note that this method must not be used to set any of the known parameters
14826    /// which have their own setter method. If done anyway, the request will fail.
14827    ///
14828    /// # Additional Parameters
14829    ///
14830    /// * *alt* (query-string) - Data format for the response.
14831    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14832    /// * *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.
14833    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14834    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14835    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14836    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14837    pub fn param<T>(mut self, name: T, value: T) -> ReplyGetCall<'a, S>
14838    where
14839        T: AsRef<str>,
14840    {
14841        self._additional_params
14842            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14843        self
14844    }
14845
14846    /// Identifies the authorization scope for the method you are building.
14847    ///
14848    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
14849    /// `Scope::Readonly`.
14850    ///
14851    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14852    /// tokens for more than one scope.
14853    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
14854    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
14855    /// function for details).
14856    ///
14857    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14858    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14859    /// sufficient, a read-write scope will do as well.
14860    pub fn add_scope<T, St>(mut self, scope: T) -> ReplyGetCall<'a, S>
14861    where
14862        T: Into<Option<St>>,
14863        St: AsRef<str>,
14864    {
14865        match scope.into() {
14866            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
14867            None => None,
14868        };
14869        self
14870    }
14871}
14872
14873/// Lists a comment's replies.
14874///
14875/// A builder for the *list* method supported by a *reply* resource.
14876/// It is not used directly, but through a `ReplyMethods` instance.
14877///
14878/// # Example
14879///
14880/// Instantiate a resource method builder
14881///
14882/// ```test_harness,no_run
14883/// # extern crate hyper;
14884/// # extern crate hyper_rustls;
14885/// # extern crate google_drive3 as drive3;
14886/// # async fn dox() {
14887/// # use std::default::Default;
14888/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
14889///
14890/// # let secret: oauth2::ApplicationSecret = Default::default();
14891/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
14892/// #         secret,
14893/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14894/// #     ).build().await.unwrap();
14895/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
14896/// // You can configure optional parameters by calling the respective setters at will, and
14897/// // execute the final call using `doit()`.
14898/// // Values shown here are possibly random and not representative !
14899/// let result = hub.replies().list("fileId", "commentId")
14900///              .page_token("accusam")
14901///              .page_size(-39)
14902///              .include_deleted(true)
14903///              .doit().await;
14904/// # }
14905/// ```
14906pub struct ReplyListCall<'a, S>
14907where
14908    S: 'a,
14909{
14910    hub: &'a DriveHub<S>,
14911    _file_id: String,
14912    _comment_id: String,
14913    _page_token: Option<String>,
14914    _page_size: Option<i32>,
14915    _include_deleted: Option<bool>,
14916    _delegate: Option<&'a mut dyn client::Delegate>,
14917    _additional_params: HashMap<String, String>,
14918    _scopes: BTreeMap<String, ()>,
14919}
14920
14921impl<'a, S> client::CallBuilder for ReplyListCall<'a, S> {}
14922
14923impl<'a, S> ReplyListCall<'a, S>
14924where
14925    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
14926    S::Response:
14927        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
14928    S::Future: Send + Unpin + 'static,
14929    S::Error: Into<Box<dyn StdError + Send + Sync>>,
14930{
14931    /// Perform the operation you have build so far.
14932    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ReplyList)> {
14933        use client::ToParts;
14934        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14935        use std::io::{Read, Seek};
14936        let mut dd = client::DefaultDelegate;
14937        let mut dlg: &mut dyn client::Delegate = match self._delegate {
14938            Some(d) => d,
14939            None => &mut dd,
14940        };
14941        dlg.begin(client::MethodInfo {
14942            id: "drive.replies.list",
14943            http_method: hyper::Method::GET,
14944        });
14945        let mut params: Vec<(&str, String)> = Vec::with_capacity(7 + self._additional_params.len());
14946        params.push(("fileId", self._file_id.to_string()));
14947        params.push(("commentId", self._comment_id.to_string()));
14948        if let Some(value) = self._page_token {
14949            params.push(("pageToken", value.to_string()));
14950        }
14951        if let Some(value) = self._page_size {
14952            params.push(("pageSize", value.to_string()));
14953        }
14954        if let Some(value) = self._include_deleted {
14955            params.push(("includeDeleted", value.to_string()));
14956        }
14957        for &field in [
14958            "alt",
14959            "fileId",
14960            "commentId",
14961            "pageToken",
14962            "pageSize",
14963            "includeDeleted",
14964        ]
14965        .iter()
14966        {
14967            if self._additional_params.contains_key(field) {
14968                dlg.finished(false);
14969                return Err(client::Error::FieldClash(field));
14970            }
14971        }
14972        for (name, value) in self._additional_params.iter() {
14973            params.push((&name, value.clone()));
14974        }
14975
14976        params.push(("alt", "json".to_string()));
14977
14978        let mut url = self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies";
14979        if self._scopes.len() == 0 {
14980            self._scopes
14981                .insert(Scope::Readonly.as_ref().to_string(), ());
14982        }
14983
14984        for &(find_this, param_name) in
14985            [("{fileId}", "fileId"), ("{commentId}", "commentId")].iter()
14986        {
14987            let mut replace_with: Option<&str> = None;
14988            for &(name, ref value) in params.iter() {
14989                if name == param_name {
14990                    replace_with = Some(value);
14991                    break;
14992                }
14993            }
14994            url = url.replace(
14995                find_this,
14996                replace_with.expect("to find substitution value in params"),
14997            );
14998        }
14999        {
15000            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15001            for param_name in ["commentId", "fileId"].iter() {
15002                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15003                    indices_for_removal.push(index);
15004                }
15005            }
15006            for &index in indices_for_removal.iter() {
15007                params.remove(index);
15008            }
15009        }
15010
15011        let url = url::Url::parse_with_params(&url, params).unwrap();
15012
15013        loop {
15014            let token = match self
15015                .hub
15016                .auth
15017                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
15018                .await
15019            {
15020                Ok(token) => token.clone(),
15021                Err(err) => match dlg.token(&err) {
15022                    Some(token) => token,
15023                    None => {
15024                        dlg.finished(false);
15025                        return Err(client::Error::MissingToken(err));
15026                    }
15027                },
15028            };
15029            let mut req_result = {
15030                let client = &self.hub.client;
15031                dlg.pre_request();
15032                let mut req_builder = hyper::Request::builder()
15033                    .method(hyper::Method::GET)
15034                    .uri(url.clone().into_string())
15035                    .header(USER_AGENT, self.hub._user_agent.clone())
15036                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
15037
15038                let request = req_builder.body(hyper::body::Body::empty());
15039
15040                client.request(request.unwrap()).await
15041            };
15042
15043            match req_result {
15044                Err(err) => {
15045                    if let client::Retry::After(d) = dlg.http_error(&err) {
15046                        sleep(d);
15047                        continue;
15048                    }
15049                    dlg.finished(false);
15050                    return Err(client::Error::HttpError(err));
15051                }
15052                Ok(mut res) => {
15053                    if !res.status().is_success() {
15054                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15055                        let (parts, _) = res.into_parts();
15056                        let body = hyper::Body::from(res_body_string.clone());
15057                        let restored_response = hyper::Response::from_parts(parts, body);
15058
15059                        let server_response =
15060                            json::from_str::<serde_json::Value>(&res_body_string).ok();
15061
15062                        if let client::Retry::After(d) =
15063                            dlg.http_failure(&restored_response, server_response.clone())
15064                        {
15065                            sleep(d);
15066                            continue;
15067                        }
15068
15069                        dlg.finished(false);
15070
15071                        return match server_response {
15072                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
15073                            None => Err(client::Error::Failure(restored_response)),
15074                        };
15075                    }
15076                    let result_value = {
15077                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15078
15079                        match json::from_str(&res_body_string) {
15080                            Ok(decoded) => (res, decoded),
15081                            Err(err) => {
15082                                dlg.response_json_decode_error(&res_body_string, &err);
15083                                return Err(client::Error::JsonDecodeError(res_body_string, err));
15084                            }
15085                        }
15086                    };
15087
15088                    dlg.finished(true);
15089                    return Ok(result_value);
15090                }
15091            }
15092        }
15093    }
15094
15095    /// The ID of the file.
15096    ///
15097    /// Sets the *file id* path property to the given value.
15098    ///
15099    /// Even though the property as already been set when instantiating this call,
15100    /// we provide this method for API completeness.
15101    pub fn file_id(mut self, new_value: &str) -> ReplyListCall<'a, S> {
15102        self._file_id = new_value.to_string();
15103        self
15104    }
15105    /// The ID of the comment.
15106    ///
15107    /// Sets the *comment id* path property to the given value.
15108    ///
15109    /// Even though the property as already been set when instantiating this call,
15110    /// we provide this method for API completeness.
15111    pub fn comment_id(mut self, new_value: &str) -> ReplyListCall<'a, S> {
15112        self._comment_id = new_value.to_string();
15113        self
15114    }
15115    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
15116    ///
15117    /// Sets the *page token* query property to the given value.
15118    pub fn page_token(mut self, new_value: &str) -> ReplyListCall<'a, S> {
15119        self._page_token = Some(new_value.to_string());
15120        self
15121    }
15122    /// The maximum number of replies to return per page.
15123    ///
15124    /// Sets the *page size* query property to the given value.
15125    pub fn page_size(mut self, new_value: i32) -> ReplyListCall<'a, S> {
15126        self._page_size = Some(new_value);
15127        self
15128    }
15129    /// Whether to include deleted replies. Deleted replies will not include their original content.
15130    ///
15131    /// Sets the *include deleted* query property to the given value.
15132    pub fn include_deleted(mut self, new_value: bool) -> ReplyListCall<'a, S> {
15133        self._include_deleted = Some(new_value);
15134        self
15135    }
15136    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15137    /// while executing the actual API request.
15138    ///
15139    /// It should be used to handle progress information, and to implement a certain level of resilience.
15140    ///
15141    /// Sets the *delegate* property to the given value.
15142    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyListCall<'a, S> {
15143        self._delegate = Some(new_value);
15144        self
15145    }
15146
15147    /// Set any additional parameter of the query string used in the request.
15148    /// It should be used to set parameters which are not yet available through their own
15149    /// setters.
15150    ///
15151    /// Please note that this method must not be used to set any of the known parameters
15152    /// which have their own setter method. If done anyway, the request will fail.
15153    ///
15154    /// # Additional Parameters
15155    ///
15156    /// * *alt* (query-string) - Data format for the response.
15157    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15158    /// * *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.
15159    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15160    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15161    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15162    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15163    pub fn param<T>(mut self, name: T, value: T) -> ReplyListCall<'a, S>
15164    where
15165        T: AsRef<str>,
15166    {
15167        self._additional_params
15168            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15169        self
15170    }
15171
15172    /// Identifies the authorization scope for the method you are building.
15173    ///
15174    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15175    /// `Scope::Readonly`.
15176    ///
15177    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15178    /// tokens for more than one scope.
15179    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15180    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15181    /// function for details).
15182    ///
15183    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15184    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15185    /// sufficient, a read-write scope will do as well.
15186    pub fn add_scope<T, St>(mut self, scope: T) -> ReplyListCall<'a, S>
15187    where
15188        T: Into<Option<St>>,
15189        St: AsRef<str>,
15190    {
15191        match scope.into() {
15192            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15193            None => None,
15194        };
15195        self
15196    }
15197}
15198
15199/// Updates a reply with patch semantics.
15200///
15201/// A builder for the *update* method supported by a *reply* resource.
15202/// It is not used directly, but through a `ReplyMethods` instance.
15203///
15204/// # Example
15205///
15206/// Instantiate a resource method builder
15207///
15208/// ```test_harness,no_run
15209/// # extern crate hyper;
15210/// # extern crate hyper_rustls;
15211/// # extern crate google_drive3 as drive3;
15212/// use drive3::api::Reply;
15213/// # async fn dox() {
15214/// # use std::default::Default;
15215/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
15216///
15217/// # let secret: oauth2::ApplicationSecret = Default::default();
15218/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
15219/// #         secret,
15220/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15221/// #     ).build().await.unwrap();
15222/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
15223/// // As the method needs a request, you would usually fill it with the desired information
15224/// // into the respective structure. Some of the parts shown here might not be applicable !
15225/// // Values shown here are possibly random and not representative !
15226/// let mut req = Reply::default();
15227///
15228/// // You can configure optional parameters by calling the respective setters at will, and
15229/// // execute the final call using `doit()`.
15230/// // Values shown here are possibly random and not representative !
15231/// let result = hub.replies().update(req, "fileId", "commentId", "replyId")
15232///              .doit().await;
15233/// # }
15234/// ```
15235pub struct ReplyUpdateCall<'a, S>
15236where
15237    S: 'a,
15238{
15239    hub: &'a DriveHub<S>,
15240    _request: Reply,
15241    _file_id: String,
15242    _comment_id: String,
15243    _reply_id: String,
15244    _delegate: Option<&'a mut dyn client::Delegate>,
15245    _additional_params: HashMap<String, String>,
15246    _scopes: BTreeMap<String, ()>,
15247}
15248
15249impl<'a, S> client::CallBuilder for ReplyUpdateCall<'a, S> {}
15250
15251impl<'a, S> ReplyUpdateCall<'a, S>
15252where
15253    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
15254    S::Response:
15255        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
15256    S::Future: Send + Unpin + 'static,
15257    S::Error: Into<Box<dyn StdError + Send + Sync>>,
15258{
15259    /// Perform the operation you have build so far.
15260    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Reply)> {
15261        use client::ToParts;
15262        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15263        use std::io::{Read, Seek};
15264        let mut dd = client::DefaultDelegate;
15265        let mut dlg: &mut dyn client::Delegate = match self._delegate {
15266            Some(d) => d,
15267            None => &mut dd,
15268        };
15269        dlg.begin(client::MethodInfo {
15270            id: "drive.replies.update",
15271            http_method: hyper::Method::PATCH,
15272        });
15273        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
15274        params.push(("fileId", self._file_id.to_string()));
15275        params.push(("commentId", self._comment_id.to_string()));
15276        params.push(("replyId", self._reply_id.to_string()));
15277        for &field in ["alt", "fileId", "commentId", "replyId"].iter() {
15278            if self._additional_params.contains_key(field) {
15279                dlg.finished(false);
15280                return Err(client::Error::FieldClash(field));
15281            }
15282        }
15283        for (name, value) in self._additional_params.iter() {
15284            params.push((&name, value.clone()));
15285        }
15286
15287        params.push(("alt", "json".to_string()));
15288
15289        let mut url =
15290            self.hub._base_url.clone() + "files/{fileId}/comments/{commentId}/replies/{replyId}";
15291        if self._scopes.len() == 0 {
15292            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
15293        }
15294
15295        for &(find_this, param_name) in [
15296            ("{fileId}", "fileId"),
15297            ("{commentId}", "commentId"),
15298            ("{replyId}", "replyId"),
15299        ]
15300        .iter()
15301        {
15302            let mut replace_with: Option<&str> = None;
15303            for &(name, ref value) in params.iter() {
15304                if name == param_name {
15305                    replace_with = Some(value);
15306                    break;
15307                }
15308            }
15309            url = url.replace(
15310                find_this,
15311                replace_with.expect("to find substitution value in params"),
15312            );
15313        }
15314        {
15315            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(3);
15316            for param_name in ["replyId", "commentId", "fileId"].iter() {
15317                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15318                    indices_for_removal.push(index);
15319                }
15320            }
15321            for &index in indices_for_removal.iter() {
15322                params.remove(index);
15323            }
15324        }
15325
15326        let url = url::Url::parse_with_params(&url, params).unwrap();
15327
15328        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
15329        let mut request_value_reader = {
15330            let mut value = json::value::to_value(&self._request).expect("serde to work");
15331            client::remove_json_null_values(&mut value);
15332            let mut dst = io::Cursor::new(Vec::with_capacity(128));
15333            json::to_writer(&mut dst, &value).unwrap();
15334            dst
15335        };
15336        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
15337        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
15338
15339        loop {
15340            let token = match self
15341                .hub
15342                .auth
15343                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
15344                .await
15345            {
15346                Ok(token) => token.clone(),
15347                Err(err) => match dlg.token(&err) {
15348                    Some(token) => token,
15349                    None => {
15350                        dlg.finished(false);
15351                        return Err(client::Error::MissingToken(err));
15352                    }
15353                },
15354            };
15355            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
15356            let mut req_result = {
15357                let client = &self.hub.client;
15358                dlg.pre_request();
15359                let mut req_builder = hyper::Request::builder()
15360                    .method(hyper::Method::PATCH)
15361                    .uri(url.clone().into_string())
15362                    .header(USER_AGENT, self.hub._user_agent.clone())
15363                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
15364
15365                let request = req_builder
15366                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
15367                    .header(CONTENT_LENGTH, request_size as u64)
15368                    .body(hyper::body::Body::from(
15369                        request_value_reader.get_ref().clone(),
15370                    ));
15371
15372                client.request(request.unwrap()).await
15373            };
15374
15375            match req_result {
15376                Err(err) => {
15377                    if let client::Retry::After(d) = dlg.http_error(&err) {
15378                        sleep(d);
15379                        continue;
15380                    }
15381                    dlg.finished(false);
15382                    return Err(client::Error::HttpError(err));
15383                }
15384                Ok(mut res) => {
15385                    if !res.status().is_success() {
15386                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15387                        let (parts, _) = res.into_parts();
15388                        let body = hyper::Body::from(res_body_string.clone());
15389                        let restored_response = hyper::Response::from_parts(parts, body);
15390
15391                        let server_response =
15392                            json::from_str::<serde_json::Value>(&res_body_string).ok();
15393
15394                        if let client::Retry::After(d) =
15395                            dlg.http_failure(&restored_response, server_response.clone())
15396                        {
15397                            sleep(d);
15398                            continue;
15399                        }
15400
15401                        dlg.finished(false);
15402
15403                        return match server_response {
15404                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
15405                            None => Err(client::Error::Failure(restored_response)),
15406                        };
15407                    }
15408                    let result_value = {
15409                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15410
15411                        match json::from_str(&res_body_string) {
15412                            Ok(decoded) => (res, decoded),
15413                            Err(err) => {
15414                                dlg.response_json_decode_error(&res_body_string, &err);
15415                                return Err(client::Error::JsonDecodeError(res_body_string, err));
15416                            }
15417                        }
15418                    };
15419
15420                    dlg.finished(true);
15421                    return Ok(result_value);
15422                }
15423            }
15424        }
15425    }
15426
15427    ///
15428    /// Sets the *request* property to the given value.
15429    ///
15430    /// Even though the property as already been set when instantiating this call,
15431    /// we provide this method for API completeness.
15432    pub fn request(mut self, new_value: Reply) -> ReplyUpdateCall<'a, S> {
15433        self._request = new_value;
15434        self
15435    }
15436    /// The ID of the file.
15437    ///
15438    /// Sets the *file id* path property to the given value.
15439    ///
15440    /// Even though the property as already been set when instantiating this call,
15441    /// we provide this method for API completeness.
15442    pub fn file_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> {
15443        self._file_id = new_value.to_string();
15444        self
15445    }
15446    /// The ID of the comment.
15447    ///
15448    /// Sets the *comment id* path property to the given value.
15449    ///
15450    /// Even though the property as already been set when instantiating this call,
15451    /// we provide this method for API completeness.
15452    pub fn comment_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> {
15453        self._comment_id = new_value.to_string();
15454        self
15455    }
15456    /// The ID of the reply.
15457    ///
15458    /// Sets the *reply id* path property to the given value.
15459    ///
15460    /// Even though the property as already been set when instantiating this call,
15461    /// we provide this method for API completeness.
15462    pub fn reply_id(mut self, new_value: &str) -> ReplyUpdateCall<'a, S> {
15463        self._reply_id = new_value.to_string();
15464        self
15465    }
15466    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15467    /// while executing the actual API request.
15468    ///
15469    /// It should be used to handle progress information, and to implement a certain level of resilience.
15470    ///
15471    /// Sets the *delegate* property to the given value.
15472    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ReplyUpdateCall<'a, S> {
15473        self._delegate = Some(new_value);
15474        self
15475    }
15476
15477    /// Set any additional parameter of the query string used in the request.
15478    /// It should be used to set parameters which are not yet available through their own
15479    /// setters.
15480    ///
15481    /// Please note that this method must not be used to set any of the known parameters
15482    /// which have their own setter method. If done anyway, the request will fail.
15483    ///
15484    /// # Additional Parameters
15485    ///
15486    /// * *alt* (query-string) - Data format for the response.
15487    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15488    /// * *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.
15489    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15490    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15491    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15492    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15493    pub fn param<T>(mut self, name: T, value: T) -> ReplyUpdateCall<'a, S>
15494    where
15495        T: AsRef<str>,
15496    {
15497        self._additional_params
15498            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15499        self
15500    }
15501
15502    /// Identifies the authorization scope for the method you are building.
15503    ///
15504    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15505    /// `Scope::Full`.
15506    ///
15507    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15508    /// tokens for more than one scope.
15509    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15510    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15511    /// function for details).
15512    ///
15513    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15514    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15515    /// sufficient, a read-write scope will do as well.
15516    pub fn add_scope<T, St>(mut self, scope: T) -> ReplyUpdateCall<'a, S>
15517    where
15518        T: Into<Option<St>>,
15519        St: AsRef<str>,
15520    {
15521        match scope.into() {
15522            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15523            None => None,
15524        };
15525        self
15526    }
15527}
15528
15529/// Permanently deletes a file version. You can only delete revisions for files with binary content in Google Drive, like images or videos. Revisions for other files, like Google Docs or Sheets, and the last remaining file version can't be deleted.
15530///
15531/// A builder for the *delete* method supported by a *revision* resource.
15532/// It is not used directly, but through a `RevisionMethods` instance.
15533///
15534/// # Example
15535///
15536/// Instantiate a resource method builder
15537///
15538/// ```test_harness,no_run
15539/// # extern crate hyper;
15540/// # extern crate hyper_rustls;
15541/// # extern crate google_drive3 as drive3;
15542/// # async fn dox() {
15543/// # use std::default::Default;
15544/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
15545///
15546/// # let secret: oauth2::ApplicationSecret = Default::default();
15547/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
15548/// #         secret,
15549/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15550/// #     ).build().await.unwrap();
15551/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
15552/// // You can configure optional parameters by calling the respective setters at will, and
15553/// // execute the final call using `doit()`.
15554/// // Values shown here are possibly random and not representative !
15555/// let result = hub.revisions().delete("fileId", "revisionId")
15556///              .doit().await;
15557/// # }
15558/// ```
15559pub struct RevisionDeleteCall<'a, S>
15560where
15561    S: 'a,
15562{
15563    hub: &'a DriveHub<S>,
15564    _file_id: String,
15565    _revision_id: String,
15566    _delegate: Option<&'a mut dyn client::Delegate>,
15567    _additional_params: HashMap<String, String>,
15568    _scopes: BTreeMap<String, ()>,
15569}
15570
15571impl<'a, S> client::CallBuilder for RevisionDeleteCall<'a, S> {}
15572
15573impl<'a, S> RevisionDeleteCall<'a, S>
15574where
15575    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
15576    S::Response:
15577        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
15578    S::Future: Send + Unpin + 'static,
15579    S::Error: Into<Box<dyn StdError + Send + Sync>>,
15580{
15581    /// Perform the operation you have build so far.
15582    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
15583        use client::ToParts;
15584        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15585        use std::io::{Read, Seek};
15586        let mut dd = client::DefaultDelegate;
15587        let mut dlg: &mut dyn client::Delegate = match self._delegate {
15588            Some(d) => d,
15589            None => &mut dd,
15590        };
15591        dlg.begin(client::MethodInfo {
15592            id: "drive.revisions.delete",
15593            http_method: hyper::Method::DELETE,
15594        });
15595        let mut params: Vec<(&str, String)> = Vec::with_capacity(3 + self._additional_params.len());
15596        params.push(("fileId", self._file_id.to_string()));
15597        params.push(("revisionId", self._revision_id.to_string()));
15598        for &field in ["fileId", "revisionId"].iter() {
15599            if self._additional_params.contains_key(field) {
15600                dlg.finished(false);
15601                return Err(client::Error::FieldClash(field));
15602            }
15603        }
15604        for (name, value) in self._additional_params.iter() {
15605            params.push((&name, value.clone()));
15606        }
15607
15608        let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
15609        if self._scopes.len() == 0 {
15610            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
15611        }
15612
15613        for &(find_this, param_name) in
15614            [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
15615        {
15616            let mut replace_with: Option<&str> = None;
15617            for &(name, ref value) in params.iter() {
15618                if name == param_name {
15619                    replace_with = Some(value);
15620                    break;
15621                }
15622            }
15623            url = url.replace(
15624                find_this,
15625                replace_with.expect("to find substitution value in params"),
15626            );
15627        }
15628        {
15629            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15630            for param_name in ["revisionId", "fileId"].iter() {
15631                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15632                    indices_for_removal.push(index);
15633                }
15634            }
15635            for &index in indices_for_removal.iter() {
15636                params.remove(index);
15637            }
15638        }
15639
15640        let url = url::Url::parse_with_params(&url, params).unwrap();
15641
15642        loop {
15643            let token = match self
15644                .hub
15645                .auth
15646                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
15647                .await
15648            {
15649                Ok(token) => token.clone(),
15650                Err(err) => match dlg.token(&err) {
15651                    Some(token) => token,
15652                    None => {
15653                        dlg.finished(false);
15654                        return Err(client::Error::MissingToken(err));
15655                    }
15656                },
15657            };
15658            let mut req_result = {
15659                let client = &self.hub.client;
15660                dlg.pre_request();
15661                let mut req_builder = hyper::Request::builder()
15662                    .method(hyper::Method::DELETE)
15663                    .uri(url.clone().into_string())
15664                    .header(USER_AGENT, self.hub._user_agent.clone())
15665                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
15666
15667                let request = req_builder.body(hyper::body::Body::empty());
15668
15669                client.request(request.unwrap()).await
15670            };
15671
15672            match req_result {
15673                Err(err) => {
15674                    if let client::Retry::After(d) = dlg.http_error(&err) {
15675                        sleep(d);
15676                        continue;
15677                    }
15678                    dlg.finished(false);
15679                    return Err(client::Error::HttpError(err));
15680                }
15681                Ok(mut res) => {
15682                    if !res.status().is_success() {
15683                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15684                        let (parts, _) = res.into_parts();
15685                        let body = hyper::Body::from(res_body_string.clone());
15686                        let restored_response = hyper::Response::from_parts(parts, body);
15687
15688                        let server_response =
15689                            json::from_str::<serde_json::Value>(&res_body_string).ok();
15690
15691                        if let client::Retry::After(d) =
15692                            dlg.http_failure(&restored_response, server_response.clone())
15693                        {
15694                            sleep(d);
15695                            continue;
15696                        }
15697
15698                        dlg.finished(false);
15699
15700                        return match server_response {
15701                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
15702                            None => Err(client::Error::Failure(restored_response)),
15703                        };
15704                    }
15705                    let result_value = res;
15706
15707                    dlg.finished(true);
15708                    return Ok(result_value);
15709                }
15710            }
15711        }
15712    }
15713
15714    /// The ID of the file.
15715    ///
15716    /// Sets the *file id* path property to the given value.
15717    ///
15718    /// Even though the property as already been set when instantiating this call,
15719    /// we provide this method for API completeness.
15720    pub fn file_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, S> {
15721        self._file_id = new_value.to_string();
15722        self
15723    }
15724    /// The ID of the revision.
15725    ///
15726    /// Sets the *revision id* path property to the given value.
15727    ///
15728    /// Even though the property as already been set when instantiating this call,
15729    /// we provide this method for API completeness.
15730    pub fn revision_id(mut self, new_value: &str) -> RevisionDeleteCall<'a, S> {
15731        self._revision_id = new_value.to_string();
15732        self
15733    }
15734    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15735    /// while executing the actual API request.
15736    ///
15737    /// It should be used to handle progress information, and to implement a certain level of resilience.
15738    ///
15739    /// Sets the *delegate* property to the given value.
15740    pub fn delegate(
15741        mut self,
15742        new_value: &'a mut dyn client::Delegate,
15743    ) -> RevisionDeleteCall<'a, S> {
15744        self._delegate = Some(new_value);
15745        self
15746    }
15747
15748    /// Set any additional parameter of the query string used in the request.
15749    /// It should be used to set parameters which are not yet available through their own
15750    /// setters.
15751    ///
15752    /// Please note that this method must not be used to set any of the known parameters
15753    /// which have their own setter method. If done anyway, the request will fail.
15754    ///
15755    /// # Additional Parameters
15756    ///
15757    /// * *alt* (query-string) - Data format for the response.
15758    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15759    /// * *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.
15760    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15761    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15762    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15763    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15764    pub fn param<T>(mut self, name: T, value: T) -> RevisionDeleteCall<'a, S>
15765    where
15766        T: AsRef<str>,
15767    {
15768        self._additional_params
15769            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15770        self
15771    }
15772
15773    /// Identifies the authorization scope for the method you are building.
15774    ///
15775    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
15776    /// `Scope::Full`.
15777    ///
15778    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15779    /// tokens for more than one scope.
15780    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
15781    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
15782    /// function for details).
15783    ///
15784    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15785    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15786    /// sufficient, a read-write scope will do as well.
15787    pub fn add_scope<T, St>(mut self, scope: T) -> RevisionDeleteCall<'a, S>
15788    where
15789        T: Into<Option<St>>,
15790        St: AsRef<str>,
15791    {
15792        match scope.into() {
15793            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
15794            None => None,
15795        };
15796        self
15797    }
15798}
15799
15800/// Gets a revision's metadata or content by ID.
15801///
15802/// This method supports **media download**. To enable it, adjust the builder like this:
15803/// `.param("alt", "media")`.
15804/// Please note that due to missing multi-part support on the server side, you will only receive the media,
15805/// but not the `Revision` structure that you would usually get. The latter will be a default value.
15806///
15807/// A builder for the *get* method supported by a *revision* resource.
15808/// It is not used directly, but through a `RevisionMethods` instance.
15809///
15810/// # Example
15811///
15812/// Instantiate a resource method builder
15813///
15814/// ```test_harness,no_run
15815/// # extern crate hyper;
15816/// # extern crate hyper_rustls;
15817/// # extern crate google_drive3 as drive3;
15818/// # async fn dox() {
15819/// # use std::default::Default;
15820/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
15821///
15822/// # let secret: oauth2::ApplicationSecret = Default::default();
15823/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
15824/// #         secret,
15825/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15826/// #     ).build().await.unwrap();
15827/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
15828/// // You can configure optional parameters by calling the respective setters at will, and
15829/// // execute the final call using `doit()`.
15830/// // Values shown here are possibly random and not representative !
15831/// let result = hub.revisions().get("fileId", "revisionId")
15832///              .acknowledge_abuse(false)
15833///              .doit().await;
15834/// # }
15835/// ```
15836pub struct RevisionGetCall<'a, S>
15837where
15838    S: 'a,
15839{
15840    hub: &'a DriveHub<S>,
15841    _file_id: String,
15842    _revision_id: String,
15843    _acknowledge_abuse: Option<bool>,
15844    _delegate: Option<&'a mut dyn client::Delegate>,
15845    _additional_params: HashMap<String, String>,
15846    _scopes: BTreeMap<String, ()>,
15847}
15848
15849impl<'a, S> client::CallBuilder for RevisionGetCall<'a, S> {}
15850
15851impl<'a, S> RevisionGetCall<'a, S>
15852where
15853    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
15854    S::Response:
15855        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
15856    S::Future: Send + Unpin + 'static,
15857    S::Error: Into<Box<dyn StdError + Send + Sync>>,
15858{
15859    /// Perform the operation you have build so far.
15860    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Revision)> {
15861        use client::ToParts;
15862        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15863        use std::io::{Read, Seek};
15864        let mut dd = client::DefaultDelegate;
15865        let mut dlg: &mut dyn client::Delegate = match self._delegate {
15866            Some(d) => d,
15867            None => &mut dd,
15868        };
15869        dlg.begin(client::MethodInfo {
15870            id: "drive.revisions.get",
15871            http_method: hyper::Method::GET,
15872        });
15873        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
15874        params.push(("fileId", self._file_id.to_string()));
15875        params.push(("revisionId", self._revision_id.to_string()));
15876        if let Some(value) = self._acknowledge_abuse {
15877            params.push(("acknowledgeAbuse", value.to_string()));
15878        }
15879        for &field in ["fileId", "revisionId", "acknowledgeAbuse"].iter() {
15880            if self._additional_params.contains_key(field) {
15881                dlg.finished(false);
15882                return Err(client::Error::FieldClash(field));
15883            }
15884        }
15885        for (name, value) in self._additional_params.iter() {
15886            params.push((&name, value.clone()));
15887        }
15888
15889        let (json_field_missing, enable_resource_parsing) = {
15890            let mut enable = true;
15891            let mut field_present = true;
15892            for &(name, ref value) in params.iter() {
15893                if name == "alt" {
15894                    field_present = false;
15895                    if <String as AsRef<str>>::as_ref(&value) != "json" {
15896                        enable = false;
15897                    }
15898                    break;
15899                }
15900            }
15901            (field_present, enable)
15902        };
15903        if json_field_missing {
15904            params.push(("alt", "json".to_string()));
15905        }
15906
15907        let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
15908        if self._scopes.len() == 0 {
15909            self._scopes
15910                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
15911        }
15912
15913        for &(find_this, param_name) in
15914            [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
15915        {
15916            let mut replace_with: Option<&str> = None;
15917            for &(name, ref value) in params.iter() {
15918                if name == param_name {
15919                    replace_with = Some(value);
15920                    break;
15921                }
15922            }
15923            url = url.replace(
15924                find_this,
15925                replace_with.expect("to find substitution value in params"),
15926            );
15927        }
15928        {
15929            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
15930            for param_name in ["revisionId", "fileId"].iter() {
15931                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
15932                    indices_for_removal.push(index);
15933                }
15934            }
15935            for &index in indices_for_removal.iter() {
15936                params.remove(index);
15937            }
15938        }
15939
15940        let url = url::Url::parse_with_params(&url, params).unwrap();
15941
15942        loop {
15943            let token = match self
15944                .hub
15945                .auth
15946                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
15947                .await
15948            {
15949                Ok(token) => token.clone(),
15950                Err(err) => match dlg.token(&err) {
15951                    Some(token) => token,
15952                    None => {
15953                        dlg.finished(false);
15954                        return Err(client::Error::MissingToken(err));
15955                    }
15956                },
15957            };
15958            let mut req_result = {
15959                let client = &self.hub.client;
15960                dlg.pre_request();
15961                let mut req_builder = hyper::Request::builder()
15962                    .method(hyper::Method::GET)
15963                    .uri(url.clone().into_string())
15964                    .header(USER_AGENT, self.hub._user_agent.clone())
15965                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
15966
15967                let request = req_builder.body(hyper::body::Body::empty());
15968
15969                client.request(request.unwrap()).await
15970            };
15971
15972            match req_result {
15973                Err(err) => {
15974                    if let client::Retry::After(d) = dlg.http_error(&err) {
15975                        sleep(d);
15976                        continue;
15977                    }
15978                    dlg.finished(false);
15979                    return Err(client::Error::HttpError(err));
15980                }
15981                Ok(mut res) => {
15982                    if !res.status().is_success() {
15983                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
15984                        let (parts, _) = res.into_parts();
15985                        let body = hyper::Body::from(res_body_string.clone());
15986                        let restored_response = hyper::Response::from_parts(parts, body);
15987
15988                        let server_response =
15989                            json::from_str::<serde_json::Value>(&res_body_string).ok();
15990
15991                        if let client::Retry::After(d) =
15992                            dlg.http_failure(&restored_response, server_response.clone())
15993                        {
15994                            sleep(d);
15995                            continue;
15996                        }
15997
15998                        dlg.finished(false);
15999
16000                        return match server_response {
16001                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
16002                            None => Err(client::Error::Failure(restored_response)),
16003                        };
16004                    }
16005                    let result_value = if enable_resource_parsing {
16006                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16007
16008                        match json::from_str(&res_body_string) {
16009                            Ok(decoded) => (res, decoded),
16010                            Err(err) => {
16011                                dlg.response_json_decode_error(&res_body_string, &err);
16012                                return Err(client::Error::JsonDecodeError(res_body_string, err));
16013                            }
16014                        }
16015                    } else {
16016                        (res, Default::default())
16017                    };
16018
16019                    dlg.finished(true);
16020                    return Ok(result_value);
16021                }
16022            }
16023        }
16024    }
16025
16026    /// The ID of the file.
16027    ///
16028    /// Sets the *file id* path property to the given value.
16029    ///
16030    /// Even though the property as already been set when instantiating this call,
16031    /// we provide this method for API completeness.
16032    pub fn file_id(mut self, new_value: &str) -> RevisionGetCall<'a, S> {
16033        self._file_id = new_value.to_string();
16034        self
16035    }
16036    /// The ID of the revision.
16037    ///
16038    /// Sets the *revision id* path property to the given value.
16039    ///
16040    /// Even though the property as already been set when instantiating this call,
16041    /// we provide this method for API completeness.
16042    pub fn revision_id(mut self, new_value: &str) -> RevisionGetCall<'a, S> {
16043        self._revision_id = new_value.to_string();
16044        self
16045    }
16046    /// Whether the user is acknowledging the risk of downloading known malware or other abusive files. This is only applicable when alt=media.
16047    ///
16048    /// Sets the *acknowledge abuse* query property to the given value.
16049    pub fn acknowledge_abuse(mut self, new_value: bool) -> RevisionGetCall<'a, S> {
16050        self._acknowledge_abuse = Some(new_value);
16051        self
16052    }
16053    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16054    /// while executing the actual API request.
16055    ///
16056    /// It should be used to handle progress information, and to implement a certain level of resilience.
16057    ///
16058    /// Sets the *delegate* property to the given value.
16059    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionGetCall<'a, S> {
16060        self._delegate = Some(new_value);
16061        self
16062    }
16063
16064    /// Set any additional parameter of the query string used in the request.
16065    /// It should be used to set parameters which are not yet available through their own
16066    /// setters.
16067    ///
16068    /// Please note that this method must not be used to set any of the known parameters
16069    /// which have their own setter method. If done anyway, the request will fail.
16070    ///
16071    /// # Additional Parameters
16072    ///
16073    /// * *alt* (query-string) - Data format for the response.
16074    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16075    /// * *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.
16076    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16077    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16078    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16079    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16080    pub fn param<T>(mut self, name: T, value: T) -> RevisionGetCall<'a, S>
16081    where
16082        T: AsRef<str>,
16083    {
16084        self._additional_params
16085            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16086        self
16087    }
16088
16089    /// Identifies the authorization scope for the method you are building.
16090    ///
16091    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16092    /// `Scope::MetadataReadonly`.
16093    ///
16094    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16095    /// tokens for more than one scope.
16096    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16097    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16098    /// function for details).
16099    ///
16100    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16101    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16102    /// sufficient, a read-write scope will do as well.
16103    pub fn add_scope<T, St>(mut self, scope: T) -> RevisionGetCall<'a, S>
16104    where
16105        T: Into<Option<St>>,
16106        St: AsRef<str>,
16107    {
16108        match scope.into() {
16109            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16110            None => None,
16111        };
16112        self
16113    }
16114}
16115
16116/// Lists a file's revisions.
16117///
16118/// A builder for the *list* method supported by a *revision* resource.
16119/// It is not used directly, but through a `RevisionMethods` instance.
16120///
16121/// # Example
16122///
16123/// Instantiate a resource method builder
16124///
16125/// ```test_harness,no_run
16126/// # extern crate hyper;
16127/// # extern crate hyper_rustls;
16128/// # extern crate google_drive3 as drive3;
16129/// # async fn dox() {
16130/// # use std::default::Default;
16131/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
16132///
16133/// # let secret: oauth2::ApplicationSecret = Default::default();
16134/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
16135/// #         secret,
16136/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16137/// #     ).build().await.unwrap();
16138/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
16139/// // You can configure optional parameters by calling the respective setters at will, and
16140/// // execute the final call using `doit()`.
16141/// // Values shown here are possibly random and not representative !
16142/// let result = hub.revisions().list("fileId")
16143///              .page_token("consetetur")
16144///              .page_size(-11)
16145///              .doit().await;
16146/// # }
16147/// ```
16148pub struct RevisionListCall<'a, S>
16149where
16150    S: 'a,
16151{
16152    hub: &'a DriveHub<S>,
16153    _file_id: String,
16154    _page_token: Option<String>,
16155    _page_size: Option<i32>,
16156    _delegate: Option<&'a mut dyn client::Delegate>,
16157    _additional_params: HashMap<String, String>,
16158    _scopes: BTreeMap<String, ()>,
16159}
16160
16161impl<'a, S> client::CallBuilder for RevisionListCall<'a, S> {}
16162
16163impl<'a, S> RevisionListCall<'a, S>
16164where
16165    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
16166    S::Response:
16167        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
16168    S::Future: Send + Unpin + 'static,
16169    S::Error: Into<Box<dyn StdError + Send + Sync>>,
16170{
16171    /// Perform the operation you have build so far.
16172    pub async fn doit(
16173        mut self,
16174    ) -> client::Result<(hyper::Response<hyper::body::Body>, RevisionList)> {
16175        use client::ToParts;
16176        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16177        use std::io::{Read, Seek};
16178        let mut dd = client::DefaultDelegate;
16179        let mut dlg: &mut dyn client::Delegate = match self._delegate {
16180            Some(d) => d,
16181            None => &mut dd,
16182        };
16183        dlg.begin(client::MethodInfo {
16184            id: "drive.revisions.list",
16185            http_method: hyper::Method::GET,
16186        });
16187        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
16188        params.push(("fileId", self._file_id.to_string()));
16189        if let Some(value) = self._page_token {
16190            params.push(("pageToken", value.to_string()));
16191        }
16192        if let Some(value) = self._page_size {
16193            params.push(("pageSize", value.to_string()));
16194        }
16195        for &field in ["alt", "fileId", "pageToken", "pageSize"].iter() {
16196            if self._additional_params.contains_key(field) {
16197                dlg.finished(false);
16198                return Err(client::Error::FieldClash(field));
16199            }
16200        }
16201        for (name, value) in self._additional_params.iter() {
16202            params.push((&name, value.clone()));
16203        }
16204
16205        params.push(("alt", "json".to_string()));
16206
16207        let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions";
16208        if self._scopes.len() == 0 {
16209            self._scopes
16210                .insert(Scope::MetadataReadonly.as_ref().to_string(), ());
16211        }
16212
16213        for &(find_this, param_name) in [("{fileId}", "fileId")].iter() {
16214            let mut replace_with: Option<&str> = None;
16215            for &(name, ref value) in params.iter() {
16216                if name == param_name {
16217                    replace_with = Some(value);
16218                    break;
16219                }
16220            }
16221            url = url.replace(
16222                find_this,
16223                replace_with.expect("to find substitution value in params"),
16224            );
16225        }
16226        {
16227            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
16228            for param_name in ["fileId"].iter() {
16229                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
16230                    indices_for_removal.push(index);
16231                }
16232            }
16233            for &index in indices_for_removal.iter() {
16234                params.remove(index);
16235            }
16236        }
16237
16238        let url = url::Url::parse_with_params(&url, params).unwrap();
16239
16240        loop {
16241            let token = match self
16242                .hub
16243                .auth
16244                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
16245                .await
16246            {
16247                Ok(token) => token.clone(),
16248                Err(err) => match dlg.token(&err) {
16249                    Some(token) => token,
16250                    None => {
16251                        dlg.finished(false);
16252                        return Err(client::Error::MissingToken(err));
16253                    }
16254                },
16255            };
16256            let mut req_result = {
16257                let client = &self.hub.client;
16258                dlg.pre_request();
16259                let mut req_builder = hyper::Request::builder()
16260                    .method(hyper::Method::GET)
16261                    .uri(url.clone().into_string())
16262                    .header(USER_AGENT, self.hub._user_agent.clone())
16263                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
16264
16265                let request = req_builder.body(hyper::body::Body::empty());
16266
16267                client.request(request.unwrap()).await
16268            };
16269
16270            match req_result {
16271                Err(err) => {
16272                    if let client::Retry::After(d) = dlg.http_error(&err) {
16273                        sleep(d);
16274                        continue;
16275                    }
16276                    dlg.finished(false);
16277                    return Err(client::Error::HttpError(err));
16278                }
16279                Ok(mut res) => {
16280                    if !res.status().is_success() {
16281                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16282                        let (parts, _) = res.into_parts();
16283                        let body = hyper::Body::from(res_body_string.clone());
16284                        let restored_response = hyper::Response::from_parts(parts, body);
16285
16286                        let server_response =
16287                            json::from_str::<serde_json::Value>(&res_body_string).ok();
16288
16289                        if let client::Retry::After(d) =
16290                            dlg.http_failure(&restored_response, server_response.clone())
16291                        {
16292                            sleep(d);
16293                            continue;
16294                        }
16295
16296                        dlg.finished(false);
16297
16298                        return match server_response {
16299                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
16300                            None => Err(client::Error::Failure(restored_response)),
16301                        };
16302                    }
16303                    let result_value = {
16304                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16305
16306                        match json::from_str(&res_body_string) {
16307                            Ok(decoded) => (res, decoded),
16308                            Err(err) => {
16309                                dlg.response_json_decode_error(&res_body_string, &err);
16310                                return Err(client::Error::JsonDecodeError(res_body_string, err));
16311                            }
16312                        }
16313                    };
16314
16315                    dlg.finished(true);
16316                    return Ok(result_value);
16317                }
16318            }
16319        }
16320    }
16321
16322    /// The ID of the file.
16323    ///
16324    /// Sets the *file id* path property to the given value.
16325    ///
16326    /// Even though the property as already been set when instantiating this call,
16327    /// we provide this method for API completeness.
16328    pub fn file_id(mut self, new_value: &str) -> RevisionListCall<'a, S> {
16329        self._file_id = new_value.to_string();
16330        self
16331    }
16332    /// The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response.
16333    ///
16334    /// Sets the *page token* query property to the given value.
16335    pub fn page_token(mut self, new_value: &str) -> RevisionListCall<'a, S> {
16336        self._page_token = Some(new_value.to_string());
16337        self
16338    }
16339    /// The maximum number of revisions to return per page.
16340    ///
16341    /// Sets the *page size* query property to the given value.
16342    pub fn page_size(mut self, new_value: i32) -> RevisionListCall<'a, S> {
16343        self._page_size = Some(new_value);
16344        self
16345    }
16346    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16347    /// while executing the actual API request.
16348    ///
16349    /// It should be used to handle progress information, and to implement a certain level of resilience.
16350    ///
16351    /// Sets the *delegate* property to the given value.
16352    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> RevisionListCall<'a, S> {
16353        self._delegate = Some(new_value);
16354        self
16355    }
16356
16357    /// Set any additional parameter of the query string used in the request.
16358    /// It should be used to set parameters which are not yet available through their own
16359    /// setters.
16360    ///
16361    /// Please note that this method must not be used to set any of the known parameters
16362    /// which have their own setter method. If done anyway, the request will fail.
16363    ///
16364    /// # Additional Parameters
16365    ///
16366    /// * *alt* (query-string) - Data format for the response.
16367    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16368    /// * *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.
16369    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16370    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16371    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16372    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16373    pub fn param<T>(mut self, name: T, value: T) -> RevisionListCall<'a, S>
16374    where
16375        T: AsRef<str>,
16376    {
16377        self._additional_params
16378            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16379        self
16380    }
16381
16382    /// Identifies the authorization scope for the method you are building.
16383    ///
16384    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16385    /// `Scope::MetadataReadonly`.
16386    ///
16387    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16388    /// tokens for more than one scope.
16389    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16390    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16391    /// function for details).
16392    ///
16393    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16394    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16395    /// sufficient, a read-write scope will do as well.
16396    pub fn add_scope<T, St>(mut self, scope: T) -> RevisionListCall<'a, S>
16397    where
16398        T: Into<Option<St>>,
16399        St: AsRef<str>,
16400    {
16401        match scope.into() {
16402            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16403            None => None,
16404        };
16405        self
16406    }
16407}
16408
16409/// Updates a revision with patch semantics.
16410///
16411/// A builder for the *update* method supported by a *revision* resource.
16412/// It is not used directly, but through a `RevisionMethods` instance.
16413///
16414/// # Example
16415///
16416/// Instantiate a resource method builder
16417///
16418/// ```test_harness,no_run
16419/// # extern crate hyper;
16420/// # extern crate hyper_rustls;
16421/// # extern crate google_drive3 as drive3;
16422/// use drive3::api::Revision;
16423/// # async fn dox() {
16424/// # use std::default::Default;
16425/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
16426///
16427/// # let secret: oauth2::ApplicationSecret = Default::default();
16428/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
16429/// #         secret,
16430/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16431/// #     ).build().await.unwrap();
16432/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
16433/// // As the method needs a request, you would usually fill it with the desired information
16434/// // into the respective structure. Some of the parts shown here might not be applicable !
16435/// // Values shown here are possibly random and not representative !
16436/// let mut req = Revision::default();
16437///
16438/// // You can configure optional parameters by calling the respective setters at will, and
16439/// // execute the final call using `doit()`.
16440/// // Values shown here are possibly random and not representative !
16441/// let result = hub.revisions().update(req, "fileId", "revisionId")
16442///              .doit().await;
16443/// # }
16444/// ```
16445pub struct RevisionUpdateCall<'a, S>
16446where
16447    S: 'a,
16448{
16449    hub: &'a DriveHub<S>,
16450    _request: Revision,
16451    _file_id: String,
16452    _revision_id: String,
16453    _delegate: Option<&'a mut dyn client::Delegate>,
16454    _additional_params: HashMap<String, String>,
16455    _scopes: BTreeMap<String, ()>,
16456}
16457
16458impl<'a, S> client::CallBuilder for RevisionUpdateCall<'a, S> {}
16459
16460impl<'a, S> RevisionUpdateCall<'a, S>
16461where
16462    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
16463    S::Response:
16464        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
16465    S::Future: Send + Unpin + 'static,
16466    S::Error: Into<Box<dyn StdError + Send + Sync>>,
16467{
16468    /// Perform the operation you have build so far.
16469    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Revision)> {
16470        use client::ToParts;
16471        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16472        use std::io::{Read, Seek};
16473        let mut dd = client::DefaultDelegate;
16474        let mut dlg: &mut dyn client::Delegate = match self._delegate {
16475            Some(d) => d,
16476            None => &mut dd,
16477        };
16478        dlg.begin(client::MethodInfo {
16479            id: "drive.revisions.update",
16480            http_method: hyper::Method::PATCH,
16481        });
16482        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
16483        params.push(("fileId", self._file_id.to_string()));
16484        params.push(("revisionId", self._revision_id.to_string()));
16485        for &field in ["alt", "fileId", "revisionId"].iter() {
16486            if self._additional_params.contains_key(field) {
16487                dlg.finished(false);
16488                return Err(client::Error::FieldClash(field));
16489            }
16490        }
16491        for (name, value) in self._additional_params.iter() {
16492            params.push((&name, value.clone()));
16493        }
16494
16495        params.push(("alt", "json".to_string()));
16496
16497        let mut url = self.hub._base_url.clone() + "files/{fileId}/revisions/{revisionId}";
16498        if self._scopes.len() == 0 {
16499            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
16500        }
16501
16502        for &(find_this, param_name) in
16503            [("{fileId}", "fileId"), ("{revisionId}", "revisionId")].iter()
16504        {
16505            let mut replace_with: Option<&str> = None;
16506            for &(name, ref value) in params.iter() {
16507                if name == param_name {
16508                    replace_with = Some(value);
16509                    break;
16510                }
16511            }
16512            url = url.replace(
16513                find_this,
16514                replace_with.expect("to find substitution value in params"),
16515            );
16516        }
16517        {
16518            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(2);
16519            for param_name in ["revisionId", "fileId"].iter() {
16520                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
16521                    indices_for_removal.push(index);
16522                }
16523            }
16524            for &index in indices_for_removal.iter() {
16525                params.remove(index);
16526            }
16527        }
16528
16529        let url = url::Url::parse_with_params(&url, params).unwrap();
16530
16531        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
16532        let mut request_value_reader = {
16533            let mut value = json::value::to_value(&self._request).expect("serde to work");
16534            client::remove_json_null_values(&mut value);
16535            let mut dst = io::Cursor::new(Vec::with_capacity(128));
16536            json::to_writer(&mut dst, &value).unwrap();
16537            dst
16538        };
16539        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
16540        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16541
16542        loop {
16543            let token = match self
16544                .hub
16545                .auth
16546                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
16547                .await
16548            {
16549                Ok(token) => token.clone(),
16550                Err(err) => match dlg.token(&err) {
16551                    Some(token) => token,
16552                    None => {
16553                        dlg.finished(false);
16554                        return Err(client::Error::MissingToken(err));
16555                    }
16556                },
16557            };
16558            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16559            let mut req_result = {
16560                let client = &self.hub.client;
16561                dlg.pre_request();
16562                let mut req_builder = hyper::Request::builder()
16563                    .method(hyper::Method::PATCH)
16564                    .uri(url.clone().into_string())
16565                    .header(USER_AGENT, self.hub._user_agent.clone())
16566                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
16567
16568                let request = req_builder
16569                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
16570                    .header(CONTENT_LENGTH, request_size as u64)
16571                    .body(hyper::body::Body::from(
16572                        request_value_reader.get_ref().clone(),
16573                    ));
16574
16575                client.request(request.unwrap()).await
16576            };
16577
16578            match req_result {
16579                Err(err) => {
16580                    if let client::Retry::After(d) = dlg.http_error(&err) {
16581                        sleep(d);
16582                        continue;
16583                    }
16584                    dlg.finished(false);
16585                    return Err(client::Error::HttpError(err));
16586                }
16587                Ok(mut res) => {
16588                    if !res.status().is_success() {
16589                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16590                        let (parts, _) = res.into_parts();
16591                        let body = hyper::Body::from(res_body_string.clone());
16592                        let restored_response = hyper::Response::from_parts(parts, body);
16593
16594                        let server_response =
16595                            json::from_str::<serde_json::Value>(&res_body_string).ok();
16596
16597                        if let client::Retry::After(d) =
16598                            dlg.http_failure(&restored_response, server_response.clone())
16599                        {
16600                            sleep(d);
16601                            continue;
16602                        }
16603
16604                        dlg.finished(false);
16605
16606                        return match server_response {
16607                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
16608                            None => Err(client::Error::Failure(restored_response)),
16609                        };
16610                    }
16611                    let result_value = {
16612                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16613
16614                        match json::from_str(&res_body_string) {
16615                            Ok(decoded) => (res, decoded),
16616                            Err(err) => {
16617                                dlg.response_json_decode_error(&res_body_string, &err);
16618                                return Err(client::Error::JsonDecodeError(res_body_string, err));
16619                            }
16620                        }
16621                    };
16622
16623                    dlg.finished(true);
16624                    return Ok(result_value);
16625                }
16626            }
16627        }
16628    }
16629
16630    ///
16631    /// Sets the *request* property to the given value.
16632    ///
16633    /// Even though the property as already been set when instantiating this call,
16634    /// we provide this method for API completeness.
16635    pub fn request(mut self, new_value: Revision) -> RevisionUpdateCall<'a, S> {
16636        self._request = new_value;
16637        self
16638    }
16639    /// The ID of the file.
16640    ///
16641    /// Sets the *file id* path property to the given value.
16642    ///
16643    /// Even though the property as already been set when instantiating this call,
16644    /// we provide this method for API completeness.
16645    pub fn file_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, S> {
16646        self._file_id = new_value.to_string();
16647        self
16648    }
16649    /// The ID of the revision.
16650    ///
16651    /// Sets the *revision id* path property to the given value.
16652    ///
16653    /// Even though the property as already been set when instantiating this call,
16654    /// we provide this method for API completeness.
16655    pub fn revision_id(mut self, new_value: &str) -> RevisionUpdateCall<'a, S> {
16656        self._revision_id = new_value.to_string();
16657        self
16658    }
16659    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16660    /// while executing the actual API request.
16661    ///
16662    /// It should be used to handle progress information, and to implement a certain level of resilience.
16663    ///
16664    /// Sets the *delegate* property to the given value.
16665    pub fn delegate(
16666        mut self,
16667        new_value: &'a mut dyn client::Delegate,
16668    ) -> RevisionUpdateCall<'a, S> {
16669        self._delegate = Some(new_value);
16670        self
16671    }
16672
16673    /// Set any additional parameter of the query string used in the request.
16674    /// It should be used to set parameters which are not yet available through their own
16675    /// setters.
16676    ///
16677    /// Please note that this method must not be used to set any of the known parameters
16678    /// which have their own setter method. If done anyway, the request will fail.
16679    ///
16680    /// # Additional Parameters
16681    ///
16682    /// * *alt* (query-string) - Data format for the response.
16683    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16684    /// * *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.
16685    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16686    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16687    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16688    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16689    pub fn param<T>(mut self, name: T, value: T) -> RevisionUpdateCall<'a, S>
16690    where
16691        T: AsRef<str>,
16692    {
16693        self._additional_params
16694            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16695        self
16696    }
16697
16698    /// Identifies the authorization scope for the method you are building.
16699    ///
16700    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16701    /// `Scope::Full`.
16702    ///
16703    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16704    /// tokens for more than one scope.
16705    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16706    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16707    /// function for details).
16708    ///
16709    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16710    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16711    /// sufficient, a read-write scope will do as well.
16712    pub fn add_scope<T, St>(mut self, scope: T) -> RevisionUpdateCall<'a, S>
16713    where
16714        T: Into<Option<St>>,
16715        St: AsRef<str>,
16716    {
16717        match scope.into() {
16718            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16719            None => None,
16720        };
16721        self
16722    }
16723}
16724
16725/// Deprecated use drives.create instead.
16726///
16727/// A builder for the *create* method supported by a *teamdrive* resource.
16728/// It is not used directly, but through a `TeamdriveMethods` instance.
16729///
16730/// # Example
16731///
16732/// Instantiate a resource method builder
16733///
16734/// ```test_harness,no_run
16735/// # extern crate hyper;
16736/// # extern crate hyper_rustls;
16737/// # extern crate google_drive3 as drive3;
16738/// use drive3::api::TeamDrive;
16739/// # async fn dox() {
16740/// # use std::default::Default;
16741/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
16742///
16743/// # let secret: oauth2::ApplicationSecret = Default::default();
16744/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
16745/// #         secret,
16746/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16747/// #     ).build().await.unwrap();
16748/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
16749/// // As the method needs a request, you would usually fill it with the desired information
16750/// // into the respective structure. Some of the parts shown here might not be applicable !
16751/// // Values shown here are possibly random and not representative !
16752/// let mut req = TeamDrive::default();
16753///
16754/// // You can configure optional parameters by calling the respective setters at will, and
16755/// // execute the final call using `doit()`.
16756/// // Values shown here are possibly random and not representative !
16757/// let result = hub.teamdrives().create(req, "requestId")
16758///              .doit().await;
16759/// # }
16760/// ```
16761pub struct TeamdriveCreateCall<'a, S>
16762where
16763    S: 'a,
16764{
16765    hub: &'a DriveHub<S>,
16766    _request: TeamDrive,
16767    _request_id: String,
16768    _delegate: Option<&'a mut dyn client::Delegate>,
16769    _additional_params: HashMap<String, String>,
16770    _scopes: BTreeMap<String, ()>,
16771}
16772
16773impl<'a, S> client::CallBuilder for TeamdriveCreateCall<'a, S> {}
16774
16775impl<'a, S> TeamdriveCreateCall<'a, S>
16776where
16777    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
16778    S::Response:
16779        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
16780    S::Future: Send + Unpin + 'static,
16781    S::Error: Into<Box<dyn StdError + Send + Sync>>,
16782{
16783    /// Perform the operation you have build so far.
16784    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TeamDrive)> {
16785        use client::ToParts;
16786        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16787        use std::io::{Read, Seek};
16788        let mut dd = client::DefaultDelegate;
16789        let mut dlg: &mut dyn client::Delegate = match self._delegate {
16790            Some(d) => d,
16791            None => &mut dd,
16792        };
16793        dlg.begin(client::MethodInfo {
16794            id: "drive.teamdrives.create",
16795            http_method: hyper::Method::POST,
16796        });
16797        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
16798        params.push(("requestId", self._request_id.to_string()));
16799        for &field in ["alt", "requestId"].iter() {
16800            if self._additional_params.contains_key(field) {
16801                dlg.finished(false);
16802                return Err(client::Error::FieldClash(field));
16803            }
16804        }
16805        for (name, value) in self._additional_params.iter() {
16806            params.push((&name, value.clone()));
16807        }
16808
16809        params.push(("alt", "json".to_string()));
16810
16811        let mut url = self.hub._base_url.clone() + "teamdrives";
16812        if self._scopes.len() == 0 {
16813            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
16814        }
16815
16816        let url = url::Url::parse_with_params(&url, params).unwrap();
16817
16818        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
16819        let mut request_value_reader = {
16820            let mut value = json::value::to_value(&self._request).expect("serde to work");
16821            client::remove_json_null_values(&mut value);
16822            let mut dst = io::Cursor::new(Vec::with_capacity(128));
16823            json::to_writer(&mut dst, &value).unwrap();
16824            dst
16825        };
16826        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
16827        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16828
16829        loop {
16830            let token = match self
16831                .hub
16832                .auth
16833                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
16834                .await
16835            {
16836                Ok(token) => token.clone(),
16837                Err(err) => match dlg.token(&err) {
16838                    Some(token) => token,
16839                    None => {
16840                        dlg.finished(false);
16841                        return Err(client::Error::MissingToken(err));
16842                    }
16843                },
16844            };
16845            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
16846            let mut req_result = {
16847                let client = &self.hub.client;
16848                dlg.pre_request();
16849                let mut req_builder = hyper::Request::builder()
16850                    .method(hyper::Method::POST)
16851                    .uri(url.clone().into_string())
16852                    .header(USER_AGENT, self.hub._user_agent.clone())
16853                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
16854
16855                let request = req_builder
16856                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
16857                    .header(CONTENT_LENGTH, request_size as u64)
16858                    .body(hyper::body::Body::from(
16859                        request_value_reader.get_ref().clone(),
16860                    ));
16861
16862                client.request(request.unwrap()).await
16863            };
16864
16865            match req_result {
16866                Err(err) => {
16867                    if let client::Retry::After(d) = dlg.http_error(&err) {
16868                        sleep(d);
16869                        continue;
16870                    }
16871                    dlg.finished(false);
16872                    return Err(client::Error::HttpError(err));
16873                }
16874                Ok(mut res) => {
16875                    if !res.status().is_success() {
16876                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16877                        let (parts, _) = res.into_parts();
16878                        let body = hyper::Body::from(res_body_string.clone());
16879                        let restored_response = hyper::Response::from_parts(parts, body);
16880
16881                        let server_response =
16882                            json::from_str::<serde_json::Value>(&res_body_string).ok();
16883
16884                        if let client::Retry::After(d) =
16885                            dlg.http_failure(&restored_response, server_response.clone())
16886                        {
16887                            sleep(d);
16888                            continue;
16889                        }
16890
16891                        dlg.finished(false);
16892
16893                        return match server_response {
16894                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
16895                            None => Err(client::Error::Failure(restored_response)),
16896                        };
16897                    }
16898                    let result_value = {
16899                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
16900
16901                        match json::from_str(&res_body_string) {
16902                            Ok(decoded) => (res, decoded),
16903                            Err(err) => {
16904                                dlg.response_json_decode_error(&res_body_string, &err);
16905                                return Err(client::Error::JsonDecodeError(res_body_string, err));
16906                            }
16907                        }
16908                    };
16909
16910                    dlg.finished(true);
16911                    return Ok(result_value);
16912                }
16913            }
16914        }
16915    }
16916
16917    ///
16918    /// Sets the *request* property to the given value.
16919    ///
16920    /// Even though the property as already been set when instantiating this call,
16921    /// we provide this method for API completeness.
16922    pub fn request(mut self, new_value: TeamDrive) -> TeamdriveCreateCall<'a, S> {
16923        self._request = new_value;
16924        self
16925    }
16926    /// An ID, such as a random UUID, which uniquely identifies this user's request for idempotent creation of a Team Drive. A repeated request by the same user and with the same request ID will avoid creating duplicates by attempting to create the same Team Drive. If the Team Drive already exists a 409 error will be returned.
16927    ///
16928    /// Sets the *request id* query property to the given value.
16929    ///
16930    /// Even though the property as already been set when instantiating this call,
16931    /// we provide this method for API completeness.
16932    pub fn request_id(mut self, new_value: &str) -> TeamdriveCreateCall<'a, S> {
16933        self._request_id = new_value.to_string();
16934        self
16935    }
16936    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16937    /// while executing the actual API request.
16938    ///
16939    /// It should be used to handle progress information, and to implement a certain level of resilience.
16940    ///
16941    /// Sets the *delegate* property to the given value.
16942    pub fn delegate(
16943        mut self,
16944        new_value: &'a mut dyn client::Delegate,
16945    ) -> TeamdriveCreateCall<'a, S> {
16946        self._delegate = Some(new_value);
16947        self
16948    }
16949
16950    /// Set any additional parameter of the query string used in the request.
16951    /// It should be used to set parameters which are not yet available through their own
16952    /// setters.
16953    ///
16954    /// Please note that this method must not be used to set any of the known parameters
16955    /// which have their own setter method. If done anyway, the request will fail.
16956    ///
16957    /// # Additional Parameters
16958    ///
16959    /// * *alt* (query-string) - Data format for the response.
16960    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16961    /// * *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.
16962    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16963    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16964    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
16965    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
16966    pub fn param<T>(mut self, name: T, value: T) -> TeamdriveCreateCall<'a, S>
16967    where
16968        T: AsRef<str>,
16969    {
16970        self._additional_params
16971            .insert(name.as_ref().to_string(), value.as_ref().to_string());
16972        self
16973    }
16974
16975    /// Identifies the authorization scope for the method you are building.
16976    ///
16977    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
16978    /// `Scope::Full`.
16979    ///
16980    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16981    /// tokens for more than one scope.
16982    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
16983    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
16984    /// function for details).
16985    ///
16986    /// Usually there is more than one suitable scope to authorize an operation, some of which may
16987    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16988    /// sufficient, a read-write scope will do as well.
16989    pub fn add_scope<T, St>(mut self, scope: T) -> TeamdriveCreateCall<'a, S>
16990    where
16991        T: Into<Option<St>>,
16992        St: AsRef<str>,
16993    {
16994        match scope.into() {
16995            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
16996            None => None,
16997        };
16998        self
16999    }
17000}
17001
17002/// Deprecated use drives.delete instead.
17003///
17004/// A builder for the *delete* method supported by a *teamdrive* resource.
17005/// It is not used directly, but through a `TeamdriveMethods` instance.
17006///
17007/// # Example
17008///
17009/// Instantiate a resource method builder
17010///
17011/// ```test_harness,no_run
17012/// # extern crate hyper;
17013/// # extern crate hyper_rustls;
17014/// # extern crate google_drive3 as drive3;
17015/// # async fn dox() {
17016/// # use std::default::Default;
17017/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
17018///
17019/// # let secret: oauth2::ApplicationSecret = Default::default();
17020/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
17021/// #         secret,
17022/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17023/// #     ).build().await.unwrap();
17024/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
17025/// // You can configure optional parameters by calling the respective setters at will, and
17026/// // execute the final call using `doit()`.
17027/// // Values shown here are possibly random and not representative !
17028/// let result = hub.teamdrives().delete("teamDriveId")
17029///              .doit().await;
17030/// # }
17031/// ```
17032pub struct TeamdriveDeleteCall<'a, S>
17033where
17034    S: 'a,
17035{
17036    hub: &'a DriveHub<S>,
17037    _team_drive_id: String,
17038    _delegate: Option<&'a mut dyn client::Delegate>,
17039    _additional_params: HashMap<String, String>,
17040    _scopes: BTreeMap<String, ()>,
17041}
17042
17043impl<'a, S> client::CallBuilder for TeamdriveDeleteCall<'a, S> {}
17044
17045impl<'a, S> TeamdriveDeleteCall<'a, S>
17046where
17047    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
17048    S::Response:
17049        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
17050    S::Future: Send + Unpin + 'static,
17051    S::Error: Into<Box<dyn StdError + Send + Sync>>,
17052{
17053    /// Perform the operation you have build so far.
17054    pub async fn doit(mut self) -> client::Result<hyper::Response<hyper::body::Body>> {
17055        use client::ToParts;
17056        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17057        use std::io::{Read, Seek};
17058        let mut dd = client::DefaultDelegate;
17059        let mut dlg: &mut dyn client::Delegate = match self._delegate {
17060            Some(d) => d,
17061            None => &mut dd,
17062        };
17063        dlg.begin(client::MethodInfo {
17064            id: "drive.teamdrives.delete",
17065            http_method: hyper::Method::DELETE,
17066        });
17067        let mut params: Vec<(&str, String)> = Vec::with_capacity(2 + self._additional_params.len());
17068        params.push(("teamDriveId", self._team_drive_id.to_string()));
17069        for &field in ["teamDriveId"].iter() {
17070            if self._additional_params.contains_key(field) {
17071                dlg.finished(false);
17072                return Err(client::Error::FieldClash(field));
17073            }
17074        }
17075        for (name, value) in self._additional_params.iter() {
17076            params.push((&name, value.clone()));
17077        }
17078
17079        let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
17080        if self._scopes.len() == 0 {
17081            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
17082        }
17083
17084        for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
17085            let mut replace_with: Option<&str> = None;
17086            for &(name, ref value) in params.iter() {
17087                if name == param_name {
17088                    replace_with = Some(value);
17089                    break;
17090                }
17091            }
17092            url = url.replace(
17093                find_this,
17094                replace_with.expect("to find substitution value in params"),
17095            );
17096        }
17097        {
17098            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
17099            for param_name in ["teamDriveId"].iter() {
17100                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17101                    indices_for_removal.push(index);
17102                }
17103            }
17104            for &index in indices_for_removal.iter() {
17105                params.remove(index);
17106            }
17107        }
17108
17109        let url = url::Url::parse_with_params(&url, params).unwrap();
17110
17111        loop {
17112            let token = match self
17113                .hub
17114                .auth
17115                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
17116                .await
17117            {
17118                Ok(token) => token.clone(),
17119                Err(err) => match dlg.token(&err) {
17120                    Some(token) => token,
17121                    None => {
17122                        dlg.finished(false);
17123                        return Err(client::Error::MissingToken(err));
17124                    }
17125                },
17126            };
17127            let mut req_result = {
17128                let client = &self.hub.client;
17129                dlg.pre_request();
17130                let mut req_builder = hyper::Request::builder()
17131                    .method(hyper::Method::DELETE)
17132                    .uri(url.clone().into_string())
17133                    .header(USER_AGENT, self.hub._user_agent.clone())
17134                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
17135
17136                let request = req_builder.body(hyper::body::Body::empty());
17137
17138                client.request(request.unwrap()).await
17139            };
17140
17141            match req_result {
17142                Err(err) => {
17143                    if let client::Retry::After(d) = dlg.http_error(&err) {
17144                        sleep(d);
17145                        continue;
17146                    }
17147                    dlg.finished(false);
17148                    return Err(client::Error::HttpError(err));
17149                }
17150                Ok(mut res) => {
17151                    if !res.status().is_success() {
17152                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
17153                        let (parts, _) = res.into_parts();
17154                        let body = hyper::Body::from(res_body_string.clone());
17155                        let restored_response = hyper::Response::from_parts(parts, body);
17156
17157                        let server_response =
17158                            json::from_str::<serde_json::Value>(&res_body_string).ok();
17159
17160                        if let client::Retry::After(d) =
17161                            dlg.http_failure(&restored_response, server_response.clone())
17162                        {
17163                            sleep(d);
17164                            continue;
17165                        }
17166
17167                        dlg.finished(false);
17168
17169                        return match server_response {
17170                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
17171                            None => Err(client::Error::Failure(restored_response)),
17172                        };
17173                    }
17174                    let result_value = res;
17175
17176                    dlg.finished(true);
17177                    return Ok(result_value);
17178                }
17179            }
17180        }
17181    }
17182
17183    /// The ID of the Team Drive
17184    ///
17185    /// Sets the *team drive id* path property to the given value.
17186    ///
17187    /// Even though the property as already been set when instantiating this call,
17188    /// we provide this method for API completeness.
17189    pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveDeleteCall<'a, S> {
17190        self._team_drive_id = new_value.to_string();
17191        self
17192    }
17193    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17194    /// while executing the actual API request.
17195    ///
17196    /// It should be used to handle progress information, and to implement a certain level of resilience.
17197    ///
17198    /// Sets the *delegate* property to the given value.
17199    pub fn delegate(
17200        mut self,
17201        new_value: &'a mut dyn client::Delegate,
17202    ) -> TeamdriveDeleteCall<'a, S> {
17203        self._delegate = Some(new_value);
17204        self
17205    }
17206
17207    /// Set any additional parameter of the query string used in the request.
17208    /// It should be used to set parameters which are not yet available through their own
17209    /// setters.
17210    ///
17211    /// Please note that this method must not be used to set any of the known parameters
17212    /// which have their own setter method. If done anyway, the request will fail.
17213    ///
17214    /// # Additional Parameters
17215    ///
17216    /// * *alt* (query-string) - Data format for the response.
17217    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17218    /// * *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.
17219    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17220    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17221    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17222    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17223    pub fn param<T>(mut self, name: T, value: T) -> TeamdriveDeleteCall<'a, S>
17224    where
17225        T: AsRef<str>,
17226    {
17227        self._additional_params
17228            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17229        self
17230    }
17231
17232    /// Identifies the authorization scope for the method you are building.
17233    ///
17234    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17235    /// `Scope::Full`.
17236    ///
17237    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17238    /// tokens for more than one scope.
17239    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17240    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17241    /// function for details).
17242    ///
17243    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17244    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17245    /// sufficient, a read-write scope will do as well.
17246    pub fn add_scope<T, St>(mut self, scope: T) -> TeamdriveDeleteCall<'a, S>
17247    where
17248        T: Into<Option<St>>,
17249        St: AsRef<str>,
17250    {
17251        match scope.into() {
17252            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17253            None => None,
17254        };
17255        self
17256    }
17257}
17258
17259/// Deprecated use drives.get instead.
17260///
17261/// A builder for the *get* method supported by a *teamdrive* resource.
17262/// It is not used directly, but through a `TeamdriveMethods` instance.
17263///
17264/// # Example
17265///
17266/// Instantiate a resource method builder
17267///
17268/// ```test_harness,no_run
17269/// # extern crate hyper;
17270/// # extern crate hyper_rustls;
17271/// # extern crate google_drive3 as drive3;
17272/// # async fn dox() {
17273/// # use std::default::Default;
17274/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
17275///
17276/// # let secret: oauth2::ApplicationSecret = Default::default();
17277/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
17278/// #         secret,
17279/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17280/// #     ).build().await.unwrap();
17281/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
17282/// // You can configure optional parameters by calling the respective setters at will, and
17283/// // execute the final call using `doit()`.
17284/// // Values shown here are possibly random and not representative !
17285/// let result = hub.teamdrives().get("teamDriveId")
17286///              .use_domain_admin_access(true)
17287///              .doit().await;
17288/// # }
17289/// ```
17290pub struct TeamdriveGetCall<'a, S>
17291where
17292    S: 'a,
17293{
17294    hub: &'a DriveHub<S>,
17295    _team_drive_id: String,
17296    _use_domain_admin_access: Option<bool>,
17297    _delegate: Option<&'a mut dyn client::Delegate>,
17298    _additional_params: HashMap<String, String>,
17299    _scopes: BTreeMap<String, ()>,
17300}
17301
17302impl<'a, S> client::CallBuilder for TeamdriveGetCall<'a, S> {}
17303
17304impl<'a, S> TeamdriveGetCall<'a, S>
17305where
17306    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
17307    S::Response:
17308        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
17309    S::Future: Send + Unpin + 'static,
17310    S::Error: Into<Box<dyn StdError + Send + Sync>>,
17311{
17312    /// Perform the operation you have build so far.
17313    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TeamDrive)> {
17314        use client::ToParts;
17315        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17316        use std::io::{Read, Seek};
17317        let mut dd = client::DefaultDelegate;
17318        let mut dlg: &mut dyn client::Delegate = match self._delegate {
17319            Some(d) => d,
17320            None => &mut dd,
17321        };
17322        dlg.begin(client::MethodInfo {
17323            id: "drive.teamdrives.get",
17324            http_method: hyper::Method::GET,
17325        });
17326        let mut params: Vec<(&str, String)> = Vec::with_capacity(4 + self._additional_params.len());
17327        params.push(("teamDriveId", self._team_drive_id.to_string()));
17328        if let Some(value) = self._use_domain_admin_access {
17329            params.push(("useDomainAdminAccess", value.to_string()));
17330        }
17331        for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
17332            if self._additional_params.contains_key(field) {
17333                dlg.finished(false);
17334                return Err(client::Error::FieldClash(field));
17335            }
17336        }
17337        for (name, value) in self._additional_params.iter() {
17338            params.push((&name, value.clone()));
17339        }
17340
17341        params.push(("alt", "json".to_string()));
17342
17343        let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
17344        if self._scopes.len() == 0 {
17345            self._scopes
17346                .insert(Scope::Readonly.as_ref().to_string(), ());
17347        }
17348
17349        for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
17350            let mut replace_with: Option<&str> = None;
17351            for &(name, ref value) in params.iter() {
17352                if name == param_name {
17353                    replace_with = Some(value);
17354                    break;
17355                }
17356            }
17357            url = url.replace(
17358                find_this,
17359                replace_with.expect("to find substitution value in params"),
17360            );
17361        }
17362        {
17363            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
17364            for param_name in ["teamDriveId"].iter() {
17365                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17366                    indices_for_removal.push(index);
17367                }
17368            }
17369            for &index in indices_for_removal.iter() {
17370                params.remove(index);
17371            }
17372        }
17373
17374        let url = url::Url::parse_with_params(&url, params).unwrap();
17375
17376        loop {
17377            let token = match self
17378                .hub
17379                .auth
17380                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
17381                .await
17382            {
17383                Ok(token) => token.clone(),
17384                Err(err) => match dlg.token(&err) {
17385                    Some(token) => token,
17386                    None => {
17387                        dlg.finished(false);
17388                        return Err(client::Error::MissingToken(err));
17389                    }
17390                },
17391            };
17392            let mut req_result = {
17393                let client = &self.hub.client;
17394                dlg.pre_request();
17395                let mut req_builder = hyper::Request::builder()
17396                    .method(hyper::Method::GET)
17397                    .uri(url.clone().into_string())
17398                    .header(USER_AGENT, self.hub._user_agent.clone())
17399                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
17400
17401                let request = req_builder.body(hyper::body::Body::empty());
17402
17403                client.request(request.unwrap()).await
17404            };
17405
17406            match req_result {
17407                Err(err) => {
17408                    if let client::Retry::After(d) = dlg.http_error(&err) {
17409                        sleep(d);
17410                        continue;
17411                    }
17412                    dlg.finished(false);
17413                    return Err(client::Error::HttpError(err));
17414                }
17415                Ok(mut res) => {
17416                    if !res.status().is_success() {
17417                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
17418                        let (parts, _) = res.into_parts();
17419                        let body = hyper::Body::from(res_body_string.clone());
17420                        let restored_response = hyper::Response::from_parts(parts, body);
17421
17422                        let server_response =
17423                            json::from_str::<serde_json::Value>(&res_body_string).ok();
17424
17425                        if let client::Retry::After(d) =
17426                            dlg.http_failure(&restored_response, server_response.clone())
17427                        {
17428                            sleep(d);
17429                            continue;
17430                        }
17431
17432                        dlg.finished(false);
17433
17434                        return match server_response {
17435                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
17436                            None => Err(client::Error::Failure(restored_response)),
17437                        };
17438                    }
17439                    let result_value = {
17440                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
17441
17442                        match json::from_str(&res_body_string) {
17443                            Ok(decoded) => (res, decoded),
17444                            Err(err) => {
17445                                dlg.response_json_decode_error(&res_body_string, &err);
17446                                return Err(client::Error::JsonDecodeError(res_body_string, err));
17447                            }
17448                        }
17449                    };
17450
17451                    dlg.finished(true);
17452                    return Ok(result_value);
17453                }
17454            }
17455        }
17456    }
17457
17458    /// The ID of the Team Drive
17459    ///
17460    /// Sets the *team drive id* path property to the given value.
17461    ///
17462    /// Even though the property as already been set when instantiating this call,
17463    /// we provide this method for API completeness.
17464    pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveGetCall<'a, S> {
17465        self._team_drive_id = new_value.to_string();
17466        self
17467    }
17468    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the Team Drive belongs.
17469    ///
17470    /// Sets the *use domain admin access* query property to the given value.
17471    pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveGetCall<'a, S> {
17472        self._use_domain_admin_access = Some(new_value);
17473        self
17474    }
17475    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17476    /// while executing the actual API request.
17477    ///
17478    /// It should be used to handle progress information, and to implement a certain level of resilience.
17479    ///
17480    /// Sets the *delegate* property to the given value.
17481    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveGetCall<'a, S> {
17482        self._delegate = Some(new_value);
17483        self
17484    }
17485
17486    /// Set any additional parameter of the query string used in the request.
17487    /// It should be used to set parameters which are not yet available through their own
17488    /// setters.
17489    ///
17490    /// Please note that this method must not be used to set any of the known parameters
17491    /// which have their own setter method. If done anyway, the request will fail.
17492    ///
17493    /// # Additional Parameters
17494    ///
17495    /// * *alt* (query-string) - Data format for the response.
17496    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17497    /// * *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.
17498    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17499    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17500    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17501    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17502    pub fn param<T>(mut self, name: T, value: T) -> TeamdriveGetCall<'a, S>
17503    where
17504        T: AsRef<str>,
17505    {
17506        self._additional_params
17507            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17508        self
17509    }
17510
17511    /// Identifies the authorization scope for the method you are building.
17512    ///
17513    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17514    /// `Scope::Readonly`.
17515    ///
17516    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17517    /// tokens for more than one scope.
17518    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17519    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17520    /// function for details).
17521    ///
17522    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17523    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17524    /// sufficient, a read-write scope will do as well.
17525    pub fn add_scope<T, St>(mut self, scope: T) -> TeamdriveGetCall<'a, S>
17526    where
17527        T: Into<Option<St>>,
17528        St: AsRef<str>,
17529    {
17530        match scope.into() {
17531            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17532            None => None,
17533        };
17534        self
17535    }
17536}
17537
17538/// Deprecated use drives.list instead.
17539///
17540/// A builder for the *list* method supported by a *teamdrive* resource.
17541/// It is not used directly, but through a `TeamdriveMethods` instance.
17542///
17543/// # Example
17544///
17545/// Instantiate a resource method builder
17546///
17547/// ```test_harness,no_run
17548/// # extern crate hyper;
17549/// # extern crate hyper_rustls;
17550/// # extern crate google_drive3 as drive3;
17551/// # async fn dox() {
17552/// # use std::default::Default;
17553/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
17554///
17555/// # let secret: oauth2::ApplicationSecret = Default::default();
17556/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
17557/// #         secret,
17558/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17559/// #     ).build().await.unwrap();
17560/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
17561/// // You can configure optional parameters by calling the respective setters at will, and
17562/// // execute the final call using `doit()`.
17563/// // Values shown here are possibly random and not representative !
17564/// let result = hub.teamdrives().list()
17565///              .use_domain_admin_access(true)
17566///              .q("sit")
17567///              .page_token("kasd")
17568///              .page_size(-47)
17569///              .doit().await;
17570/// # }
17571/// ```
17572pub struct TeamdriveListCall<'a, S>
17573where
17574    S: 'a,
17575{
17576    hub: &'a DriveHub<S>,
17577    _use_domain_admin_access: Option<bool>,
17578    _q: Option<String>,
17579    _page_token: Option<String>,
17580    _page_size: Option<i32>,
17581    _delegate: Option<&'a mut dyn client::Delegate>,
17582    _additional_params: HashMap<String, String>,
17583    _scopes: BTreeMap<String, ()>,
17584}
17585
17586impl<'a, S> client::CallBuilder for TeamdriveListCall<'a, S> {}
17587
17588impl<'a, S> TeamdriveListCall<'a, S>
17589where
17590    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
17591    S::Response:
17592        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
17593    S::Future: Send + Unpin + 'static,
17594    S::Error: Into<Box<dyn StdError + Send + Sync>>,
17595{
17596    /// Perform the operation you have build so far.
17597    pub async fn doit(
17598        mut self,
17599    ) -> client::Result<(hyper::Response<hyper::body::Body>, TeamDriveList)> {
17600        use client::ToParts;
17601        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17602        use std::io::{Read, Seek};
17603        let mut dd = client::DefaultDelegate;
17604        let mut dlg: &mut dyn client::Delegate = match self._delegate {
17605            Some(d) => d,
17606            None => &mut dd,
17607        };
17608        dlg.begin(client::MethodInfo {
17609            id: "drive.teamdrives.list",
17610            http_method: hyper::Method::GET,
17611        });
17612        let mut params: Vec<(&str, String)> = Vec::with_capacity(6 + self._additional_params.len());
17613        if let Some(value) = self._use_domain_admin_access {
17614            params.push(("useDomainAdminAccess", value.to_string()));
17615        }
17616        if let Some(value) = self._q {
17617            params.push(("q", value.to_string()));
17618        }
17619        if let Some(value) = self._page_token {
17620            params.push(("pageToken", value.to_string()));
17621        }
17622        if let Some(value) = self._page_size {
17623            params.push(("pageSize", value.to_string()));
17624        }
17625        for &field in ["alt", "useDomainAdminAccess", "q", "pageToken", "pageSize"].iter() {
17626            if self._additional_params.contains_key(field) {
17627                dlg.finished(false);
17628                return Err(client::Error::FieldClash(field));
17629            }
17630        }
17631        for (name, value) in self._additional_params.iter() {
17632            params.push((&name, value.clone()));
17633        }
17634
17635        params.push(("alt", "json".to_string()));
17636
17637        let mut url = self.hub._base_url.clone() + "teamdrives";
17638        if self._scopes.len() == 0 {
17639            self._scopes
17640                .insert(Scope::Readonly.as_ref().to_string(), ());
17641        }
17642
17643        let url = url::Url::parse_with_params(&url, params).unwrap();
17644
17645        loop {
17646            let token = match self
17647                .hub
17648                .auth
17649                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
17650                .await
17651            {
17652                Ok(token) => token.clone(),
17653                Err(err) => match dlg.token(&err) {
17654                    Some(token) => token,
17655                    None => {
17656                        dlg.finished(false);
17657                        return Err(client::Error::MissingToken(err));
17658                    }
17659                },
17660            };
17661            let mut req_result = {
17662                let client = &self.hub.client;
17663                dlg.pre_request();
17664                let mut req_builder = hyper::Request::builder()
17665                    .method(hyper::Method::GET)
17666                    .uri(url.clone().into_string())
17667                    .header(USER_AGENT, self.hub._user_agent.clone())
17668                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
17669
17670                let request = req_builder.body(hyper::body::Body::empty());
17671
17672                client.request(request.unwrap()).await
17673            };
17674
17675            match req_result {
17676                Err(err) => {
17677                    if let client::Retry::After(d) = dlg.http_error(&err) {
17678                        sleep(d);
17679                        continue;
17680                    }
17681                    dlg.finished(false);
17682                    return Err(client::Error::HttpError(err));
17683                }
17684                Ok(mut res) => {
17685                    if !res.status().is_success() {
17686                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
17687                        let (parts, _) = res.into_parts();
17688                        let body = hyper::Body::from(res_body_string.clone());
17689                        let restored_response = hyper::Response::from_parts(parts, body);
17690
17691                        let server_response =
17692                            json::from_str::<serde_json::Value>(&res_body_string).ok();
17693
17694                        if let client::Retry::After(d) =
17695                            dlg.http_failure(&restored_response, server_response.clone())
17696                        {
17697                            sleep(d);
17698                            continue;
17699                        }
17700
17701                        dlg.finished(false);
17702
17703                        return match server_response {
17704                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
17705                            None => Err(client::Error::Failure(restored_response)),
17706                        };
17707                    }
17708                    let result_value = {
17709                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
17710
17711                        match json::from_str(&res_body_string) {
17712                            Ok(decoded) => (res, decoded),
17713                            Err(err) => {
17714                                dlg.response_json_decode_error(&res_body_string, &err);
17715                                return Err(client::Error::JsonDecodeError(res_body_string, err));
17716                            }
17717                        }
17718                    };
17719
17720                    dlg.finished(true);
17721                    return Ok(result_value);
17722                }
17723            }
17724        }
17725    }
17726
17727    /// Issue the request as a domain administrator; if set to true, then all Team Drives of the domain in which the requester is an administrator are returned.
17728    ///
17729    /// Sets the *use domain admin access* query property to the given value.
17730    pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveListCall<'a, S> {
17731        self._use_domain_admin_access = Some(new_value);
17732        self
17733    }
17734    /// Query string for searching Team Drives.
17735    ///
17736    /// Sets the *q* query property to the given value.
17737    pub fn q(mut self, new_value: &str) -> TeamdriveListCall<'a, S> {
17738        self._q = Some(new_value.to_string());
17739        self
17740    }
17741    /// Page token for Team Drives.
17742    ///
17743    /// Sets the *page token* query property to the given value.
17744    pub fn page_token(mut self, new_value: &str) -> TeamdriveListCall<'a, S> {
17745        self._page_token = Some(new_value.to_string());
17746        self
17747    }
17748    /// Maximum number of Team Drives to return.
17749    ///
17750    /// Sets the *page size* query property to the given value.
17751    pub fn page_size(mut self, new_value: i32) -> TeamdriveListCall<'a, S> {
17752        self._page_size = Some(new_value);
17753        self
17754    }
17755    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17756    /// while executing the actual API request.
17757    ///
17758    /// It should be used to handle progress information, and to implement a certain level of resilience.
17759    ///
17760    /// Sets the *delegate* property to the given value.
17761    pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> TeamdriveListCall<'a, S> {
17762        self._delegate = Some(new_value);
17763        self
17764    }
17765
17766    /// Set any additional parameter of the query string used in the request.
17767    /// It should be used to set parameters which are not yet available through their own
17768    /// setters.
17769    ///
17770    /// Please note that this method must not be used to set any of the known parameters
17771    /// which have their own setter method. If done anyway, the request will fail.
17772    ///
17773    /// # Additional Parameters
17774    ///
17775    /// * *alt* (query-string) - Data format for the response.
17776    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17777    /// * *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.
17778    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17779    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17780    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
17781    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
17782    pub fn param<T>(mut self, name: T, value: T) -> TeamdriveListCall<'a, S>
17783    where
17784        T: AsRef<str>,
17785    {
17786        self._additional_params
17787            .insert(name.as_ref().to_string(), value.as_ref().to_string());
17788        self
17789    }
17790
17791    /// Identifies the authorization scope for the method you are building.
17792    ///
17793    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
17794    /// `Scope::Readonly`.
17795    ///
17796    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17797    /// tokens for more than one scope.
17798    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
17799    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
17800    /// function for details).
17801    ///
17802    /// Usually there is more than one suitable scope to authorize an operation, some of which may
17803    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17804    /// sufficient, a read-write scope will do as well.
17805    pub fn add_scope<T, St>(mut self, scope: T) -> TeamdriveListCall<'a, S>
17806    where
17807        T: Into<Option<St>>,
17808        St: AsRef<str>,
17809    {
17810        match scope.into() {
17811            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
17812            None => None,
17813        };
17814        self
17815    }
17816}
17817
17818/// Deprecated use drives.update instead
17819///
17820/// A builder for the *update* method supported by a *teamdrive* resource.
17821/// It is not used directly, but through a `TeamdriveMethods` instance.
17822///
17823/// # Example
17824///
17825/// Instantiate a resource method builder
17826///
17827/// ```test_harness,no_run
17828/// # extern crate hyper;
17829/// # extern crate hyper_rustls;
17830/// # extern crate google_drive3 as drive3;
17831/// use drive3::api::TeamDrive;
17832/// # async fn dox() {
17833/// # use std::default::Default;
17834/// # use drive3::{DriveHub, oauth2, hyper, hyper_rustls};
17835///
17836/// # let secret: oauth2::ApplicationSecret = Default::default();
17837/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
17838/// #         secret,
17839/// #         oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17840/// #     ).build().await.unwrap();
17841/// # let mut hub = DriveHub::new(hyper::Client::builder().build(hyper_rustls::HttpsConnector::with_native_roots().https_or_http().enable_http1().enable_http2().build()), auth);
17842/// // As the method needs a request, you would usually fill it with the desired information
17843/// // into the respective structure. Some of the parts shown here might not be applicable !
17844/// // Values shown here are possibly random and not representative !
17845/// let mut req = TeamDrive::default();
17846///
17847/// // You can configure optional parameters by calling the respective setters at will, and
17848/// // execute the final call using `doit()`.
17849/// // Values shown here are possibly random and not representative !
17850/// let result = hub.teamdrives().update(req, "teamDriveId")
17851///              .use_domain_admin_access(false)
17852///              .doit().await;
17853/// # }
17854/// ```
17855pub struct TeamdriveUpdateCall<'a, S>
17856where
17857    S: 'a,
17858{
17859    hub: &'a DriveHub<S>,
17860    _request: TeamDrive,
17861    _team_drive_id: String,
17862    _use_domain_admin_access: Option<bool>,
17863    _delegate: Option<&'a mut dyn client::Delegate>,
17864    _additional_params: HashMap<String, String>,
17865    _scopes: BTreeMap<String, ()>,
17866}
17867
17868impl<'a, S> client::CallBuilder for TeamdriveUpdateCall<'a, S> {}
17869
17870impl<'a, S> TeamdriveUpdateCall<'a, S>
17871where
17872    S: tower_service::Service<Uri> + Clone + Send + Sync + 'static,
17873    S::Response:
17874        hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
17875    S::Future: Send + Unpin + 'static,
17876    S::Error: Into<Box<dyn StdError + Send + Sync>>,
17877{
17878    /// Perform the operation you have build so far.
17879    pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TeamDrive)> {
17880        use client::ToParts;
17881        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17882        use std::io::{Read, Seek};
17883        let mut dd = client::DefaultDelegate;
17884        let mut dlg: &mut dyn client::Delegate = match self._delegate {
17885            Some(d) => d,
17886            None => &mut dd,
17887        };
17888        dlg.begin(client::MethodInfo {
17889            id: "drive.teamdrives.update",
17890            http_method: hyper::Method::PATCH,
17891        });
17892        let mut params: Vec<(&str, String)> = Vec::with_capacity(5 + self._additional_params.len());
17893        params.push(("teamDriveId", self._team_drive_id.to_string()));
17894        if let Some(value) = self._use_domain_admin_access {
17895            params.push(("useDomainAdminAccess", value.to_string()));
17896        }
17897        for &field in ["alt", "teamDriveId", "useDomainAdminAccess"].iter() {
17898            if self._additional_params.contains_key(field) {
17899                dlg.finished(false);
17900                return Err(client::Error::FieldClash(field));
17901            }
17902        }
17903        for (name, value) in self._additional_params.iter() {
17904            params.push((&name, value.clone()));
17905        }
17906
17907        params.push(("alt", "json".to_string()));
17908
17909        let mut url = self.hub._base_url.clone() + "teamdrives/{teamDriveId}";
17910        if self._scopes.len() == 0 {
17911            self._scopes.insert(Scope::Full.as_ref().to_string(), ());
17912        }
17913
17914        for &(find_this, param_name) in [("{teamDriveId}", "teamDriveId")].iter() {
17915            let mut replace_with: Option<&str> = None;
17916            for &(name, ref value) in params.iter() {
17917                if name == param_name {
17918                    replace_with = Some(value);
17919                    break;
17920                }
17921            }
17922            url = url.replace(
17923                find_this,
17924                replace_with.expect("to find substitution value in params"),
17925            );
17926        }
17927        {
17928            let mut indices_for_removal: Vec<usize> = Vec::with_capacity(1);
17929            for param_name in ["teamDriveId"].iter() {
17930                if let Some(index) = params.iter().position(|t| &t.0 == param_name) {
17931                    indices_for_removal.push(index);
17932                }
17933            }
17934            for &index in indices_for_removal.iter() {
17935                params.remove(index);
17936            }
17937        }
17938
17939        let url = url::Url::parse_with_params(&url, params).unwrap();
17940
17941        let mut json_mime_type: mime::Mime = "application/json".parse().unwrap();
17942        let mut request_value_reader = {
17943            let mut value = json::value::to_value(&self._request).expect("serde to work");
17944            client::remove_json_null_values(&mut value);
17945            let mut dst = io::Cursor::new(Vec::with_capacity(128));
17946            json::to_writer(&mut dst, &value).unwrap();
17947            dst
17948        };
17949        let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
17950        request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
17951
17952        loop {
17953            let token = match self
17954                .hub
17955                .auth
17956                .token(&self._scopes.keys().collect::<Vec<_>>()[..])
17957                .await
17958            {
17959                Ok(token) => token.clone(),
17960                Err(err) => match dlg.token(&err) {
17961                    Some(token) => token,
17962                    None => {
17963                        dlg.finished(false);
17964                        return Err(client::Error::MissingToken(err));
17965                    }
17966                },
17967            };
17968            request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
17969            let mut req_result = {
17970                let client = &self.hub.client;
17971                dlg.pre_request();
17972                let mut req_builder = hyper::Request::builder()
17973                    .method(hyper::Method::PATCH)
17974                    .uri(url.clone().into_string())
17975                    .header(USER_AGENT, self.hub._user_agent.clone())
17976                    .header(AUTHORIZATION, format!("Bearer {}", token.as_str()));
17977
17978                let request = req_builder
17979                    .header(CONTENT_TYPE, format!("{}", json_mime_type.to_string()))
17980                    .header(CONTENT_LENGTH, request_size as u64)
17981                    .body(hyper::body::Body::from(
17982                        request_value_reader.get_ref().clone(),
17983                    ));
17984
17985                client.request(request.unwrap()).await
17986            };
17987
17988            match req_result {
17989                Err(err) => {
17990                    if let client::Retry::After(d) = dlg.http_error(&err) {
17991                        sleep(d);
17992                        continue;
17993                    }
17994                    dlg.finished(false);
17995                    return Err(client::Error::HttpError(err));
17996                }
17997                Ok(mut res) => {
17998                    if !res.status().is_success() {
17999                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
18000                        let (parts, _) = res.into_parts();
18001                        let body = hyper::Body::from(res_body_string.clone());
18002                        let restored_response = hyper::Response::from_parts(parts, body);
18003
18004                        let server_response =
18005                            json::from_str::<serde_json::Value>(&res_body_string).ok();
18006
18007                        if let client::Retry::After(d) =
18008                            dlg.http_failure(&restored_response, server_response.clone())
18009                        {
18010                            sleep(d);
18011                            continue;
18012                        }
18013
18014                        dlg.finished(false);
18015
18016                        return match server_response {
18017                            Some(error_value) => Err(client::Error::BadRequest(error_value)),
18018                            None => Err(client::Error::Failure(restored_response)),
18019                        };
18020                    }
18021                    let result_value = {
18022                        let res_body_string = client::get_body_as_string(res.body_mut()).await;
18023
18024                        match json::from_str(&res_body_string) {
18025                            Ok(decoded) => (res, decoded),
18026                            Err(err) => {
18027                                dlg.response_json_decode_error(&res_body_string, &err);
18028                                return Err(client::Error::JsonDecodeError(res_body_string, err));
18029                            }
18030                        }
18031                    };
18032
18033                    dlg.finished(true);
18034                    return Ok(result_value);
18035                }
18036            }
18037        }
18038    }
18039
18040    ///
18041    /// Sets the *request* property to the given value.
18042    ///
18043    /// Even though the property as already been set when instantiating this call,
18044    /// we provide this method for API completeness.
18045    pub fn request(mut self, new_value: TeamDrive) -> TeamdriveUpdateCall<'a, S> {
18046        self._request = new_value;
18047        self
18048    }
18049    /// The ID of the Team Drive
18050    ///
18051    /// Sets the *team drive id* path property to the given value.
18052    ///
18053    /// Even though the property as already been set when instantiating this call,
18054    /// we provide this method for API completeness.
18055    pub fn team_drive_id(mut self, new_value: &str) -> TeamdriveUpdateCall<'a, S> {
18056        self._team_drive_id = new_value.to_string();
18057        self
18058    }
18059    /// Issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the Team Drive belongs.
18060    ///
18061    /// Sets the *use domain admin access* query property to the given value.
18062    pub fn use_domain_admin_access(mut self, new_value: bool) -> TeamdriveUpdateCall<'a, S> {
18063        self._use_domain_admin_access = Some(new_value);
18064        self
18065    }
18066    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18067    /// while executing the actual API request.
18068    ///
18069    /// It should be used to handle progress information, and to implement a certain level of resilience.
18070    ///
18071    /// Sets the *delegate* property to the given value.
18072    pub fn delegate(
18073        mut self,
18074        new_value: &'a mut dyn client::Delegate,
18075    ) -> TeamdriveUpdateCall<'a, S> {
18076        self._delegate = Some(new_value);
18077        self
18078    }
18079
18080    /// Set any additional parameter of the query string used in the request.
18081    /// It should be used to set parameters which are not yet available through their own
18082    /// setters.
18083    ///
18084    /// Please note that this method must not be used to set any of the known parameters
18085    /// which have their own setter method. If done anyway, the request will fail.
18086    ///
18087    /// # Additional Parameters
18088    ///
18089    /// * *alt* (query-string) - Data format for the response.
18090    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18091    /// * *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.
18092    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18093    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18094    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
18095    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
18096    pub fn param<T>(mut self, name: T, value: T) -> TeamdriveUpdateCall<'a, S>
18097    where
18098        T: AsRef<str>,
18099    {
18100        self._additional_params
18101            .insert(name.as_ref().to_string(), value.as_ref().to_string());
18102        self
18103    }
18104
18105    /// Identifies the authorization scope for the method you are building.
18106    ///
18107    /// Use this method to actively specify which scope should be used, instead the default `Scope` variant
18108    /// `Scope::Full`.
18109    ///
18110    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18111    /// tokens for more than one scope.
18112    /// If `None` is specified, then all scopes will be removed and no default scope will be used either.
18113    /// In that case, you have to specify your API-key using the `key` parameter (see the `param()`
18114    /// function for details).
18115    ///
18116    /// Usually there is more than one suitable scope to authorize an operation, some of which may
18117    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18118    /// sufficient, a read-write scope will do as well.
18119    pub fn add_scope<T, St>(mut self, scope: T) -> TeamdriveUpdateCall<'a, S>
18120    where
18121        T: Into<Option<St>>,
18122        St: AsRef<str>,
18123    {
18124        match scope.into() {
18125            Some(scope) => self._scopes.insert(scope.as_ref().to_string(), ()),
18126            None => None,
18127        };
18128        self
18129    }
18130}